// 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.analysis; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertNotNull; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; import com.google.devtools.build.lib.analysis.util.AnalysisTestCase; import com.google.devtools.build.lib.analysis.util.TestAspects; import com.google.devtools.build.lib.analysis.util.TestAspects.AspectRequiringRule; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.packages.Aspect; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.NativeAspectClass; import com.google.devtools.build.lib.packages.NoSuchPackageException; import com.google.devtools.build.lib.packages.NoSuchTargetException; import com.google.devtools.build.lib.packages.NoSuchThingException; import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.testutil.TestRuleClassProvider; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import javax.annotation.Nullable; /** * Tests for {@link DependencyResolver}. * *

These use custom rules so that all usual and unusual cases related to aspect processing can * be tested. * *

It would be nicer is we didn't have a Skyframe executor, if we didn't have that, we'd need a * way to create a configuration, a package manager and a whole lot of other things, so it's just * easier this way. */ @RunWith(JUnit4.class) public class DependencyResolverTest extends AnalysisTestCase { private DependencyResolver dependencyResolver; @Before public final void createResolver() throws Exception { dependencyResolver = new DependencyResolver() { @Override protected void invalidVisibilityReferenceHook(TargetAndConfiguration node, Label label) { throw new IllegalStateException(); } @Override protected void invalidPackageGroupReferenceHook(TargetAndConfiguration node, Label label) { throw new IllegalStateException(); } @Override protected void missingEdgeHook(Target from, Label to, NoSuchThingException e) { throw new IllegalStateException(e); } @Nullable @Override protected Target getTarget(Target from, Label label, NestedSetBuilder