Skip to content

Commit

Permalink
better test for bug jj-vcs#3223
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Jun 27, 2024
1 parent 042813f commit 92a3763
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions lib/tests/test_local_working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::path::Path;
use std::sync::Arc;

use indoc::indoc;
use insta::{assert_debug_snapshot, assert_snapshot};
use itertools::Itertools;
use jj_lib::backend::{MergedTreeId, TreeId, TreeValue};
use jj_lib::file_util::{check_symlink_support, try_symlink};
Expand Down Expand Up @@ -385,6 +386,59 @@ fn test_acl() {
assert!(became_public_path.to_fs_path(&workspace_root).is_file());
}

#[test]
fn test_conflict_empty_vs_nonempty_issue_3223() {
let settings = testutils::user_settings();
let mut test_workspace = TestWorkspace::init(&settings);
let repo = &test_workspace.repo;

let path = RepoPath::from_internal_string("file");
let empty_tree = create_tree(repo, &[]);
let tree1 = create_tree(repo, &[(path, "")]); // empty file
let tree2 = create_tree(repo, &[(path, "nonempty")]);
let merged_tree = tree1.merge(&empty_tree, &tree2).unwrap();
// The tree representation is conflicted...
assert_debug_snapshot!(tree_entries(&merged_tree), @r###"
[
(
"file",
Some(
Conflicted(
[
Some(
File {
id: FileId(
"482ae5a29fbe856c7272",
),
executable: false,
},
),
None,
Some(
File {
id: FileId(
"2f381f1aab1e326fe57d",
),
executable: false,
},
),
],
),
),
),
]
"###);
let merged_commit = commit_with_tree(repo.store(), merged_tree.id());
let repo = &test_workspace.repo;
let ws = &mut test_workspace.workspace;
ws.check_out(repo.op_id().clone(), None, &merged_commit)
.unwrap();
let file_contents = std::fs::read_to_string(path.to_fs_path(ws.workspace_root())).unwrap();
// BUG: The file on disk does *not* have conflict markers. So, it's
// impossible to resolve the conflict.
assert_snapshot!(file_contents, @"nonempty");
}

#[test]
fn test_tree_builder_file_directory_transition() {
let settings = testutils::user_settings();
Expand Down

0 comments on commit 92a3763

Please sign in to comment.