summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/tests.yml13
-rw-r--r--dhall/tests/spec.rs33
2 files changed, 29 insertions, 17 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 5d8236c..e5b800e 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -79,11 +79,8 @@ jobs:
- name: Run tests
run: wasm-pack test serde_dhall --node
- # Tests don't work because of path escaping shenanigans. I have a branch that
- # will fix that but depends on https://github.com/LukasKalbertodt/libtest-mimic/pull/4
test_windows:
- name: Build on windows
- # name: Run tests on windows
+ name: Run tests on windows
runs-on: windows-latest
strategy:
matrix:
@@ -100,11 +97,7 @@ jobs:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- - name: Build
+ - name: Run tests
uses: actions-rs/cargo@v1
with:
- command: build
- # - name: Run tests
- # uses: actions-rs/cargo@v1
- # with:
- # command: test
+ command: test
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