Skip to content

Commit 183ccfb

Browse files
committed
refactor: tests: port multi_rewrite to a snapshot test
`git` didn't recognize this as a pure move, but it is. This test was supposed to test if changes are visible across `commit`s, even when those changes aren't written to the original file (like with the `--rewrite-mode alongside` used by [`refactor`], and unlike with `--rewrite-mode inplace`). However, `commit` is currently broken (see #1605), so this test is not actually testing what it's meant to. The places where `commit`s are supposed to go are left as comments for now until we fix `commit`.
1 parent f08ad16 commit 183ccfb

6 files changed

Lines changed: 36 additions & 17 deletions

File tree

c2rust-refactor/tests/multi_rewrite/new.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

c2rust-refactor/tests/multi_rewrite/run.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

c2rust-refactor/tests/snapshots.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,28 @@ fn test_matcher_typed() {
327327
.test();
328328
}
329329

330+
/// This test was supposed to test if changes are visible across `commit`s,
331+
/// even when those changes aren't written to the original file
332+
/// (like with the `--rewrite-mode alongside` used by [`refactor`],
333+
/// and unlike with `--rewrite-mode inplace`).
334+
/// However, `commit` is currently broken (see #1605),
335+
/// so this test is not actually testing what it's meant to.
336+
/// The places where `commit`s are supposed to go
337+
/// are left as comments for now until we fix `commit`.
338+
#[test]
339+
fn test_multi_rewrite() {
340+
refactor("rewrite_expr")
341+
.command_args(&["1", "2"])
342+
.named("multi_rewrite.rs")
343+
.test();
344+
// commit
345+
refactor("rewrite_expr")
346+
.command_args(&["2", "3"])
347+
.named("multi_rewrite.new")
348+
.test();
349+
// commit
350+
}
351+
330352
/// TODO Broken.
331353
/// This panics with the error:
332354
///
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: c2rust-refactor/tests/snapshots.rs
3+
expression: c2rust-refactor rewrite_expr 2 3 --rewrite-mode alongside -- tests/snapshots/multi_rewrite.new --edition 2021
4+
---
5+
fn main() {
6+
let x = 3;
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: c2rust-refactor/tests/snapshots.rs
3+
expression: c2rust-refactor rewrite_expr 1 2 --rewrite-mode alongside -- tests/snapshots/multi_rewrite.rs --edition 2021
4+
---
5+
fn main() {
6+
let x = 2;
7+
}

0 commit comments

Comments
 (0)