Skip to content

Commit 55afd62

Browse files
committed
transpile: save separate .{platform}.rs files for platform-specific snapshots
1 parent 653fe59 commit 55afd62

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

c2rust-transpile/tests/snapshots.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,18 @@ fn transpile(platform: Option<&str>, c_path: &Path) {
6161
let c_path = c_path.strip_prefix(&cwd).unwrap();
6262
let rs_path = c_path.with_extension("rs");
6363
let rs = fs::read_to_string(&rs_path).unwrap();
64+
let rs_path = match platform {
65+
None => rs_path,
66+
Some(platform) => {
67+
let platform_rs_path = rs_path.with_extension(&format!("{platform}.rs"));
68+
fs::rename(&rs_path, &platform_rs_path).unwrap();
69+
platform_rs_path
70+
}
71+
};
6472
let debug_expr = format!("cat {}", rs_path.display());
6573

6674
let name = platform
67-
.map(|platform| ["transpile", platform].join("-"))
75+
.map(|platform| format!("transpile-{platform}"))
6876
.unwrap_or("transpile".into());
6977

7078
insta::assert_snapshot!(name, &rs, &debug_expr);

0 commit comments

Comments
 (0)