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 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'dhall/src/tests.rs') 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(()) } -- cgit v1.2.3 From 24ff14dc98b83ddc12239a0eae4852c9cd87d41f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 1 Mar 2020 16:37:10 +0000 Subject: Add a lot of import tests --- dhall/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dhall/src/tests.rs') diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 3649f8d..044b185 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -243,7 +243,7 @@ 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. + // Setup current directory to the root of the repository. Important for `as Location` tests. env::set_current_dir( PathBuf::from(env!("CARGO_MANIFEST_DIR")).parent().unwrap(), )?; -- cgit v1.2.3 From 386f34af802a812c2af8ece2cc427cfb5a7c1fe8 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 1 Mar 2020 17:26:59 +0000 Subject: Implement `missing` and `env:VAR` imports --- dhall/src/tests.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'dhall/src/tests.rs') diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 044b185..369c6cc 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -247,6 +247,8 @@ fn run_test(test: Test) -> Result<()> { env::set_current_dir( PathBuf::from(env!("CARGO_MANIFEST_DIR")).parent().unwrap(), )?; + // Set environment variable for import tests. + env::set_var("DHALL_TEST_VAR", "6 * 7"); match test { ParserSuccess(expr, expected) => { -- cgit v1.2.3