summaryrefslogtreecommitdiff
path: root/dhall/tests
diff options
context:
space:
mode:
authorNadrieril2020-06-24 22:19:08 +0100
committerNadrieril2020-06-25 12:34:40 +0100
commitd064efd894d034726f1d67494fa98fc975708106 (patch)
tree6973b86eb2ca6c8eb3474b0e6d603774510c07b4 /dhall/tests
parent42a9e687e3ecd157779236e893d5564a119dce31 (diff)
ci: run tests on windows
Diffstat (limited to '')
-rw-r--r--dhall/tests/spec.rs33
1 files changed, 26 insertions, 7 deletions
diff --git a/dhall/tests/spec.rs b/dhall/tests/spec.rs
index 8670013..a423435 100644
--- a/dhall/tests/spec.rs
+++ b/dhall/tests/spec.rs
@@ -238,7 +238,10 @@ impl TestFile {
}
let expected = read_to_string(self.path())?;
+ let expected = expected.replace("\r\n", "\n"); // Normalize line endings
let msg = format!("{}\n", x);
+ // TODO: git changes newlines on windows
+ let msg = msg.replace("\r\n", "\n");
if msg != expected {
if Self::force_update() {
self.write_ui(x)?;
@@ -306,7 +309,7 @@ fn dhall_files_in_dir<'a>(
dir: &'a Path,
take_ab_suffix: bool,
filetype: FileType,
-) -> impl Iterator<Item = (String, String)> + 'a {
+) -> impl Iterator<Item = String> + 'a {
WalkDir::new(dir)
.into_iter()
.filter_map(|e| e.ok())
@@ -325,9 +328,7 @@ fn dhall_files_in_dir<'a>(
} else {
path.to_owned()
};
- // Transform path into a valid Rust identifier
- let name = path.replace("/", "_").replace("-", "_");
- Some((name, path))
+ Some(path)
})
}
@@ -341,13 +342,16 @@ fn discover_tests_for_feature(feature: TestFeature) -> Vec<Test<SpecTest>> {
for base_path in TEST_PATHS {
let base_path = Path::new(base_path);
let tests_dir = base_path.join(feature.directory);
- for (name, path) in
+ for path in
dhall_files_in_dir(&tests_dir, take_ab_suffix, feature.input_type)
{
- if (feature.exclude_path)(&path) {
+ let normalized_path = path.replace("\\", "/");
+ if (feature.exclude_path)(&normalized_path) {
continue;
}
- if (feature.too_slow_path)(&path) && cfg!(debug_assertions) {
+ if (feature.too_slow_path)(&normalized_path)
+ && cfg!(debug_assertions)
+ {
continue;
}
let path = tests_dir.join(path);
@@ -366,6 +370,8 @@ fn discover_tests_for_feature(feature: TestFeature) -> Vec<Test<SpecTest>> {
_ => path.as_ref().to_owned(),
};
+ // Transform path into a valid Rust identifier
+ let name = normalized_path.replace("/", "_").replace("-", "_");
let input = feature
.input_type
.construct(&format!("{}{}", path, input_suffix));
@@ -420,6 +426,10 @@ fn define_features() -> Vec<TestFeature> {
directory: "parser/failure/",
variant: SpecTestKind::ParserFailure,
output_type: FileType::UI,
+ exclude_path: Rc::new(|_path: &str| {
+ // TODO: git changes newlines on windows
+ cfg!(windows)
+ }),
..default_feature.clone()
},
TestFeature {
@@ -481,6 +491,11 @@ fn define_features() -> Vec<TestFeature> {
|| path == "customHeaders"
|| path == "headerForwarding"
|| path == "noHeaderForwarding"
+ // TODO: git changes newlines on windows
+ || (cfg!(windows) && path == "unit/AsText")
+ // TODO: paths on windows have backslashes; this breaks all the `as Location` tests
+ // See https://github.com/dhall-lang/dhall-lang/issues/1032
+ || (cfg!(windows) && path.contains("asLocation"))
}),
..default_feature.clone()
},
@@ -490,6 +505,8 @@ fn define_features() -> Vec<TestFeature> {
variant: SpecTestKind::ImportFailure,
exclude_path: Rc::new(|path: &str| {
false
+ // TODO: paths on windows have backslashes; this breaks many things
+ || cfg!(windows)
// TODO: import headers
|| path == "customHeadersUsingBoundVariable"
}),
@@ -553,6 +570,8 @@ fn define_features() -> Vec<TestFeature> {
false
// TODO: enable free variable checking
|| path == "unit/MergeHandlerFreeVar"
+ // TODO: git changes newlines on windows
+ || cfg!(windows)
}),
output_type: FileType::UI,
..default_feature