Skip to content

Commit

Permalink
test_conflicts and test_resolve_command: use indoc! to indent confl…
Browse files Browse the repository at this point in the history
…ict 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`.
  • Loading branch information
ilyagr committed Mar 23, 2024
1 parent 4fbe6ae commit 24650a6
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 159 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ glob = "0.3.1"
hex = "0.4.3"
ignore = "0.4.20"
indexmap = "2.2.5"
indoc = "2.0.4"
insta = { version = "1.35.1", features = ["filters"] }
itertools = "0.12.1"
libc = { version = "0.2.153" }
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ anyhow = { workspace = true }
assert_cmd = { workspace = true }
assert_matches = { workspace = true }
async-trait = { workspace = true }
indoc = { workspace = true }
insta = { workspace = true }
test-case = { workspace = true }
testutils = { workspace = true }
Expand Down
40 changes: 22 additions & 18 deletions cli/tests/test_resolve_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

use std::path::Path;

use indoc::indoc;

use crate::common::TestEnvironment;

fn create_commit(
Expand Down Expand Up @@ -195,15 +197,16 @@ fn test_resolution() {
&editor_script,
[
"dump editor2",
"write
<<<<<<<
%%%%%%%
-some
+fake
+++++++
conflict
>>>>>>>
",
indoc! {"
write
<<<<<<<
%%%%%%%
-some
+fake
+++++++
conflict
>>>>>>>
"},
]
.join("\0"),
)
Expand Down Expand Up @@ -270,15 +273,16 @@ conflict
&editor_script,
[
"dump editor3",
"write
<<<<<<<
%%%%%%%
-some
+fake
+++++++
conflict
>>>>>>>
",
indoc! {"
write
<<<<<<<
%%%%%%%
-some
+fake
+++++++
conflict
>>>>>>>
"},
]
.join("\0"),
)
Expand Down
1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ winreg = { workspace = true }
assert_matches = { workspace = true }
criterion = { workspace = true }
esl01-renderdag = { workspace = true }
indoc = { workspace = true }
insta = { workspace = true }
num_cpus = { workspace = true }
pretty_assertions = { workspace = true }
Expand Down
Loading

0 comments on commit 24650a6

Please sign in to comment.