Skip to content

Commit

Permalink
snapshot: demo unreadable error message on invalid ignore
Browse files Browse the repository at this point in the history
A user on Discord ran into this error message, and they were confused
about why they were getting it. The next commit will improve the error
messages.
  • Loading branch information
scott2000 committed Dec 17, 2024
1 parent 25117d7 commit 7f1d902
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cli/tests/test_working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,27 @@ fn test_materialize_and_snapshot_different_conflict_markers() {
line 3
"##);
}

#[test]
fn test_snapshot_invalid_ignore_pattern() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
let gitignore_path = repo_path.join(".gitignore");

// Test invalid pattern in .gitignore
std::fs::write(&gitignore_path, " []\n").unwrap();
insta::assert_snapshot!(test_env.jj_cmd_internal_error(&repo_path, &["st"]), @r#"
Internal error: Failed to snapshot the working copy
Caused by: error parsing glob ' []': unclosed character class; missing ']'
"#);

// Test invalid UTF-8 in .gitignore
std::fs::write(&gitignore_path, b"\xff\n").unwrap();
insta::assert_snapshot!(test_env.jj_cmd_internal_error(&repo_path, &["st"]), @r##"
Internal error: Failed to snapshot the working copy
Caused by:
1: invalid UTF-8 for ignore pattern in on line #1: �
2: invalid utf-8 sequence of 1 bytes from index 0
"##);
}

0 comments on commit 7f1d902

Please sign in to comment.