diff options
author | Nadrieril | 2019-11-11 09:57:29 +0000 |
---|---|---|
committer | Nadrieril | 2019-11-11 10:24:58 +0000 |
commit | 36070e6c285ecb96fad56470261c66b082685e56 (patch) | |
tree | 6d16bcc4b4761f01590db2c66716c6a44392491a /dhall/src | |
parent | 5f29aa9a57192b49d30f7b9066b0b1f48d124e76 (diff) |
Generate import tests automatically
Diffstat (limited to 'dhall/src')
-rw-r--r-- | dhall/src/lib.rs | 1 | ||||
-rw-r--r-- | dhall/src/phase/resolve.rs | 47 | ||||
-rw-r--r-- | dhall/src/tests.rs | 31 |
3 files changed, 15 insertions, 64 deletions
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 0a430e4..9656612 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -11,7 +11,6 @@ clippy::ptr_arg )] -#[macro_use] mod tests; pub mod core; diff --git a/dhall/src/phase/resolve.rs b/dhall/src/phase/resolve.rs index c5f2ac8..c302bfa 100644 --- a/dhall/src/phase/resolve.rs +++ b/dhall/src/phase/resolve.rs @@ -178,50 +178,3 @@ impl<SE: Copy> Canonicalize for ImportLocation<SE> { } } } - -#[cfg(test)] -#[rustfmt::skip] -mod spec_tests { - macro_rules! import_success { - ($name:ident, $path:expr) => { - make_spec_test!( - ImportSuccess( - &("../dhall-lang/tests/import/success/".to_owned() + $path + "A.dhall"), - &("../dhall-lang/tests/import/success/".to_owned() + $path + "B.dhall") - ), - $name - ); - }; - } - - // macro_rules! import_failure { - // ($name:ident, $path:expr) => { - // make_spec_test!( - // ImportFailure(&("../dhall-lang/tests/import/failure/".to_owned() + $path + ".dhall")), - // $name - // ); - // }; - // } - - // import_success!(success_alternativeEnvNatural, "alternativeEnvNatural"); - // import_success!(success_alternativeEnvSimple, "alternativeEnvSimple"); - // import_success!(success_alternativeHashMismatch, "alternativeHashMismatch"); - import_success!(success_alternativeNatural, "alternativeNatural"); - import_success!(success_alternativeParseError, "alternativeParseError"); - import_success!(success_alternativeTypeError, "alternativeTypeError"); - // import_success!(success_asLocation, "asLocation"); - // import_success!(success_asText, "asText"); - // import_success!(success_customHeaders, "customHeaders"); - import_success!(success_fieldOrder, "fieldOrder"); - // note: this one needs special setup with env variables - // import_success!(success_hashFromCache, "hashFromCache"); - // import_success!(success_headerForwarding, "headerForwarding"); - // import_success!(success_nestedHash, "nestedHash"); - // import_success!(success_noHeaderForwarding, "noHeaderForwarding"); - // import_failure!(failure_alternativeEnv, "alternativeEnv"); - // import_failure!(failure_alternativeEnvMissing, "alternativeEnvMissing"); - // import_failure!(failure_cycle, "cycle"); - // import_failure!(failure_hashMismatch, "hashMismatch"); - // import_failure!(failure_missing, "missing"); - // import_failure!(failure_referentiallyInsane, "referentiallyInsane"); -} diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 80994d1..b98489f 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -20,22 +20,6 @@ right: `{}`"#, }}; } -#[macro_export] -macro_rules! make_spec_test { - ($type:expr, $name:ident) => { - #[test] - #[allow(non_snake_case)] - fn $name() { - use crate::tests::Test::*; - use crate::tests::*; - match run_test_stringy_error($type) { - Ok(_) => {} - Err(s) => panic!(s), - } - } - }; -} - use std::fs::File; use std::io::Read; use std::path::PathBuf; @@ -200,6 +184,21 @@ pub fn run_test(test: Test<'_>) -> Result<()> { #[cfg(test)] mod spec { + macro_rules! make_spec_test { + ($type:expr, $name:ident) => { + #[test] + #[allow(non_snake_case)] + fn $name() { + use crate::tests::Test::*; + use crate::tests::*; + match run_test_stringy_error($type) { + Ok(_) => {} + Err(s) => panic!(s), + } + } + }; + } + // See build.rs include!(concat!(env!("OUT_DIR"), "/spec_tests.rs")); } |