Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestIgnore.java @ 339:863356c2847e
Issue 16: respect glob patterns in HgIgnore for sub-directories
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 16 Nov 2011 22:42:21 +0100 |
parents | 7af843ecc378 |
children | 516b817415ba |
comparison
equal
deleted
inserted
replaced
338:3cfa4d908fc9 | 339:863356c2847e |
---|---|
39 | 39 |
40 public static void main(String[] args) throws Throwable { | 40 public static void main(String[] args) throws Throwable { |
41 TestIgnore test = new TestIgnore(); | 41 TestIgnore test = new TestIgnore(); |
42 test.testGlobWithAlternatives(); | 42 test.testGlobWithAlternatives(); |
43 test.testComplexFileParse(); | 43 test.testComplexFileParse(); |
44 test.testSegmentsMatch(); | |
45 test.testWildcardsDoNotMatchDirectorySeparator(); | |
44 test.errorCollector.verify(); | 46 test.errorCollector.verify(); |
45 } | 47 } |
46 | 48 |
47 @Test | 49 @Test |
48 public void testGlobWithAlternatives() throws Exception { | 50 public void testGlobWithAlternatives() throws Exception { |
69 for (Path p : toCheck) { | 71 for (Path p : toCheck) { |
70 errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p)); | 72 errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p)); |
71 } | 73 } |
72 } | 74 } |
73 | 75 |
76 @Test | |
77 public void testSegmentsMatch() throws Exception { | |
78 String s = "syntax:glob\nbin\n.*\nTEST-*.xml"; | |
79 HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(s)); | |
80 Path[] toCheck = new Path[] { | |
81 Path.create("bin/org/sample/First.class"), | |
82 Path.create(".ignored-file"), | |
83 Path.create("dir/.ignored-file"), | |
84 Path.create("dir/.ignored-dir/file"), | |
85 Path.create("TEST-a.xml"), | |
86 Path.create("dir/TEST-b.xml"), | |
87 }; | |
88 for (Path p : toCheck) { | |
89 errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p)); | |
90 } | |
91 } | |
92 | |
93 @Test | |
94 public void testWildcardsDoNotMatchDirectorySeparator() throws Exception { | |
95 String s = "syntax:glob\na?b\nc*d"; | |
96 HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(s)); | |
97 // shall not be ignored | |
98 Path[] toPass = new Path[] { | |
99 Path.create("a/b"), | |
100 Path.create("a/b/x"), | |
101 Path.create("x/a/b"), | |
102 Path.create("axyb"), | |
103 Path.create("c/d"), | |
104 Path.create("c/d/x"), | |
105 Path.create("x/c/d"), | |
106 }; | |
107 // shall be ignored | |
108 Path[] toIgnore = new Path[] { | |
109 Path.create("axb"), | |
110 Path.create("a3b"), | |
111 Path.create("a_b"), | |
112 Path.create("cd"), | |
113 Path.create("cxd"), | |
114 Path.create("cxyd"), | |
115 Path.create("x/cd"), | |
116 Path.create("x/cxyd"), | |
117 Path.create("cd/x"), | |
118 Path.create("cxyd/x"), | |
119 }; | |
120 for (Path p : toIgnore) { | |
121 errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p)); | |
122 } | |
123 for (Path p : toPass) { | |
124 errorCollector.assertTrue(p.toString(), !hgIgnore.isIgnored(p)); | |
125 } | |
126 } | |
74 } | 127 } |