diff options
author | 2018-01-02 04:38:02 -0800 | |
---|---|---|
committer | 2018-01-02 04:40:18 -0800 | |
commit | 7e8c9460141db26e3a818cba16165ff31e80799e (patch) | |
tree | 0f6f81ab0aee906886396d32c6f8e61a49335719 /src/test/java/com/google/devtools/build/lib | |
parent | 63a8e1a9c2eb887c45e4ec37c7a858b004acd979 (diff) |
Automated rollback of commit 46356dfa59428b665aa280ba4cbca6e449f73c5b.
*** Reason for rollback ***
causes github #4375 and #4373
*** Original change description ***
Use an annotation preprocessor to validate SkylarkConfigurationField.
RELNOTES: None.
PiperOrigin-RevId: 180535458
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
9 files changed, 0 insertions, 439 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/BUILD b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/BUILD deleted file mode 100644 index a583cfad24..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/BUILD +++ /dev/null @@ -1,29 +0,0 @@ -licenses(["notice"]) # Apache 2.0 - -filegroup( - name = "srcs", - srcs = glob( - ["**"], - ), - visibility = ["//src/main/java/com/google/devtools/build/lib:__pkg__"], -) - -java_test( - name = "SkylarkConfigurationFieldProcessorTest", - srcs = ["SkylarkConfigurationFieldProcessorTest.java"], - resources = [":ProcessorTestFiles"], - deps = [ - "//src/main/java/com/google/devtools/build/lib:build-base", - "//src/main/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor:annotation_preprocessor", - "//src/main/java/com/google/devtools/build/lib/cmdline", - "//third_party:compile_testing", - "//third_party:guava", - "//third_party:junit4", - "//third_party:truth", - ], -) - -filegroup( - name = "ProcessorTestFiles", - srcs = glob(["optiontestsources/*.java"]), -) diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/SkylarkConfigurationFieldProcessorTest.java b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/SkylarkConfigurationFieldProcessorTest.java deleted file mode 100644 index 3edeb437eb..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/SkylarkConfigurationFieldProcessorTest.java +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2017 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.analysis.skylark.annotations.processor; - -import static com.google.common.truth.Truth.assertAbout; -import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource; - -import com.google.common.io.Resources; -import com.google.testing.compile.JavaFileObjects; -import javax.tools.JavaFileObject; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Unit tests for SkylarkConfigurationFieldProcessor. - */ -@RunWith(JUnit4.class) -public final class SkylarkConfigurationFieldProcessorTest { - - private static JavaFileObject getFile(String pathToFile) { - return JavaFileObjects.forResource(Resources.getResource( - "com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/" - + pathToFile)); - } - - @Test - public void testGoldenConfigurationField() throws Exception { - assertAbout(javaSource()) - .that(getFile("GoldenConfigurationField.java")) - .processedWith(new SkylarkConfigurationFieldProcessor()) - .compilesWithoutError(); - } - - @Test - public void testHasMethodParameters() throws Exception { - assertAbout(javaSource()) - .that(getFile("HasMethodParameters.java")) - .processedWith(new SkylarkConfigurationFieldProcessor()) - .failsToCompile() - .withErrorContaining( - "@SkylarkConfigurationField annotated methods must have zero arguments."); - } - - @Test - public void testMethodIsPrivate() throws Exception { - assertAbout(javaSource()) - .that(getFile("MethodIsPrivate.java")) - .processedWith(new SkylarkConfigurationFieldProcessor()) - .failsToCompile() - .withErrorContaining("@SkylarkConfigurationField annotated methods must be public."); - } - - @Test - public void testMethodThrowsException() throws Exception { - assertAbout(javaSource()) - .that(getFile("MethodThrowsException.java")) - .processedWith(new SkylarkConfigurationFieldProcessor()) - .failsToCompile() - .withErrorContaining("@SkylarkConfigurationField annotated must not throw exceptions."); - } - - @Test - public void testNonConfigurationFragment() throws Exception { - assertAbout(javaSource()) - .that(getFile("NonConfigurationFragment.java")) - .processedWith(new SkylarkConfigurationFieldProcessor()) - .failsToCompile() - .withErrorContaining("@SkylarkConfigurationField annotated methods must be methods of " - + "configuration fragments with the @SkylarkModule annotation."); - } - - @Test - public void testNonExposedConfigurationFragment() throws Exception { - assertAbout(javaSource()) - .that(getFile("NonExposedConfigurationFragment.java")) - .processedWith(new SkylarkConfigurationFieldProcessor()) - .failsToCompile() - .withErrorContaining("@SkylarkConfigurationField annotated methods must be methods of " - + "configuration fragments with the @SkylarkModule annotation."); - } - - @Test - public void testReturnsOtherType() throws Exception { - assertAbout(javaSource()) - .that(getFile("ReturnsOtherType.java")) - .processedWith(new SkylarkConfigurationFieldProcessor()) - .failsToCompile() - .withErrorContaining("@SkylarkConfigurationField annotated methods must return Label."); - } -} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/GoldenConfigurationField.java b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/GoldenConfigurationField.java deleted file mode 100644 index 47fd152b48..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/GoldenConfigurationField.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 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.analysis.skylark.annotations.processor.optiontestsources; - -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.skylark.annotations.SkylarkConfigurationField; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; - -/** - * A test case of SkylarkConfigurationFieldProcessorTest. - */ -@SkylarkModule( - name = "module_name", - doc = "A fake configuration fragment for a test.", - category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT -) -public class GoldenConfigurationField extends BuildConfiguration.Fragment { - - /** - * Returns the label of the xcode_config rule to use for resolving the host system xcode version. - */ - @SkylarkConfigurationField( - name = "some_field", - doc = "Documentation ", - defaultLabel = "defaultLabel", - defaultInToolRepository = true - ) - public Label getXcodeConfigLabel() { - return null; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/HasMethodParameters.java b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/HasMethodParameters.java deleted file mode 100644 index f75519c1cc..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/HasMethodParameters.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 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.analysis.skylark.annotations.processor.optiontestsources; - -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.skylark.annotations.SkylarkConfigurationField; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; - -/** - * A test case of SkylarkConfigurationFieldProcessorTest. - */ -@SkylarkModule( - name = "module_name", - doc = "A fake configuration fragment for a test.", - category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT -) -public class HasMethodParameters extends BuildConfiguration.Fragment { - - /** - * Returns the label of the xcode_config rule to use for resolving the host system xcode version. - */ - @SkylarkConfigurationField( - name = "some_field", - doc = "Documentation ", - defaultLabel = "defaultLabel", - defaultInToolRepository = true - ) - public Label getXcodeConfigLabel(int x) { - return null; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/MethodIsPrivate.java b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/MethodIsPrivate.java deleted file mode 100644 index 3569917255..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/MethodIsPrivate.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 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.analysis.skylark.annotations.processor.optiontestsources; - -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.skylark.annotations.SkylarkConfigurationField; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; - -/** - * A test case of SkylarkConfigurationFieldProcessorTest. - */ -@SkylarkModule( - name = "module_name", - doc = "A fake configuration fragment for a test.", - category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT -) -public class MethodIsPrivate extends BuildConfiguration.Fragment { - - /** - * Returns the label of the xcode_config rule to use for resolving the host system xcode version. - */ - @SkylarkConfigurationField( - name = "some_field", - doc = "Documentation ", - defaultLabel = "defaultLabel", - defaultInToolRepository = true - ) - private Label getXcodeConfigLabel() { - return null; - } -} - diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/MethodThrowsException.java b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/MethodThrowsException.java deleted file mode 100644 index 43fdc46139..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/MethodThrowsException.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 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.analysis.skylark.annotations.processor.optiontestsources; - -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.skylark.annotations.SkylarkConfigurationField; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; - -/** - * A test case of SkylarkConfigurationFieldProcessorTest. - */ -@SkylarkModule( - name = "module_name", - doc = "A fake configuration fragment for a test.", - category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT -) -public class MethodThrowsException extends BuildConfiguration.Fragment { - - /** - * Returns the label of the xcode_config rule to use for resolving the host system xcode version. - */ - @SkylarkConfigurationField( - name = "some_field", - doc = "Documentation ", - defaultLabel = "defaultLabel", - defaultInToolRepository = true - ) - public Label getXcodeConfigLabel() throws IllegalArgumentException { - return null; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/NonConfigurationFragment.java b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/NonConfigurationFragment.java deleted file mode 100644 index 221493775f..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/NonConfigurationFragment.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 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.analysis.skylark.annotations.processor.optiontestsources; - -import com.google.devtools.build.lib.analysis.skylark.annotations.SkylarkConfigurationField; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; - -/** - * A test case of SkylarkConfigurationFieldProcessorTest. - */ -@SkylarkModule( - name = "module_name", - doc = "A fake configuration fragment for a test.", - category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT -) -public class NonConfigurationFragment { - - /** - * Returns the label of the xcode_config rule to use for resolving the host system xcode version. - */ - @SkylarkConfigurationField( - name = "some_field", - doc = "Documentation ", - defaultLabel = "defaultLabel", - defaultInToolRepository = true - ) - public Label getXcodeConfigLabel() { - return null; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/NonExposedConfigurationFragment.java b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/NonExposedConfigurationFragment.java deleted file mode 100644 index 6806c14c2a..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/NonExposedConfigurationFragment.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 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.analysis.skylark.annotations.processor.optiontestsources; - -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.skylark.annotations.SkylarkConfigurationField; -import com.google.devtools.build.lib.cmdline.Label; - -/** - * A test case of SkylarkConfigurationFieldProcessorTest. - */ -public class NonExposedConfigurationFragment extends BuildConfiguration.Fragment { - - /** - * Returns the label of the xcode_config rule to use for resolving the host system xcode version. - */ - @SkylarkConfigurationField( - name = "some_field", - doc = "Documentation ", - defaultLabel = "defaultLabel", - defaultInToolRepository = true - ) - public Label getXcodeConfigLabel() { - return null; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/ReturnsOtherType.java b/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/ReturnsOtherType.java deleted file mode 100644 index 2f167c33b5..0000000000 --- a/src/test/java/com/google/devtools/build/lib/analysis/skylark/annotations/processor/optiontestsources/ReturnsOtherType.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 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.analysis.skylark.annotations.processor.optiontestsources; - -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.skylark.annotations.SkylarkConfigurationField; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; - -/** - * A test case of SkylarkConfigurationFieldProcessorTest. - */ -@SkylarkModule( - name = "module_name", - doc = "A fake configuration fragment for a test.", - category = SkylarkModuleCategory.CONFIGURATION_FRAGMENT -) -public class ReturnsOtherType extends BuildConfiguration.Fragment { - - /** - * Returns the label of the xcode_config rule to use for resolving the host system xcode version. - */ - @SkylarkConfigurationField( - name = "some_field", - doc = "Documentation ", - defaultLabel = "defaultLabel", - defaultInToolRepository = true - ) - public String getXcodeConfigLabel() { - return null; - } -} |