@Test public void shouldIgnoreWhenTextIsDocumentInChildOfRootFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("*/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "B" + separator + "c.doc"), is(true)); }
@Test public void shouldNormalizeRegex() throws Exception { IgnoredFiles ignore = new IgnoredFiles("*\\*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "B" + separator + "c.doc"), is(true)); }
@Test public void shouldSkipDiot() throws Exception { IgnoredFiles ignore = new IgnoredFiles("helper/*.*"); assertThat( ignore.shouldIgnore( hgMaterialConfig, "helper" + separator + "configuration_reference.html"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "helper" + separator + "conf-docs" + separator + "configuration_reference.html"), is(false)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "helper" + separator + "resources" + separator + "images" + separator + "cruise" + separator + "dependent_build.png"), is(false)); }
@Test public void shouldIncludeWhenTheTextUnderRootIsNotADocument() { IgnoredFiles ignore = new IgnoredFiles("*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.pdf"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc.aaa"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(false)); }
@Test public void shouldIgnoreIfTextIsUnderAFolderMatchingTheGivenFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*Test*/*"); assertThat( ignore.shouldIgnore( hgMaterialConfig, "B" + separator + "SomethingTestThis" + separator + "isIgnored"), is(true)); }
@Test public void shouldIgnoreIfTextIsUnderAGivenFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/DocumentFolder/*"); assertThat( ignore.shouldIgnore( hgMaterialConfig, "A" + separator + "DocumentFolder" + separator + "d.doc"), is(true)); }
@Test public void shouldIgnoreWhenTextIsADocumentInAnyFolderWhenDirectoryWildcardNotInTheBegining() throws Exception { IgnoredFiles ignore = new IgnoredFiles("foo*/**/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "foo-hi/bar/a.doc"), is(true)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "bar/baz/b.doc"), is(false)); }
@Test public void shouldIncludeWhenTextIsNotADocumentInAnyFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.pdf"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "B" + separator + "a.pdf"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "B" + separator + "a.pdf"), is(false)); }
@Test public void shouldIncludeIfTextIsNotUnderAFolderMatchingTheGivenFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("**/*Test*/*"); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "shouldNotBeIgnored.doc"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "B/NotIgnored" + separator + "isIgnored"), is(false)); }
@Test public void shouldEscapeAllValidSpecialCharactersInPattern() { // see mingle #5700 hgMaterialConfig = new TfsMaterialConfig(new GoCipher()); IgnoredFiles ignore = new IgnoredFiles("$/tfs_repo/Properties/*.*"); assertThat( ignore.shouldIgnore( hgMaterialConfig, "$/tfs_repo" + separator + "Properties" + separator + "AssemblyInfo.cs"), is(true)); }
@Test public void shouldIncludeWhenTheTextDoesnotMatchDocumentUnderRoot() { IgnoredFiles ignore = new IgnoredFiles("a.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "b.doc"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc1"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "B" + separator + "a.doc"), is(false)); assertThat(ignore.shouldIgnore(hgMaterialConfig, "A" + separator + "a.doc"), is(false)); }
@Test public void shouldIncludeIfTheTextIsNotADocumentInTheSpecifiedFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("ROOTFOLDER/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "shouldNotBeIgnored.doc"), is(false)); assertThat( ignore.shouldIgnore(hgMaterialConfig, "ANYFOLDER" + separator + "shouldNotBeIgnored.doc"), is(false)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "ROOTFOLDER" + separator + "" + "ANYFOLDER" + separator + "shouldNotBeIgnored.doc"), is(false)); }
@Test public void shouldIgnoreEverythingUnderAFolderWithWildcardsWithoutExtension() throws Exception { IgnoredFiles ignore = new IgnoredFiles("Test/**/*"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "Test" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "subdir" + separator + "foo.txt"), is(true)); assertThat( ignore.shouldIgnore( hgMaterialConfig, "Test" + separator + "subdir" + separator + "subdir" + separator + "foo"), is(true)); }
@Test public void shouldIgnoreWhenTheTextUnderRootIsADocument() { IgnoredFiles ignore = new IgnoredFiles("*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "a.doc"), is(true)); }
@Test public void shouldAddErrorToItsErrorCollection() { IgnoredFiles ignore = new IgnoredFiles("helper/*.*"); ignore.addError("pattern", "not allowed"); assertThat(ignore.errors().on("pattern"), is("not allowed")); }
@Test public void shouldIncludIgnoreIfTextIsADocumentInTheSpecifiedFolder() throws Exception { IgnoredFiles ignore = new IgnoredFiles("ROOTFOLDER/*.doc"); assertThat(ignore.shouldIgnore(hgMaterialConfig, "ROOTFOLDER" + separator + "a.doc"), is(true)); }