diff options
author | Irina Iancu <elenairina@google.com> | 2017-01-16 13:39:05 +0000 |
---|---|---|
committer | Vladimir Moskva <vladmos@google.com> | 2017-01-16 13:48:59 +0000 |
commit | a1dd398f2a7a022d8d04d4ce0d2d2934dd355195 (patch) | |
tree | b54d3e22b9647c82a899dca336f702bc1cdd5854 /src/test | |
parent | 56328986232dfe4d92f738ab3bbd26d89236a428 (diff) |
Adding output_licenses to bazel's java_plugin.
Fixes #2286.
--
PiperOrigin-RevId: 144627152
MOS_MIGRATED_REVID=144627152
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/BUILD | 1 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelLicensingTests.java | 60 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD index bc018d7299..c48a0ddada 100644 --- a/src/test/java/com/google/devtools/build/lib/BUILD +++ b/src/test/java/com/google/devtools/build/lib/BUILD @@ -306,6 +306,7 @@ java_test( java_library( name = "analysis_testutil", srcs = glob([ + "analysis/LicensingTests.java", "analysis/mock/BazelAnalysisMock.java", "analysis/util/*.java", "exec/util/*.java", diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelLicensingTests.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelLicensingTests.java new file mode 100644 index 0000000000..977753a4c0 --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelLicensingTests.java @@ -0,0 +1,60 @@ +// Copyright 2015 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.bazel.rules.java; + + +import com.google.common.collect.Maps; +import com.google.devtools.build.lib.analysis.ConfiguredTarget; +import com.google.devtools.build.lib.analysis.LicensingTests; +import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.packages.License; +import java.util.Map; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Integration tests for {@link License}. + */ +@RunWith(JUnit4.class) +public class BazelLicensingTests extends LicensingTests { + @Test + public void testJavaPluginAllowsOutputLicenseDeclaration() throws Exception { + scratch.file("ise/BUILD", + "licenses(['restricted'])", + "java_library(name = 'dependency',", + " srcs = ['dependency.java'])", + "java_plugin(name = 'plugin',", + " deps = [':dependency'],", + " srcs = ['plugin.java'],", + " output_licenses = ['unencumbered'])"); + + scratch.file("gsa/BUILD", + "licenses(['unencumbered'])", + "java_library(name = 'library',", + " srcs = ['library.java'],", + " plugins = ['//ise:plugin'])"); + + ConfiguredTarget library = getConfiguredTarget("//gsa:library"); + Map<Label, License> actual = Maps.filterKeys(getTransitiveLicenses(library), + CC_OR_JAVA_OR_SH_LABEL_FILTER); + Map<Label, License> expected = licenses( + "//ise:plugin", "unencumbered", + "//gsa:library", "unencumbered" + ); + + assertSameMapEntries(expected, actual); + } +} |