diff options
author | 2018-05-24 06:11:07 -0700 | |
---|---|---|
committer | 2018-05-24 06:12:21 -0700 | |
commit | 2cb2ac6e9402ffa27f32880f52c13be60c631ff6 (patch) | |
tree | 9101eb1e62bbd93d48c69440ceff7a019636acdb /src/test/java/com | |
parent | 70733df000fe72b8d06abdb92ce129be934d622b (diff) |
Delete GlobList
RELNOTES: None.
PiperOrigin-RevId: 197881012
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/GlobCriteriaTest.java | 191 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/GlobListTest.java | 99 |
2 files changed, 0 insertions, 290 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/GlobCriteriaTest.java b/src/test/java/com/google/devtools/build/lib/syntax/GlobCriteriaTest.java deleted file mode 100644 index c75633a8f5..0000000000 --- a/src/test/java/com/google/devtools/build/lib/syntax/GlobCriteriaTest.java +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright 2009 The Bazel Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package com.google.devtools.build.lib.syntax; - -import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; - -import com.google.devtools.build.lib.testutil.Suite; -import com.google.devtools.build.lib.testutil.TestSpec; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Links for {@link GlobCriteria} - */ -@TestSpec(size = Suite.SMALL_TESTS) -@RunWith(JUnit4.class) -public class GlobCriteriaTest { - - @Test - public void testParse_EmptyList() throws Exception { - GlobCriteria gc = GlobCriteria.parse("[]"); - assertThat(gc.isGlob()).isFalse(); - assertThat(gc.getIncludePatterns()).isEmpty(); - assertThat(gc.getExcludePatterns()).isEmpty(); - } - - @Test - public void testParse_SingleList() throws Exception { - GlobCriteria gc = GlobCriteria.parse("['abc']"); - assertThat(gc.isGlob()).isFalse(); - assertThat(gc.getIncludePatterns()).containsExactly("abc"); - assertThat(gc.getExcludePatterns()).isEmpty(); - } - - @Test - public void testParse_MultipleList() throws Exception { - GlobCriteria gc = GlobCriteria.parse("['abc', 'def', 'ghi']"); - assertThat(gc.isGlob()).isFalse(); - assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder(); - assertThat(gc.getExcludePatterns()).isEmpty(); - } - - @Test - public void testParse_EmptyGlob() throws Exception { - GlobCriteria gc = GlobCriteria.parse("glob([])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).isEmpty(); - assertThat(gc.getExcludePatterns()).isEmpty(); - } - - @Test - public void testParse_SingleGlob() throws Exception { - GlobCriteria gc = GlobCriteria.parse("glob(['abc'])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).containsExactly("abc"); - assertThat(gc.getExcludePatterns()).isEmpty(); - } - - @Test - public void testParse_MultipleGlob() throws Exception { - GlobCriteria gc = GlobCriteria.parse("glob(['abc', 'def', 'ghi'])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder(); - assertThat(gc.getExcludePatterns()).isEmpty(); - } - - @Test - public void testParse_EmptyGlobWithExclude() throws Exception { - GlobCriteria gc = GlobCriteria.parse("glob([], exclude=['xyz'])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).isEmpty(); - assertThat(gc.getExcludePatterns()).containsExactly("xyz"); - } - - @Test - public void testParse_SingleGlobWithExclude() throws Exception { - GlobCriteria gc = GlobCriteria.parse("glob(['abc'], exclude=['xyz'])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).containsExactly("abc"); - assertThat(gc.getExcludePatterns()).containsExactly("xyz"); - } - - @Test - public void testParse_MultipleGlobWithExclude() throws Exception { - GlobCriteria gc = GlobCriteria.parse("glob(['abc', 'def', 'ghi'], exclude=['xyz'])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder(); - assertThat(gc.getExcludePatterns()).containsExactly("xyz"); - } - - @Test - public void testParse_MultipleGlobWithMultipleExclude() throws Exception { - GlobCriteria gc = GlobCriteria.parse( - "glob(['abc', 'def', 'ghi'], exclude=['rst', 'uvw', 'xyz'])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder(); - assertThat(gc.getExcludePatterns()).containsExactly("rst", "uvw", "xyz").inOrder(); - } - - @Test - public void testParse_GlobWithSlashesAndWildcards() throws Exception { - GlobCriteria gc = GlobCriteria.parse("glob(['java/src/net/jsunit/*.java'])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).containsExactly("java/src/net/jsunit/*.java"); - assertThat(gc.getExcludePatterns()).isEmpty(); - } - - @Test - public void testParse_ExcludeWithInvalidLabel() throws Exception { - GlobCriteria gc = GlobCriteria.parse("glob(['abc', 'def', 'ghi'], exclude=['xyz~'])"); - assertThat(gc.isGlob()).isTrue(); - assertThat(gc.getIncludePatterns()).containsExactly("abc", "def", "ghi").inOrder(); - assertThat(gc.getExcludePatterns()).containsExactly("xyz~"); - } - - @Test - public void testParse_InvalidFormat_TooManySpacesList() throws Exception { - try { - GlobCriteria.parse("glob(['abc, 'def', 'ghi'], exclude=['xyz~'])"); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - } - - @Test - public void testParse_InvalidFormat_MissingQuote() throws Exception { - try { - GlobCriteria.parse("glob(['abc, 'def', 'ghi'], exclude=['xyz~'])"); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - } - - @Test - public void testParse_InvalidFormat_TooManySpacesExclude() throws Exception { - try { - GlobCriteria.parse("glob(['abc', 'def', 'ghi'], exclude=['xyz~'])"); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - } - - @Test - public void testParse_InvalidFormat_MissingQuoteExclude() throws Exception { - try { - GlobCriteria.parse("glob(['abc, 'def', 'ghi'], exclude=['xyz~])"); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - } - - @Test - public void testParse_InvalidFormat_ExcludeWithList() throws Exception { - try { - GlobCriteria.parse("['abc, 'def', 'ghi'], exclude=['xyz~']"); - fail(); - } catch (IllegalArgumentException e) { - // expected - } - } - - @Test - public void testParse_veryLongString() throws Exception { - StringBuilder builder = new StringBuilder(); - builder.append("['File0.java'"); - for (int i = 1; i < 5000; ++i) { - builder.append(", 'File").append(i).append(".java'"); - } - builder.append("]"); - String s = builder.toString(); - GlobCriteria gc = GlobCriteria.parse(s); - assertThat(gc.toString()).isEqualTo(s); - } -} diff --git a/src/test/java/com/google/devtools/build/lib/syntax/GlobListTest.java b/src/test/java/com/google/devtools/build/lib/syntax/GlobListTest.java deleted file mode 100644 index d5da29e53f..0000000000 --- a/src/test/java/com/google/devtools/build/lib/syntax/GlobListTest.java +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2009 The Bazel Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package com.google.devtools.build.lib.syntax; - -import static com.google.common.truth.Truth.assertThat; - -import com.google.common.collect.ImmutableList; -import com.google.devtools.build.lib.testutil.Suite; -import com.google.devtools.build.lib.testutil.TestSpec; -import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Tests for {@link GlobList} */ -@TestSpec(size = Suite.SMALL_TESTS) -@RunWith(JUnit4.class) -public class GlobListTest { - - @Test - public void testParse_glob() throws Exception { - String expression = "glob(['abc'])"; - assertThat(GlobList.parse(expression).toExpression()).isEqualTo(expression); - } - - @Test - public void testParse_multipleGlobs() throws Exception { - String expression = "glob(['abc']) + glob(['def']) + glob(['ghi'])"; - assertThat(GlobList.parse(expression).toExpression()).isEqualTo(expression); - } - - @Test - public void testParse_multipleLists() throws Exception { - String expression = "['abc'] + ['def'] + ['ghi']"; - assertThat(GlobList.parse(expression).toExpression()).isEqualTo(expression); - } - - @Test - public void testParse_complexExpression() throws Exception { - String expression = "glob(['abc', 'def', 'ghi'], " - + "exclude=['rst', 'uvw', 'xyz']) " - + "+ glob(['abc', 'def', 'ghi'], exclude=['rst', 'uvw', 'xyz'])"; - assertThat(GlobList.parse(expression).toExpression()).isEqualTo(expression); - } - - @Test - public void testConcat_GlobToGlob() throws Exception { - GlobList<String> glob1 = GlobList.parse( - "glob(['abc'], exclude=['def']) + glob(['xyz'])"); - GlobList<String> glob2 = GlobList.parse( - "glob(['xyzzy']) + glob(['foo'], exclude=['bar'])"); - GlobList<String> cat = GlobList.concat(glob1, glob2); - assertThat(cat.toExpression()).isEqualTo(glob1.toExpression() + " + " + glob2.toExpression()); - } - - @Test - public void testConcat_GlobToList() throws Exception { - GlobList<String> glob = GlobList.parse( - "glob(['abc'], exclude=['def']) + glob(['xyz'])"); - List<String> list = ImmutableList.of("xyzzy", "foo", "bar"); - GlobList<String> cat = GlobList.concat(list, glob); - assertThat(cat.toExpression()) - .isEqualTo("['xyzzy', 'foo', 'bar'] + glob(['abc'], exclude=['def']) + glob(['xyz'])"); - } - - @Test - public void testConcat_ListToGlob() throws Exception { - GlobList<String> glob = GlobList.parse( - "glob(['abc'], exclude=['def']) + glob(['xyz'])"); - List<String> list = ImmutableList.of("xyzzy", "foo", "bar"); - GlobList<String> cat = GlobList.concat(glob, list); - assertThat(cat.toExpression()) - .isEqualTo("glob(['abc'], exclude=['def']) + glob(['xyz']) + ['xyzzy', 'foo', 'bar']"); - } - - @Test - public void testGetCriteria() throws Exception { - List<String> include = ImmutableList.of("abc", "def", "ghi"); - List<String> exclude = ImmutableList.of("rst", "uvw", "xyz"); - List<String> matches = ImmutableList.of("xyzzy", "foo", "bar"); - GlobList<String> glob = GlobList.captureResults(include, exclude, matches); - assertThat(glob).isEqualTo(matches); - ImmutableList<GlobCriteria> criteria = glob.getCriteria(); - assertThat(criteria).hasSize(1); - assertThat(criteria.get(0).getIncludePatterns()).isEqualTo(include); - assertThat(criteria.get(0).getExcludePatterns()).isEqualTo(exclude); - } -} |