Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: path construction errors on Windows #19

Merged
merged 6 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ on:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -28,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -47,7 +52,7 @@ jobs:
runs-on: windows-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -65,7 +70,7 @@ jobs:
runs-on: macos-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand Down
2 changes: 1 addition & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub fn get_changed_files(git_root: &AbsPath, relative_to: Option<&str>) -> Resul
.difference(&deleted_working_tree_files)
// Git reports files relative to the root of git root directory, so retrieve
// that and prepend it to the file paths.
.map(|f| format!("{}/{}", git_root.display(), f))
.map(|f| format!("{}", git_root.join(f).display()))
.map(|f| {
AbsPath::try_from(&f).with_context(|| {
format!("Failed to find file while gathering files to lint: {}", f)
Expand Down
2 changes: 1 addition & 1 deletion src/persistent_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl RunInfo {
// this run.
fn dir_name(&self) -> String {
let args = blake3::hash(self.args.join("_").as_bytes()).to_string();
self.timestamp.clone() + "_" + &args
self.timestamp.clone().replace(":", "-") + "_" + &args
}
}

Expand Down
10 changes: 10 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fn temp_config_returning_msg(lint_message: LintMessage) -> Result<tempfile::Name
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // STDERR string is different
fn unknown_config_fails() -> Result<()> {
let mut cmd = Command::cargo_bin("lintrunner")?;
cmd.arg("--config=asdfasdfasdf");
Expand Down Expand Up @@ -124,6 +125,7 @@ fn empty_command_fails() -> Result<()> {
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // STDERR string is different
fn simple_linter() -> Result<()> {
let data_path = tempfile::tempdir()?;
let lint_message = LintMessage {
Expand Down Expand Up @@ -154,6 +156,7 @@ fn simple_linter() -> Result<()> {
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // path is rendered differently
fn simple_linter_oneline() -> Result<()> {
let data_path = tempfile::tempdir()?;
let lint_message = LintMessage {
Expand Down Expand Up @@ -185,6 +188,7 @@ fn simple_linter_oneline() -> Result<()> {
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // STDERR string is different
fn simple_linter_fails_on_nonexistent_file() -> Result<()> {
let config = temp_config(
"\
Expand Down Expand Up @@ -229,6 +233,7 @@ fn duplicate_code_fails() -> Result<()> {
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // STDOUT string is different
fn linter_providing_nonexistent_path_degrades_gracefully() -> Result<()> {
let data_path = tempfile::tempdir()?;
let lint_message = LintMessage {
Expand Down Expand Up @@ -263,6 +268,7 @@ fn linter_providing_nonexistent_path_degrades_gracefully() -> Result<()> {
}
justinchuby marked this conversation as resolved.
Show resolved Hide resolved

#[test]
#[cfg_attr(target_os = "windows", ignore)] // STDERR string is different
fn linter_hard_failure_is_caught() -> Result<()> {
let data_path = tempfile::tempdir()?;
let config = temp_config(
Expand Down Expand Up @@ -315,6 +321,7 @@ fn linter_nonexistent_command() -> Result<()> {
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // path is rendered differently
fn simple_linter_replacement_message() -> Result<()> {
let data_path = tempfile::tempdir()?;
let lint_message = LintMessage {
Expand Down Expand Up @@ -419,6 +426,7 @@ fn skip_nonexistent_linter() -> Result<()> {
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // Usage string is different
fn invalid_paths_cmd_and_from() -> Result<()> {
let config = temp_config(
"\
Expand All @@ -439,6 +447,7 @@ fn invalid_paths_cmd_and_from() -> Result<()> {
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // Usage string is different
fn invalid_paths_cmd_and_specified_paths() -> Result<()> {
let config = temp_config(
"\
Expand Down Expand Up @@ -705,6 +714,7 @@ fn tee_json() -> Result<()> {
}

#[test]
#[cfg_attr(target_os = "windows", ignore)] // STDOUT string is different
fn linter_replacement_trailing_newlines() -> Result<()> {
let data_path = tempfile::tempdir()?;
let lint_message = LintMessage {
Expand Down