Skip to content

Commit 02a04d0

Browse files
committed
test_conflicts and test_resolve_command: use indoc! to indent conflict markers in tests
Apart from (IMO) looking nicer, this will also sidestep the potential problem that if the file contains actual jj conflict markers (`>>>>>>>` in the beginning of a line, for example), jj would currently have trouble materializing and subsequently parsing conflicts in the file if it actually became conflicted. I'll demo this bug in either this or a subsequent PR. It's the kind of bug that sounds serious in theory but might never cause a problem in practice. After this PR, only `docs/tutorial.md` has a conflict marker that's not indented. There's only one there, so hopefully it won't be too much of a pain to deal with. I also indented other strings in `test_conflicts.rs`. IMO, this looks nice and more consistent with the `insta::assert_snapshot` output. I didn't spend the time to do the same for `test_resolve_command`.
1 parent d8c8494 commit 02a04d0

File tree

6 files changed

+187
-159
lines changed

6 files changed

+187
-159
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ glob = "0.3.1"
5656
hex = "0.4.3"
5757
ignore = "0.4.20"
5858
indexmap = "2.2.5"
59+
indoc = "2.0.4"
5960
insta = { version = "1.35.1", features = ["filters"] }
6061
itertools = "0.12.1"
6162
libc = { version = "0.2.153" }

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ anyhow = { workspace = true }
8282
assert_cmd = { workspace = true }
8383
assert_matches = { workspace = true }
8484
async-trait = { workspace = true }
85+
indoc = { workspace = true }
8586
insta = { workspace = true }
8687
test-case = { workspace = true }
8788
testutils = { workspace = true }

cli/tests/test_resolve_command.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
use std::path::Path;
1616

17+
use indoc::indoc;
18+
1719
use crate::common::TestEnvironment;
1820

1921
fn create_commit(
@@ -195,15 +197,16 @@ fn test_resolution() {
195197
&editor_script,
196198
[
197199
"dump editor2",
198-
"write
199-
<<<<<<<
200-
%%%%%%%
201-
-some
202-
+fake
203-
+++++++
204-
conflict
205-
>>>>>>>
206-
",
200+
indoc! {"
201+
write
202+
<<<<<<<
203+
%%%%%%%
204+
-some
205+
+fake
206+
+++++++
207+
conflict
208+
>>>>>>>
209+
"},
207210
]
208211
.join("\0"),
209212
)
@@ -270,15 +273,16 @@ conflict
270273
&editor_script,
271274
[
272275
"dump editor3",
273-
"write
274-
<<<<<<<
275-
%%%%%%%
276-
-some
277-
+fake
278-
+++++++
279-
conflict
280-
>>>>>>>
281-
",
276+
indoc! {"
277+
write
278+
<<<<<<<
279+
%%%%%%%
280+
-some
281+
+fake
282+
+++++++
283+
conflict
284+
>>>>>>>
285+
"},
282286
]
283287
.join("\0"),
284288
)

lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ winreg = { workspace = true }
7272
assert_matches = { workspace = true }
7373
criterion = { workspace = true }
7474
esl01-renderdag = { workspace = true }
75+
indoc = { workspace = true }
7576
insta = { workspace = true }
7677
num_cpus = { workspace = true }
7778
pretty_assertions = { workspace = true }

0 commit comments

Comments
 (0)