From e277fb2f7316fef5c20e7c485eeba1f14328d621 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 1 Mar 2020 15:36:44 +0000 Subject: Run tests from repo root as specified in spec --- dhall/src/tests.rs | 8 +++++++- dhall/tests/import/success/unit/asLocation/Canonicalize1B.dhall | 2 +- dhall/tests/import/success/unit/asLocation/Canonicalize2B.dhall | 2 +- dhall/tests/import/success/unit/asLocation/Canonicalize3B.dhall | 2 +- dhall/tests/import/success/unit/asLocation/Canonicalize4B.dhall | 2 +- dhall/tests/import/success/unit/asLocation/Canonicalize5B.dhall | 2 +- dhall/tests/import/success/unit/asLocation/Chain1B.dhall | 2 +- dhall/tests/import/success/unit/asLocation/Chain2B.dhall | 2 +- dhall/tests/import/success/unit/asLocation/Chain3B.dhall | 2 +- dhall/tests/import/success/unit/asLocation/HashB.dhall | 2 +- dhall/tests/import/success/unit/asLocation/RelativeB.dhall | 2 +- update-tests.sh | 4 ++-- 12 files changed, 19 insertions(+), 13 deletions(-) diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 482f9ae..3649f8d 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -80,7 +80,7 @@ impl TestFile { match self { TestFile::Source(path) | TestFile::Binary(path) - | TestFile::UI(path) => PathBuf::from(path), + | TestFile::UI(path) => PathBuf::from("dhall").join(path), } } @@ -243,6 +243,11 @@ fn run_test_stringy_error(test: Test) -> std::result::Result<(), String> { fn run_test(test: Test) -> Result<()> { use self::Test::*; + // Setup current directory to the root of the repository. Important for import tests. + env::set_current_dir( + PathBuf::from(env!("CARGO_MANIFEST_DIR")).parent().unwrap(), + )?; + match test { ParserSuccess(expr, expected) => { let expr = expr.parse()?; @@ -302,6 +307,7 @@ fn run_test(test: Test) -> Result<()> { expected.compare(expr)?; } } + Ok(()) } diff --git a/dhall/tests/import/success/unit/asLocation/Canonicalize1B.dhall b/dhall/tests/import/success/unit/asLocation/Canonicalize1B.dhall index b7d9f3d..3a8a926 100644 --- a/dhall/tests/import/success/unit/asLocation/Canonicalize1B.dhall +++ b/dhall/tests/import/success/unit/asLocation/Canonicalize1B.dhall @@ -1,2 +1,2 @@ < Environment : Text | Remote : Text | Local : Text | Missing >.Local - "./tests/import/success/unit/asLocation/foo/bar/import.dhall" + "./dhall/tests/import/success/unit/asLocation/foo/bar/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/Canonicalize2B.dhall b/dhall/tests/import/success/unit/asLocation/Canonicalize2B.dhall index b7d9f3d..3a8a926 100644 --- a/dhall/tests/import/success/unit/asLocation/Canonicalize2B.dhall +++ b/dhall/tests/import/success/unit/asLocation/Canonicalize2B.dhall @@ -1,2 +1,2 @@ < Environment : Text | Remote : Text | Local : Text | Missing >.Local - "./tests/import/success/unit/asLocation/foo/bar/import.dhall" + "./dhall/tests/import/success/unit/asLocation/foo/bar/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/Canonicalize3B.dhall b/dhall/tests/import/success/unit/asLocation/Canonicalize3B.dhall index d54f065..b223da6 100644 --- a/dhall/tests/import/success/unit/asLocation/Canonicalize3B.dhall +++ b/dhall/tests/import/success/unit/asLocation/Canonicalize3B.dhall @@ -1,2 +1,2 @@ < Environment : Text | Remote : Text | Local : Text | Missing >.Local - "./tests/import/success/unit/bar/import.dhall" + "./dhall/tests/import/success/unit/bar/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/Canonicalize4B.dhall b/dhall/tests/import/success/unit/asLocation/Canonicalize4B.dhall index 7dd93f7..b6301f8 100644 --- a/dhall/tests/import/success/unit/asLocation/Canonicalize4B.dhall +++ b/dhall/tests/import/success/unit/asLocation/Canonicalize4B.dhall @@ -1,2 +1,2 @@ < Environment : Text | Remote : Text | Local : Text | Missing >.Local - "./tests/import/success/bar/import.dhall" + "./dhall/tests/import/success/bar/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/Canonicalize5B.dhall b/dhall/tests/import/success/unit/asLocation/Canonicalize5B.dhall index d54f065..b223da6 100644 --- a/dhall/tests/import/success/unit/asLocation/Canonicalize5B.dhall +++ b/dhall/tests/import/success/unit/asLocation/Canonicalize5B.dhall @@ -1,2 +1,2 @@ < Environment : Text | Remote : Text | Local : Text | Missing >.Local - "./tests/import/success/unit/bar/import.dhall" + "./dhall/tests/import/success/unit/bar/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/Chain1B.dhall b/dhall/tests/import/success/unit/asLocation/Chain1B.dhall index 3055c8e..6aee0b5 100644 --- a/dhall/tests/import/success/unit/asLocation/Chain1B.dhall +++ b/dhall/tests/import/success/unit/asLocation/Chain1B.dhall @@ -1,2 +1,2 @@ < Environment : Text | Local : Text | Missing | Remote : Text >.Local - "./tests/import/success/unit/asLocation/some/import.dhall" + "./dhall/tests/import/success/unit/asLocation/some/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/Chain2B.dhall b/dhall/tests/import/success/unit/asLocation/Chain2B.dhall index 20df611..6aba54e 100644 --- a/dhall/tests/import/success/unit/asLocation/Chain2B.dhall +++ b/dhall/tests/import/success/unit/asLocation/Chain2B.dhall @@ -1,2 +1,2 @@ < Environment : Text | Local : Text | Missing | Remote : Text >.Local - "./tests/import/success/bar/import.dhall" + "./dhall/tests/import/success/bar/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/Chain3B.dhall b/dhall/tests/import/success/unit/asLocation/Chain3B.dhall index 20df611..6aba54e 100644 --- a/dhall/tests/import/success/unit/asLocation/Chain3B.dhall +++ b/dhall/tests/import/success/unit/asLocation/Chain3B.dhall @@ -1,2 +1,2 @@ < Environment : Text | Local : Text | Missing | Remote : Text >.Local - "./tests/import/success/bar/import.dhall" + "./dhall/tests/import/success/bar/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/HashB.dhall b/dhall/tests/import/success/unit/asLocation/HashB.dhall index 3055c8e..6aee0b5 100644 --- a/dhall/tests/import/success/unit/asLocation/HashB.dhall +++ b/dhall/tests/import/success/unit/asLocation/HashB.dhall @@ -1,2 +1,2 @@ < Environment : Text | Local : Text | Missing | Remote : Text >.Local - "./tests/import/success/unit/asLocation/some/import.dhall" + "./dhall/tests/import/success/unit/asLocation/some/import.dhall" diff --git a/dhall/tests/import/success/unit/asLocation/RelativeB.dhall b/dhall/tests/import/success/unit/asLocation/RelativeB.dhall index 1ef12f2..b3bd255 100644 --- a/dhall/tests/import/success/unit/asLocation/RelativeB.dhall +++ b/dhall/tests/import/success/unit/asLocation/RelativeB.dhall @@ -1,2 +1,2 @@ < Environment : Text | Remote : Text | Local : Text | Missing >.Local - "./tests/import/success/unit/asLocation/some/import.dhall" + "./dhall/tests/import/success/unit/asLocation/some/import.dhall" diff --git a/update-tests.sh b/update-tests.sh index d58b4c5..91ac2ed 100755 --- a/update-tests.sh +++ b/update-tests.sh @@ -12,7 +12,7 @@ Usage: update-tests.sh [missing | add] END ) -cd "$(dirname "$0")/dhall" || exit 1 +cd "$(dirname "$0")" || exit 1 if [ ! -x "$(which dhall)" ] ; then echo "Error: 'dhall' executable not found in PATH" @@ -89,7 +89,7 @@ function generate_output_file() { if [ "$1" = "missing" ]; then echo "Generating missing output files..." for folder in parser binary-decode semantic-hash import type-inference normalization alpha-normalization; do - for root in "../dhall-lang/tests" "tests"; do + for root in "dhall-lang/tests" "dhall/tests"; do # This is not robust to spaces in filenames, but hopefully there should be none fd 'A\.dhallb?$' "$root/$folder/success" \ | sed 's/A.dhallb\?$//' \ -- cgit v1.2.3