| 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 | } |