Skip to content

Commit 07fa433

Browse files
authored
Fixed input_file on windows (#386)
1 parent e65d78e commit 07fa433

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@v3
2424
- uses: dtolnay/rust-toolchain@master
2525
with:
26-
toolchain: 1.56.1
26+
toolchain: 1.60.0
2727
- name: Test
2828
run: make cargotest
2929

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to insta and cargo-insta are documented here.
44

55
## 1.30.0
66

7+
- Resolved a bug on Windows that caused `input_file` not to be written into the
8+
snapshots. (#386)
79
- Snapshots are accepted when running with `--accept` even if a test outside
810
insta fails. (#358)
911
- Mark settings drop guard as `#[must_use]`.

src/runtime.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,9 @@ impl<'a> SnapshotAssertionContext<'a> {
310310

311311
/// Given a path returns the local path within the workspace.
312312
pub fn localize_path(&self, p: &Path) -> Option<PathBuf> {
313-
self.cargo_workspace
314-
.join(p)
315-
.canonicalize()
316-
.ok()
317-
.and_then(|s| {
318-
self.cargo_workspace
319-
.canonicalize()
320-
.ok()
321-
.and_then(|cw| s.strip_prefix(cw).ok().map(|x| x.to_path_buf()))
322-
})
313+
let workspace = self.cargo_workspace.canonicalize().ok()?;
314+
let p = self.cargo_workspace.join(p).canonicalize().ok()?;
315+
p.strip_prefix(&workspace).ok().map(|x| x.to_path_buf())
323316
}
324317

325318
/// Creates the new snapshot from input values.

0 commit comments

Comments
 (0)