blob: 2541692df5214c4962140b3ec1ba10a300d64eb3 [file] [log] [blame]
laszlocsomorf4b6ac62020-02-06 01:13:44 -08001// Copyright 2020 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14package com.google.devtools.build.lib.analysis;
15
16import com.google.devtools.build.lib.analysis.configuredtargets.PackageGroupConfiguredTarget;
17import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
18import org.junit.Test;
19import org.junit.runner.RunWith;
20import org.junit.runners.JUnit4;
21
22/**
23 * Tests for {@link PackageGroupConfiguredTarget}.
24 */
25@RunWith(JUnit4.class)
26public final class PackageGroupBuildViewTest extends BuildViewTestCase {
27 /** Regression test for bug #3445835. */
28 @Test
29 public void testPackageGroupInDeps() throws Exception {
30 checkError("foo", "bar", "in deps attribute of cc_library rule //foo:bar: "
31 + "package group '//foo:foo' is misplaced here ",
32 "package_group(name = 'foo', packages = ['//none'])",
33 "cc_library(name = 'bar', deps = [':foo'])");
34 }
35
36 @Test
37 public void testPackageGroupInData() throws Exception {
38 checkError(
39 "foo",
40 "bar",
41 "in data attribute of cc_library rule //foo:bar: "
42 + "package group '//foo:foo' is misplaced here ",
43 "package_group(name = 'foo', packages = ['//none'])",
44 "cc_library(name = 'bar', data = [':foo'])");
45 }
46}