MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_complex_negation

Function test_complex_negation

atomic-repository/src/ignore.rs:1055–1074  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1053
1054 #[test]
1055 fn test_complex_negation() {
1056 let temp = TempDir::new().unwrap();
1057 let ignore_path = temp.path().join(".atomicignore");
1058 std::fs::write(
1059 &ignore_path,
1060 "logs/\n!logs/important/\nlogs/important/*.log\n!logs/important/keep.log\n",
1061 )
1062 .unwrap();
1063
1064 let rules = IgnoreRules::load(temp.path());
1065
1066 assert!(rules.is_ignored(Path::new("logs"), true));
1067 assert!(rules.is_ignored(Path::new("logs/debug.log"), false));
1068 // Negation patterns restore files
1069 assert!(!rules.is_ignored(Path::new("logs/important"), true));
1070 // But nested patterns can re-ignore
1071 assert!(rules.is_ignored(Path::new("logs/important/error.log"), false));
1072 // And nested negations can restore again
1073 assert!(!rules.is_ignored(Path::new("logs/important/keep.log"), false));
1074 }
1075}

Callers

nothing calls this directly

Calls 3

writeFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected