| 921 | |
| 922 | #[test] |
| 923 | fn test_node_modules_no_trailing_slash() { |
| 924 | // This tests the common case where users write "node_modules" without trailing slash |
| 925 | let temp = TempDir::new().unwrap(); |
| 926 | let ignore_path = temp.path().join(".atomicignore"); |
| 927 | std::fs::write(&ignore_path, "node_modules\n").unwrap(); |
| 928 | |
| 929 | let rules = IgnoreRules::load(temp.path()); |
| 930 | |
| 931 | // Should ignore the directory itself |
| 932 | assert!( |
| 933 | rules.is_ignored(Path::new("node_modules"), true), |
| 934 | "node_modules directory should be ignored" |
| 935 | ); |
| 936 | |
| 937 | // Should ignore subdirectories |
| 938 | assert!( |
| 939 | rules.is_ignored(Path::new("node_modules/typescript"), true), |
| 940 | "node_modules/typescript should be ignored" |
| 941 | ); |
| 942 | |
| 943 | // Should ignore files inside node_modules |
| 944 | assert!( |
| 945 | rules.is_ignored( |
| 946 | Path::new("node_modules/typescript/lib/lib.es2015.proxy.d.ts"), |
| 947 | false |
| 948 | ), |
| 949 | "Files inside node_modules should be ignored" |
| 950 | ); |
| 951 | |
| 952 | // Should ignore deeply nested files |
| 953 | assert!( |
| 954 | rules.is_ignored( |
| 955 | Path::new("node_modules/@types/node/child_process.d.ts"), |
| 956 | false |
| 957 | ), |
| 958 | "Deeply nested files in node_modules should be ignored" |
| 959 | ); |
| 960 | |
| 961 | // Should NOT ignore unrelated files |
| 962 | assert!( |
| 963 | !rules.is_ignored(Path::new("src/index.js"), false), |
| 964 | "src/index.js should NOT be ignored" |
| 965 | ); |
| 966 | assert!( |
| 967 | !rules.is_ignored(Path::new("package.json"), false), |
| 968 | "package.json should NOT be ignored" |
| 969 | ); |
| 970 | } |
| 971 | |
| 972 | #[test] |
| 973 | fn test_python_patterns() { |