Skip to content

Commit

Permalink
Hack at expected path strings to compare equal on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhy committed Sep 27, 2023
1 parent 6d5eb6d commit 2526a33
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/nu-command/tests/commands/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ pub fn create_file_at(full_path: impl AsRef<Path>) -> Result<(), std::io::Error>
}

Check warning on line 133 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, default)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

Check warning on line 133 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, dataframe)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

Check warning on line 133 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, extra)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

// playground has root directory and subdirectories foo and foo/bar to play with
// specify all test files relative to root directory.
// specify all test files relative to root directory.
// OK to use fwd slash in paths, they're hacked to OS dir separator when needed (windows)
#[rstest]
#[case(".", r#"'*z'"#, &["ablez", "baker", "charliez"], &["ablez", "charliez"], "simple glob")]
#[case(".", r#"'qqq'"#, &["ablez", "baker", "charliez"], &[], "glob matches none")]
Expand All @@ -160,19 +161,18 @@ fn glob_files_in_parent(
r#"glob {} | sort | str join " ""#,

Check warning on line 161 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, default)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

Check warning on line 161 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, dataframe)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

Check warning on line 161 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, extra)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs
glob
);

let mut expected: Vec<String> = vec![];
for e in exp {
expected.push(
dirs.test()

Check warning on line 168 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, default)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

Check warning on line 168 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, dataframe)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

Check warning on line 168 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, extra)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs
.join(PathBuf::from(e))
.canonicalize().unwrap()
.join(PathBuf::from(e)) // sadly, does *not" convert "foo/bar" to "foo\\bar" on Windows.
.to_string_lossy()
.to_string(),
.to_string()
);
}

let expected = expected.join(" ");
let expected = expected.join(" ").replace("/", std::path::MAIN_SEPARATOR_STR);

Check warning on line 175 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, default)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

Check warning on line 175 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, dataframe)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs

Check warning on line 175 in crates/nu-command/tests/commands/glob.rs

View workflow job for this annotation

GitHub Actions / fmt-clippy (ubuntu-20.04, extra)

Diff in /home/runner/work/nushell/nushell/crates/nu-command/tests/commands/glob.rs
assert_eq!(actual.out, expected, "\n test: {}", tag);
});
}

0 comments on commit 2526a33

Please sign in to comment.