Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/anchors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,11 @@ mod tests {

#[test]
fn a_file_with_no_marker_parses_to_nothing() {
assert!(parse("ordinary prose about anchors and facts\n").is_empty());
assert!(
parse("ordinary prose about anchors and facts\n").is_empty(),
"{:?}",
parse("ordinary prose about anchors and facts\n")
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ mod tests {
/// came to have an unreachable clean arm.
#[test]
fn the_standing_caveats_are_not_surfaces_this_run_failed_to_read() {
assert!(!STANDING_CAVEATS.is_empty());
assert!(!STANDING_CAVEATS.is_empty(), "STANDING_CAVEATS is empty");
for caveat in STANDING_CAVEATS {
assert!(
caveat.contains("cannot"),
Expand Down
20 changes: 16 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3742,10 +3742,22 @@ mod tests {
// changes what a guard does in every repository that never wrote the
// field, which is most of them.
let rule = Rule::synthetic("x", Check::empty(CheckKind::Builtin));
assert!(rule.public_repos().is_empty());
assert!(rule.allowed_owners().is_empty());
assert!(rule.allowed_repos().is_empty());
assert!(rule.private_owners().is_empty());
assert!(rule.public_repos().is_empty(), "{:?}", rule.public_repos());
assert!(
rule.allowed_owners().is_empty(),
"{:?}",
rule.allowed_owners()
);
assert!(
rule.allowed_repos().is_empty(),
"{:?}",
rule.allowed_repos()
);
assert!(
rule.private_owners().is_empty(),
"{:?}",
rule.private_owners()
);
assert!(
!rule.refuse_unknown(),
"an unknown name is not private by default"
Expand Down
20 changes: 16 additions & 4 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ mod tests {
assert!(
search_text("literally $HOME/secrets here\n", &plain, "t")
.unwrap()
.is_empty()
.is_empty(),
"{:?}",
search_text("literally $HOME/secrets here\n", &plain, "t").unwrap()
);
}

Expand All @@ -247,14 +249,22 @@ mod tests {
..Default::default()
};
let query = Query::from_files("LICENSE", &files);
assert!(search_text("LICENSEE\n", &query, "t").unwrap().is_empty());
assert!(
search_text("LICENSEE\n", &query, "t").unwrap().is_empty(),
"{:?}",
search_text("LICENSEE\n", &query, "t").unwrap()
);
assert_eq!(search_text("LICENSE\n", &query, "t").unwrap().len(), 1);
}

#[test]
fn word_matching_keeps_a_short_needle_out_of_a_longer_word() {
let query = Query::literal("arc", true);
assert!(search_text("search\n", &query, "t").unwrap().is_empty());
assert!(
search_text("search\n", &query, "t").unwrap().is_empty(),
"{:?}",
search_text("search\n", &query, "t").unwrap()
);
assert_eq!(search_text("arc\n", &query, "t").unwrap().len(), 1);
}

Expand All @@ -280,7 +290,9 @@ mod tests {
assert!(
search_text(text, &Query::regex(pattern, false), "t")
.unwrap()
.is_empty()
.is_empty(),
"{:?}",
search_text(text, &Query::regex(pattern, false), "t").unwrap()
);
}

Expand Down
22 changes: 15 additions & 7 deletions src/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ mod tests {
},
);
let collected = body(&[&unread]);
assert!(collected.found.is_empty());
assert!(collected.read.is_empty());
assert!(collected.found.is_empty(), "{:?}", collected.found);
assert!(collected.read.is_empty(), "{:?}", collected.read);
assert_eq!(collected.unavailable.len(), 1);
assert_eq!(collected.unavailable[0].reason, "a.rs:3 did not parse");
assert_eq!(
Expand Down Expand Up @@ -503,7 +503,11 @@ mod tests {
unavailable: Vec::new(),
read: vec![PARSER, PATTERN],
};
assert!(collected.contradictions().is_empty());
assert!(
collected.contradictions().is_empty(),
"{:?}",
collected.contradictions()
);
}

#[test]
Expand Down Expand Up @@ -565,7 +569,7 @@ mod tests {
]);
let removed = collected.established(Kind::FunctionRemoved);
assert!(!removed.clean());
assert!(removed.found().is_empty());
assert!(removed.found().is_empty(), "{:?}", removed.found());
assert_eq!(removed.unread().len(), 1);
assert!(matches!(removed, Established::HeuristicOnly { .. }));
}
Expand Down Expand Up @@ -595,7 +599,7 @@ mod tests {
let collected = body(&[&Scripted(PATTERN, Observation::Found(Vec::new()))]);
let removed = collected.established(Kind::FunctionRemoved);
assert!(removed.clean());
assert!(removed.unread().is_empty());
assert!(removed.unread().is_empty(), "{:?}", removed.unread());
}

#[test]
Expand All @@ -609,7 +613,7 @@ mod tests {
)]);
let removed = collected.established(Kind::FunctionRemoved);
assert_eq!(removed, Established::Unavailable(Vec::new()));
assert!(removed.found().is_empty());
assert!(removed.found().is_empty(), "{:?}", removed.found());
assert!(!removed.clean());
// Still in the body for a reader; just in no verdict.
assert_eq!(collected.found, vec![inferred]);
Expand All @@ -627,7 +631,11 @@ mod tests {
collected.established(Kind::FunctionRemoved),
Established::Proven(vec![&proven])
);
assert!(collected.contradictions().is_empty());
assert!(
collected.contradictions().is_empty(),
"{:?}",
collected.contradictions()
);

let assertion = fact(ORACLE, Kind::FunctionRemoved, "a.rs::stop");
let clean = body(&[
Expand Down
6 changes: 5 additions & 1 deletion src/evidence/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ mod tests {
// `--- a/fn_x.rs` opens with the removal marker and is not a line
// of the file; only a hunk's lines are.
let diff = "diff --git a/lib.rs b/lib.rs\n--- a/lib.rs\n+++ b/lib.rs\n";
assert!(compare("lib.rs", rust(), diff).is_empty());
assert!(
compare("lib.rs", rust(), diff).is_empty(),
"{:?}",
compare("lib.rs", rust(), diff)
);
}

#[test]
Expand Down
6 changes: 5 additions & 1 deletion src/evidence/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ mod tests {
assert_eq!(marked.len(), 2);
assert_eq!(marked[0].line, "Co-Authored-By: A <noreply@x.test>");
assert_eq!(marked[1].line, "Generated with Claude Code");
assert!(agent_markers_in("Plain\n").is_empty());
assert!(
agent_markers_in("Plain\n").is_empty(),
"{:?}",
agent_markers_in("Plain\n")
);
}

#[test]
Expand Down
4 changes: 3 additions & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,9 @@ mod tests {
assert!(
each_blob(&std::env::temp_dir(), &[], |_, _| ())
.unwrap()
.is_empty()
.is_empty(),
"{:?}",
each_blob(&std::env::temp_dir(), &[], |_, _| ()).unwrap()
);
}

Expand Down
36 changes: 30 additions & 6 deletions src/guard/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ mod tests {
fn a_fullwidth_form_needs_an_east_asian_script_beside_it() {
// `Script_Extensions=Common`, so the intersection cannot decide these
// and the range decides them instead.
assert!(findings(&format!("{JAPANESE}\u{FF08}{KANA}\u{FF09}\u{FF01}\n")).is_empty());
assert!(
findings(&format!("{JAPANESE}\u{FF08}{KANA}\u{FF09}\u{FF01}\n")).is_empty(),
"{:?}",
findings(&format!("{JAPANESE}\u{FF08}{KANA}\u{FF09}\u{FF01}\n"))
);
assert_eq!(findings("Fix the parser\u{FF01}\n").len(), 1);
assert_eq!(findings("Fix the parser\u{FF08}1\u{FF09}\n").len(), 2);
}
Expand Down Expand Up @@ -501,9 +505,21 @@ mod tests {
#[test]
fn punctuation_is_admitted_only_by_the_script_that_owns_it() {
// Greek, Arabic and Hebrew marks beside their own letters.
assert!(findings(&format!("{GREEK}\u{0384}\n")).is_empty());
assert!(findings(&format!("{ARABIC}\u{060C} {ARABIC}\n")).is_empty());
assert!(findings(&format!("{HEBREW}\u{05C3}\n")).is_empty());
assert!(
findings(&format!("{GREEK}\u{0384}\n")).is_empty(),
"{:?}",
findings(&format!("{GREEK}\u{0384}\n"))
);
assert!(
findings(&format!("{ARABIC}\u{060C} {ARABIC}\n")).is_empty(),
"{:?}",
findings(&format!("{ARABIC}\u{060C} {ARABIC}\n"))
);
assert!(
findings(&format!("{HEBREW}\u{05C3}\n")).is_empty(),
"{:?}",
findings(&format!("{HEBREW}\u{05C3}\n"))
);
// And the same marks with only Latin letters to vouch for them.
assert_eq!(findings("Fix the parser\u{0384}\n").len(), 1);
assert_eq!(findings("Fix the parser\u{060C}\n").len(), 1);
Expand All @@ -519,12 +535,20 @@ mod tests {
// are, so a Cyrillic homoglyph inside a Latin word is not what this
// guard refuses. What it refuses is the mark that arrives with no
// letters of its own script, and a Cyrillic word vouches for none.
assert!(findings("Fix the c\u{0430}che\n").is_empty());
assert!(
findings("Fix the c\u{0430}che\n").is_empty(),
"{:?}",
findings("Fix the c\u{0430}che\n")
);
assert_eq!(findings(&format!("{CYRILLIC}\u{3002}\n")).len(), 1);
}

#[test]
fn ascii_prose_and_a_tab_are_untouched() {
assert!(findings("Fix the parser\n\nIt read a\ttab.\n").is_empty());
assert!(
findings("Fix the parser\n\nIt read a\ttab.\n").is_empty(),
"{:?}",
findings("Fix the parser\n\nIt read a\ttab.\n")
);
}
}
4 changes: 3 additions & 1 deletion src/guard/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,9 @@ mod tests {
assert!(
declared_owners(&permitted_dir, &permitted, permitted_rule)
.unwrap()
.is_empty()
.is_empty(),
"{:?}",
declared_owners(&permitted_dir, &permitted, permitted_rule).unwrap()
);
}

Expand Down
50 changes: 41 additions & 9 deletions src/guard/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,20 @@ mod tests {

#[test]
fn ordinary_text_and_real_emoji_pass() {
assert!(findings("hello\tworld\n日本語 ☕\n").is_empty());
assert!(
findings("hello\tworld\n日本語 ☕\n").is_empty(),
"{:?}",
findings("hello\tworld\n日本語 ☕\n")
);
}

#[test]
fn a_variation_selector_after_an_emoji_is_earned() {
assert!(findings("\u{26A0}\u{FE0F}\n").is_empty());
assert!(
findings("\u{26A0}\u{FE0F}\n").is_empty(),
"{:?}",
findings("\u{26A0}\u{FE0F}\n")
);
}

#[test]
Expand All @@ -441,12 +449,20 @@ mod tests {

#[test]
fn a_keycap_sequence_is_the_one_ascii_exception() {
assert!(findings("1\u{FE0F}\u{20E3}\n").is_empty());
assert!(
findings("1\u{FE0F}\u{20E3}\n").is_empty(),
"{:?}",
findings("1\u{FE0F}\u{20E3}\n")
);
}

#[test]
fn an_ideographic_selector_needs_an_ideograph() {
assert!(findings("\u{845B}\u{E0100}\n").is_empty());
assert!(
findings("\u{845B}\u{E0100}\n").is_empty(),
"{:?}",
findings("\u{845B}\u{E0100}\n")
);
assert_eq!(findings("7\u{E0100}\n").len(), 1);
}

Expand All @@ -463,15 +479,23 @@ mod tests {
#[test]
fn an_allowance_may_be_scoped_to_a_path() {
let allowances = vec![parse_allowance("U+00A0:docs/**").unwrap()];
assert!(scan("a\u{00A0}b\n", "docs/page.md", &allowances).is_empty());
assert!(
scan("a\u{00A0}b\n", "docs/page.md", &allowances).is_empty(),
"{:?}",
scan("a\u{00A0}b\n", "docs/page.md", &allowances)
);
assert_eq!(scan("a\u{00A0}b\n", "src/main.rs", &allowances).len(), 1);
}

#[test]
fn an_allowance_grants_and_never_revokes() {
// Adding an entry cannot tighten the guard on anybody else's file.
let allowances = vec![parse_allowance("U+00A0").unwrap()];
assert!(scan("a\u{00A0}b\n", "any.txt", &allowances).is_empty());
assert!(
scan("a\u{00A0}b\n", "any.txt", &allowances).is_empty(),
"{:?}",
scan("a\u{00A0}b\n", "any.txt", &allowances)
);
assert_eq!(scan("a\u{200B}b\n", "any.txt", &allowances).len(), 1);
}

Expand All @@ -491,22 +515,30 @@ mod tests {
assert_eq!(found.len(), 1, "{found:?}");
assert!(found[0].contains("U+200B"), "{found:?}");
assert!(found[0].contains("FILE NAME"), "{found:?}");
assert!(scan_name("docs/readme.md", &[]).is_empty());
assert!(
scan_name("docs/readme.md", &[]).is_empty(),
"{:?}",
scan_name("docs/readme.md", &[])
);
}

#[test]
fn a_tab_is_legal_in_a_file_and_never_in_a_path() {
// The two characters the content rule exempts, which is why the path
// cannot simply be handed to `scan`.
assert!(findings("a\tb\n").is_empty());
assert!(findings("a\tb\n").is_empty(), "{:?}", findings("a\tb\n"));
assert_eq!(scan_name("a\tb", &[]).len(), 1);
assert_eq!(scan_name("a\nb", &[]).len(), 1);
}

#[test]
fn an_allowance_scoped_to_a_path_reaches_that_paths_name() {
let allowances = vec![parse_allowance("U+00A0:docs/**").unwrap()];
assert!(scan_name("docs/a\u{00A0}b.md", &allowances).is_empty());
assert!(
scan_name("docs/a\u{00A0}b.md", &allowances).is_empty(),
"{:?}",
scan_name("docs/a\u{00A0}b.md", &allowances)
);
assert_eq!(scan_name("src/a\u{00A0}b.rs", &allowances).len(), 1);
}

Expand Down
6 changes: 5 additions & 1 deletion src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,11 @@ mod tests {
Placed::Occupied(_)
));
// And neither is listed as one of ours, so neither would be removed.
assert!(links(&dir).unwrap().is_empty());
assert!(
links(&dir).unwrap().is_empty(),
"{:?}",
links(&dir).unwrap()
);
assert_eq!(std::fs::read(dir.join("git")).unwrap(), b"the real git");
}

Expand Down
2 changes: 1 addition & 1 deletion src/pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ mod tests {
"repos:\n - repo: local\n hooks:\n - id: x\n",
);
let read = read_pins(&dir).unwrap();
assert!(read.pins.is_empty());
assert!(read.pins.is_empty(), "{:?}", read.pins);
assert_eq!(read.configs, 1);
assert!(
read.notes
Expand Down
Loading
Loading