Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestIgnore.java @ 269:7af843ecc378
Respect glob pattern with alternatives {a,b}
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Tue, 23 Aug 2011 23:47:38 +0200 |
| parents | |
| children | 863356c2847e |
comparison
equal
deleted
inserted
replaced
| 268:c5980f287cc4 | 269:7af843ecc378 |
|---|---|
| 1 /* | |
| 2 * Copyright (c) 2011 TMate Software Ltd | |
| 3 * | |
| 4 * This program is free software; you can redistribute it and/or modify | |
| 5 * it under the terms of the GNU General Public License as published by | |
| 6 * the Free Software Foundation; version 2 of the License. | |
| 7 * | |
| 8 * This program is distributed in the hope that it will be useful, | |
| 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 11 * GNU General Public License for more details. | |
| 12 * | |
| 13 * For information on how to redistribute this software under | |
| 14 * the terms of a license other than GNU General Public License | |
| 15 * contact TMate Software at support@hg4j.com | |
| 16 */ | |
| 17 package org.tmatesoft.hg.test; | |
| 18 | |
| 19 import java.io.BufferedReader; | |
| 20 import java.io.File; | |
| 21 import java.io.FileReader; | |
| 22 import java.io.StringReader; | |
| 23 | |
| 24 import org.junit.Rule; | |
| 25 import org.junit.Test; | |
| 26 import org.tmatesoft.hg.repo.HgIgnore; | |
| 27 import org.tmatesoft.hg.repo.HgInternals; | |
| 28 import org.tmatesoft.hg.util.Path; | |
| 29 | |
| 30 /** | |
| 31 * | |
| 32 * @author Artem Tikhomirov | |
| 33 * @author TMate Software Ltd. | |
| 34 */ | |
| 35 public class TestIgnore { | |
| 36 | |
| 37 @Rule | |
| 38 public ErrorCollectorExt errorCollector = new ErrorCollectorExt(); | |
| 39 | |
| 40 public static void main(String[] args) throws Throwable { | |
| 41 TestIgnore test = new TestIgnore(); | |
| 42 test.testGlobWithAlternatives(); | |
| 43 test.testComplexFileParse(); | |
| 44 test.errorCollector.verify(); | |
| 45 } | |
| 46 | |
| 47 @Test | |
| 48 public void testGlobWithAlternatives() throws Exception { | |
| 49 String content = "syntax:glob\ndoc/*.[0-9].{x,ht}ml"; | |
| 50 HgIgnore hgIgnore = HgInternals.newHgIgnore(new StringReader(content)); | |
| 51 final Path p1 = Path.create("doc/asd.2.xml"); | |
| 52 final Path p2 = Path.create("doc/zxc.6.html"); | |
| 53 errorCollector.assertTrue(p1.toString(), hgIgnore.isIgnored(p1)); | |
| 54 errorCollector.assertTrue(p2.toString(), hgIgnore.isIgnored(p2)); | |
| 55 } | |
| 56 | |
| 57 @Test | |
| 58 public void testComplexFileParse() throws Exception { | |
| 59 BufferedReader br = new BufferedReader(new FileReader(new File(Configuration.get().getTestDataDir(), "mercurial.hgignore"))); | |
| 60 HgIgnore hgIgnore = HgInternals.newHgIgnore(br); | |
| 61 br.close(); | |
| 62 Path[] toCheck = new Path[] { | |
| 63 Path.create("file.so"), | |
| 64 Path.create("a/b/file.so"), | |
| 65 Path.create("#abc#"), | |
| 66 Path.create(".#abc"), | |
| 67 Path.create("locale/en/LC_MESSAGES/hg.mo"), | |
| 68 }; | |
| 69 for (Path p : toCheck) { | |
| 70 errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p)); | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 } |
