Skip to content

Commit 032bea6

Browse files
authored
fix: path construction errors on Windows (#19)
* Run CI on windows and macos * Fix git file discovery * Fix RunInfo dir_name for Windows * Ignore tests * fix windows * simple_linter
1 parent 1c991af commit 032bea6

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

.github/workflows/CI.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ on:
1010

1111
jobs:
1212
test:
13-
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
18+
runs-on: ${{ matrix.os }}
1419
steps:
15-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
1621
- uses: actions-rs/toolchain@v1
1722
with:
1823
toolchain: stable
@@ -28,7 +33,7 @@ jobs:
2833
runs-on: ubuntu-latest
2934
needs: test
3035
steps:
31-
- uses: actions/checkout@v2
36+
- uses: actions/checkout@v3
3237
- uses: actions-rs/toolchain@v1
3338
with:
3439
toolchain: stable
@@ -47,7 +52,7 @@ jobs:
4752
runs-on: windows-latest
4853
needs: test
4954
steps:
50-
- uses: actions/checkout@v2
55+
- uses: actions/checkout@v3
5156
- uses: actions-rs/toolchain@v1
5257
with:
5358
toolchain: stable
@@ -65,7 +70,7 @@ jobs:
6570
runs-on: macos-latest
6671
needs: test
6772
steps:
68-
- uses: actions/checkout@v2
73+
- uses: actions/checkout@v3
6974
- uses: actions-rs/toolchain@v1
7075
with:
7176
toolchain: stable

src/git.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub fn get_changed_files(git_root: &AbsPath, relative_to: Option<&str>) -> Resul
138138
.difference(&deleted_working_tree_files)
139139
// Git reports files relative to the root of git root directory, so retrieve
140140
// that and prepend it to the file paths.
141-
.map(|f| format!("{}/{}", git_root.display(), f))
141+
.map(|f| format!("{}", git_root.join(f).display()))
142142
.map(|f| {
143143
AbsPath::try_from(&f).with_context(|| {
144144
format!("Failed to find file while gathering files to lint: {}", f)

src/persistent_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl RunInfo {
4747
// this run.
4848
fn dir_name(&self) -> String {
4949
let args = blake3::hash(self.args.join("_").as_bytes()).to_string();
50-
self.timestamp.clone() + "_" + &args
50+
self.timestamp.clone().replace(":", "-") + "_" + &args
5151
}
5252
}
5353

tests/integration_test.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fn temp_config_returning_msg(lint_message: LintMessage) -> Result<tempfile::Name
5959
}
6060

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

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

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

187190
#[test]
191+
#[cfg_attr(target_os = "windows", ignore)] // STDERR string is different
188192
fn simple_linter_fails_on_nonexistent_file() -> Result<()> {
189193
let config = temp_config(
190194
"\
@@ -229,6 +233,7 @@ fn duplicate_code_fails() -> Result<()> {
229233
}
230234

231235
#[test]
236+
#[cfg_attr(target_os = "windows", ignore)] // STDOUT string is different
232237
fn linter_providing_nonexistent_path_degrades_gracefully() -> Result<()> {
233238
let data_path = tempfile::tempdir()?;
234239
let lint_message = LintMessage {
@@ -263,6 +268,7 @@ fn linter_providing_nonexistent_path_degrades_gracefully() -> Result<()> {
263268
}
264269

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

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

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

441449
#[test]
450+
#[cfg_attr(target_os = "windows", ignore)] // Usage string is different
442451
fn invalid_paths_cmd_and_specified_paths() -> Result<()> {
443452
let config = temp_config(
444453
"\
@@ -705,6 +714,7 @@ fn tee_json() -> Result<()> {
705714
}
706715

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

0 commit comments

Comments
 (0)