diff options
Diffstat (limited to 'dhall')
-rw-r--r-- | dhall/Cargo.toml | 4 | ||||
-rw-r--r-- | dhall/build.rs | 36 | ||||
-rw-r--r-- | dhall/tests/normalization.rs | 8 |
3 files changed, 25 insertions, 23 deletions
diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml index 234daa4..e898cde 100644 --- a/dhall/Cargo.toml +++ b/dhall/Cargo.toml @@ -22,3 +22,7 @@ dhall_generator = { path = "../dhall_generator" } [dev-dependencies] pretty_assertions = "0.6.1" + +[build-dependencies] +walkdir = "2" + diff --git a/dhall/build.rs b/dhall/build.rs index c8ad6ad..cc62a97 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -1,23 +1,28 @@ use std::env; use std::ffi::OsString; -use std::fs::{self, File}; +use std::fs::File; use std::io::Write; use std::path::Path; +use walkdir::WalkDir; fn dhall_files_in_dir<'a>(dir: &'a Path) -> impl Iterator<Item = String> + 'a { - fs::read_dir(dir).unwrap().filter_map(move |path| { - let path = path.unwrap().path(); - let path = path.strip_prefix(dir).unwrap(); - if path.extension() != Some(&OsString::from("dhall")) { - return None; - } - let path = path.to_string_lossy(); - let path = path[..path.len() - 6].to_owned(); - Some(path) - }) + WalkDir::new(dir) + .into_iter() + .filter_map(|e| e.ok()) + .filter_map(move |path| { + let path = path.path(); + let path = path.strip_prefix(dir).unwrap(); + if path.extension() != Some(&OsString::from("dhall")) { + return None; + } + let path = path.to_string_lossy(); + let path = path[..path.len() - 6].to_owned(); + Some(path) + }) } fn main() -> std::io::Result<()> { + println!("cargo:rerun-if-changed=../dhall-lang/.git"); let out_dir = env::var("OUT_DIR").unwrap(); let tests_dir = Path::new("../dhall-lang/tests/"); @@ -25,17 +30,18 @@ fn main() -> std::io::Result<()> { let mut file = File::create(parser_tests_path)?; for path in dhall_files_in_dir(&tests_dir.join("parser/success/")) { - let name = &path[..path.len() - 1]; + let path = &path[..path.len() - 1]; + let name = path.replace("/", "_"); // Skip this test; parser is way too slow indebug mode if name == "largeExpression" { continue; } - writeln!(file, r#"make_spec_test!(ParserSuccess, spec_parser_success_{0}, "{0}");"#, name)?; + writeln!(file, r#"make_spec_test!(ParserSuccess, spec_parser_success_{}, "{}");"#, name, path)?; } for path in dhall_files_in_dir(&tests_dir.join("parser/failure/")) { - let name = &path; - writeln!(file, r#"make_spec_test!(ParserFailure, spec_parser_failure_{0}, "{0}");"#, name)?; + let name = path.replace("/", "_"); + writeln!(file, r#"make_spec_test!(ParserFailure, spec_parser_failure_{}, "{}");"#, name, path)?; } Ok(()) diff --git a/dhall/tests/normalization.rs b/dhall/tests/normalization.rs index 5df46a6..d2db38d 100644 --- a/dhall/tests/normalization.rs +++ b/dhall/tests/normalization.rs @@ -14,14 +14,6 @@ norm!(spec_normalization_success_haskell_tutorial_access_0, "haskell-tutorial/ac // norm!(spec_normalization_success_haskell_tutorial_combineTypes_1, "haskell-tutorial/combineTypes/1"); // norm!(spec_normalization_success_haskell_tutorial_prefer_0, "haskell-tutorial/prefer/0"); norm!(spec_normalization_success_haskell_tutorial_projection_0, "haskell-tutorial/projection/0"); -// norm!(spec_normalization_success_multiline_escape, "multiline/escape"); -// norm!(spec_normalization_success_multiline_hangingIndent, "multiline/hangingIndent"); -// norm!(spec_normalization_success_multiline_interesting, "multiline/interesting"); -// norm!(spec_normalization_success_multiline_interiorIndent, "multiline/interiorIndent"); -// norm!(spec_normalization_success_multiline_interpolation, "multiline/interpolation"); -// norm!(spec_normalization_success_multiline_preserveComment, "multiline/preserveComment"); -// norm!(spec_normalization_success_multiline_singleLine, "multiline/singleLine"); -// norm!(spec_normalization_success_multiline_twoLines, "multiline/twoLines"); norm!(spec_normalization_success_prelude_Bool_and_0, "prelude/Bool/and/0"); |