From e4eb23fe5512760b0e4a80c19a98f43875051fb1 Mon Sep 17 00:00:00 2001 From: nharmata Date: Tue, 5 Dec 2017 09:27:45 -0800 Subject: Automated rollback of commit d0f06a6e4b61adc39bf5e1cfbae39501a89dc8e3. RELNOTES: None PiperOrigin-RevId: 177965330 --- .../build/lib/analysis/util/AnalysisTestCase.java | 3 +- .../build/lib/analysis/util/BuildViewTestCase.java | 3 +- .../lib/analysis/util/ConfigurationTestCase.java | 3 +- .../lib/packages/util/PackageLoadingTestCase.java | 4 +- .../lib/pkgcache/BuildFileModificationTest.java | 4 +- .../build/lib/pkgcache/IncrementalLoadingTest.java | 3 +- .../build/lib/pkgcache/LoadingPhaseRunnerTest.java | 3 +- .../build/lib/pkgcache/PackageCacheTest.java | 4 +- .../ContainingPackageLookupFunctionTest.java | 6 +- .../lib/skyframe/FilesetEntryFunctionTest.java | 6 +- .../build/lib/skyframe/GlobFunctionTest.java | 6 +- .../lib/skyframe/PackageLookupFunctionTest.java | 17 ++--- ...areDepsOfPatternsFunctionSmartNegationTest.java | 74 ++++++++++++++++++++-- .../RecursiveFilesystemTraversalFunctionTest.java | 6 +- 14 files changed, 104 insertions(+), 38 deletions(-) (limited to 'src/test/java/com/google') diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java index 5b81290312..282a3fa7e3 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java @@ -175,7 +175,8 @@ public abstract class AnalysisTestCase extends FoundationTestCase { ImmutableList.of(), analysisMock.getSkyFunctions(directories), ImmutableList.of(), - PathFragment.EMPTY_FRAGMENT, + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index efdd13dcd7..764b382f1e 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -242,7 +242,8 @@ public abstract class BuildViewTestCase extends FoundationTestCase { ImmutableList.of(), analysisMock.getSkyFunctions(directories), ImmutableList.of(), - PathFragment.EMPTY_FRAGMENT, + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java index 0e94a10d2e..c142337717 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java @@ -126,7 +126,8 @@ public abstract class ConfigurationTestCase extends FoundationTestCase { ImmutableList.of(), analysisMock.getSkyFunctions(directories), ImmutableList.of(), - PathFragment.EMPTY_FRAGMENT, + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java index 3f199e9fe9..af481f8db7 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java @@ -46,7 +46,6 @@ import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.build.lib.testutil.TestRuleClassProvider; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; import com.google.devtools.build.lib.vfs.ModifiedFileSet; -import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyFunctionName; import com.google.devtools.common.options.Options; @@ -121,7 +120,8 @@ public abstract class PackageLoadingTestCase extends FoundationTestCase { ImmutableList.of(), ImmutableMap.of(), ImmutableList.of(), - PathFragment.EMPTY_FRAGMENT, + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java index 22a55ec1ff..7ebb3c2cb1 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java @@ -40,7 +40,6 @@ import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.ModifiedFileSet; import com.google.devtools.build.lib.vfs.Path; -import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem; import com.google.devtools.common.options.OptionsParser; import java.nio.charset.StandardCharsets; @@ -91,7 +90,8 @@ public class BuildFileModificationTest extends FoundationTestCase { ImmutableList.of(), analysisMock.getSkyFunctions(directories), ImmutableList.of(), - PathFragment.EMPTY_FRAGMENT, + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java index 49e5be4013..f78e49e3f5 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java @@ -482,7 +482,8 @@ public class IncrementalLoadingTest { ImmutableList.of(new ManualDiffAwarenessFactory()), ImmutableMap.of(), ImmutableList.of(), - PathFragment.EMPTY_FRAGMENT, + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java index a368664094..3a4943a8c9 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java @@ -630,7 +630,8 @@ public class LoadingPhaseRunnerTest { ImmutableList.of(), analysisMock.getSkyFunctions(directories), ImmutableList.of(), - PathFragment.EMPTY_FRAGMENT, + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java index 22f71b573b..8fd9d55c8e 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java @@ -48,7 +48,6 @@ import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; import com.google.devtools.build.lib.vfs.ModifiedFileSet; import com.google.devtools.build.lib.vfs.Path; -import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.InvocationPolicyEnforcer; import com.google.devtools.common.options.OptionsParser; import com.google.devtools.common.options.OptionsParsingException; @@ -100,7 +99,8 @@ public class PackageCacheTest extends FoundationTestCase { ImmutableList.of(), analysisMock.getSkyFunctions(directories), ImmutableList.of(), - PathFragment.EMPTY_FRAGMENT, + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java index b2a28a0a2f..0728c5425e 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java @@ -103,7 +103,9 @@ public class ContainingPackageLookupFunctionTest extends FoundationTestCase { skyFunctions.put( SkyFunctions.PACKAGE, new PackageFunction(null, null, null, null, null, null, null)); skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, - new BlacklistedPackagePrefixesFunction()); + new BlacklistedPackagePrefixesFunction( + /*hardcodedBlacklistedPackagePrefixes=*/ ImmutableSet.of(), + /*additionalBlacklistedPackagePrefixesFile=*/ PathFragment.EMPTY_FRAGMENT)); skyFunctions.put(SkyFunctions.FILE_STATE, new FileStateFunction( new AtomicReference(), externalFilesHelper)); skyFunctions.put(SkyFunctions.FILE, new FileFunction(pkgLocator)); @@ -141,8 +143,6 @@ public class ContainingPackageLookupFunctionTest extends FoundationTestCase { evaluator = new InMemoryMemoizingEvaluator(skyFunctions, differencer); driver = new SequentialBuildDriver(evaluator); PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID()); - PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set(differencer, - PathFragment.EMPTY_FRAGMENT); PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get()); PrecomputedValue.SKYLARK_SEMANTICS.set(differencer, SkylarkSemantics.DEFAULT_SEMANTICS); RepositoryDelegatorFunction.REPOSITORY_OVERRIDES.set( diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java index 301fa746c0..90ed181ad2 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java @@ -115,7 +115,9 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase { CrossRepositoryLabelViolationStrategy.ERROR, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY)); skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, - new BlacklistedPackagePrefixesFunction()); + new BlacklistedPackagePrefixesFunction( + /*hardcodedBlacklistedPackagePrefixes=*/ ImmutableSet.of(), + /*additionalBlacklistedPackagePrefixesFile=*/ PathFragment.EMPTY_FRAGMENT)); skyFunctions.put(SkyFunctions.FILESET_ENTRY, new FilesetEntryFunction()); skyFunctions.put(SkyFunctions.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction()); @@ -124,8 +126,6 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase { driver = new SequentialBuildDriver(evaluator); PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID()); PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get()); - PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set(differencer, - PathFragment.EMPTY_FRAGMENT); } private Artifact getSourceArtifact(String path) throws Exception { diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java index 660d89595f..13acf704e9 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java @@ -122,8 +122,6 @@ public abstract class GlobFunctionTest { driver = new SequentialBuildDriver(evaluator); PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID()); PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get()); - PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set( - differencer, PathFragment.EMPTY_FRAGMENT); PrecomputedValue.SKYLARK_SEMANTICS.set(differencer, SkylarkSemantics.DEFAULT_SEMANTICS); createTestFiles(); @@ -153,7 +151,9 @@ public abstract class GlobFunctionTest { CrossRepositoryLabelViolationStrategy.ERROR, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY)); skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, - new BlacklistedPackagePrefixesFunction()); + new BlacklistedPackagePrefixesFunction( + /*hardcodedBlacklistedPackagePrefixes=*/ ImmutableSet.of(), + /*additionalBlacklistedPackagePrefixesFile=*/ PathFragment.EMPTY_FRAGMENT)); skyFunctions.put( SkyFunctions.FILE_STATE, new FileStateFunction( diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java index a90119ce5a..d9a3f5a701 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java @@ -79,6 +79,8 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { private SequentialBuildDriver driver; private RecordingDifferencer differencer; private Path emptyPackagePath; + private static final String ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING = + "config/blacklisted.txt"; protected abstract CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy(); @@ -121,7 +123,9 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { SkyFunctions.DIRECTORY_LISTING_STATE, new DirectoryListingStateFunction(externalFilesHelper)); skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, - new BlacklistedPackagePrefixesFunction()); + new BlacklistedPackagePrefixesFunction( + /*hardcodedBlacklistedPackagePrefixes=*/ ImmutableSet.of(), + PathFragment.create(ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING))); RuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider(); skyFunctions.put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(ruleClassProvider)); skyFunctions.put( @@ -153,8 +157,6 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { evaluator = new InMemoryMemoizingEvaluator(skyFunctions, differencer); driver = new SequentialBuildDriver(evaluator); PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID()); - PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set( - differencer, PathFragment.EMPTY_FRAGMENT); PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get()); PrecomputedValue.SKYLARK_SEMANTICS.set(differencer, SkylarkSemantics.DEFAULT_SEMANTICS); RepositoryDelegatorFunction.REPOSITORY_OVERRIDES.set( @@ -209,14 +211,12 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { assertThat(packageLookupValue.getErrorMsg()).isNotNull(); } - @Test public void testBlacklistedPackage() throws Exception { scratch.file("blacklisted/subdir/BUILD"); scratch.file("blacklisted/BUILD"); - PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set(differencer, - PathFragment.create("config/blacklisted.txt")); - Path blacklist = scratch.file("config/blacklisted.txt", "blacklisted"); + Path blacklist = scratch.overwriteFile( + ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING, "blacklisted"); ImmutableSet pkgs = ImmutableSet.of("blacklisted/subdir", "blacklisted"); for (String pkg : pkgs) { @@ -226,7 +226,8 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { assertThat(packageLookupValue.getErrorMsg()).isNotNull(); } - scratch.overwriteFile("config/blacklisted.txt", "not_blacklisted"); + scratch.overwriteFile( + ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING, "not_blacklisted"); RootedPath rootedBlacklist = RootedPath.toRootedPath( blacklist.getParentDirectory().getParentDirectory(), PathFragment.create("config/blacklisted.txt")); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java index bbf9f945d9..2f43b7c083 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java @@ -18,24 +18,42 @@ import static com.google.devtools.build.skyframe.WalkableGraphUtils.exists; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.eventbus.EventBus; -import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; +import com.google.devtools.build.lib.actions.ActionKeyContext; +import com.google.devtools.build.lib.analysis.BlazeDirectories; +import com.google.devtools.build.lib.analysis.ServerDirectories; +import com.google.devtools.build.lib.analysis.util.AnalysisMock; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.PackageIdentifier; +import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.events.Reporter; +import com.google.devtools.build.lib.packages.SkylarkSemanticsOptions; +import com.google.devtools.build.lib.pkgcache.PackageCacheOptions; +import com.google.devtools.build.lib.pkgcache.PathPackageLocator; +import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction; +import com.google.devtools.build.lib.testutil.FoundationTestCase; +import com.google.devtools.build.lib.testutil.TestConstants; +import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.skyframe.EvaluationResult; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; import com.google.devtools.build.skyframe.WalkableGraph; +import com.google.devtools.common.options.Options; import java.io.IOException; +import java.util.UUID; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; /** Tests for {@link PrepareDepsOfPatternsFunction}. */ @RunWith(JUnit4.class) -public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTestCase { +public class PrepareDepsOfPatternsFunctionSmartNegationTest extends FoundationTestCase { + private SkyframeExecutor skyframeExecutor; + private static final String ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING = + "config/blacklist.txt"; private static SkyKey getKeyForLabel(Label label) { // Note that these tests used to look for TargetMarker SkyKeys before TargetMarker was @@ -44,6 +62,50 @@ public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTes return TransitiveTraversalValue.key(label); } + @Before + public void setUp() throws Exception { + BlazeDirectories directories = + new BlazeDirectories( + new ServerDirectories(getScratch().dir("/install"), getScratch().dir("/output")), + rootDirectory, + AnalysisMock.get().getProductName()); + skyframeExecutor = + SequencedSkyframeExecutor.create( + AnalysisMock.get() + .getPackageFactoryBuilderForTesting(directories) + .build(AnalysisMock.get().createRuleClassProvider(), fileSystem), + fileSystem, + directories, + new ActionKeyContext(), + /*workspaceStatusActionFactory=*/ null, + AnalysisMock.get().createRuleClassProvider().getBuildInfoFactories(), + ImmutableList.of(), + AnalysisMock.get().getSkyFunctions(directories), + ImmutableList.of(), + BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, + PathFragment.create(ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING), + BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, + BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, + BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE); + TestConstants.processSkyframeExecutorForTesting(skyframeExecutor); + skyframeExecutor.preparePackageLoading( + new PathPackageLocator( + outputBase, + ImmutableList.of(rootDirectory), + BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY), + Options.getDefaults(PackageCacheOptions.class), + Options.getDefaults(SkylarkSemanticsOptions.class), + AnalysisMock.get().getDefaultsPackageContent(), + UUID.randomUUID(), + ImmutableMap.of(), + ImmutableMap.of(), + new TimestampGranularityMonitor(null)); + skyframeExecutor.injectExtraPrecomputedValues(ImmutableList.of(PrecomputedValue.injected( + RepositoryDelegatorFunction.REPOSITORY_OVERRIDES, + ImmutableMap.of()))); + scratch.file(ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING); + } + @Test public void testRecursiveEvaluationFailsOnBadBuildFile() throws Exception { // Given a well-formed package "@//foo" and a malformed package "@//foo/foo", @@ -89,9 +151,7 @@ public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTes ImmutableList patternSequence = ImmutableList.of("//foo/..."); // and a blacklist for the malformed package, - getSkyframeExecutor().setBlacklistedPackagePrefixesFile( - PathFragment.create("config/blacklist.txt")); - scratch.file("config/blacklist.txt", "foo/foo"); + scratch.overwriteFile(ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING, "foo/foo"); assertSkipsFoo(patternSequence); } @@ -140,12 +200,12 @@ public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTes // When PrepareDepsOfPatternsFunction completes evaluation, EvaluationResult evaluationResult = - getSkyframeExecutor() + skyframeExecutor .getDriverForTesting() .evaluate( singletonTargetPattern, keepGoing, - LOADING_PHASE_THREADS, + /*numThreads=*/ 100, new Reporter(new EventBus(), eventCollector)); // The evaluation has no errors if success was expected. assertThat(evaluationResult.hasError()).isNotEqualTo(successExpected); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java index c6b946f4a3..bb54b99d19 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java @@ -119,7 +119,9 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe CrossRepositoryLabelViolationStrategy.ERROR, BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY)); skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, - new BlacklistedPackagePrefixesFunction()); + new BlacklistedPackagePrefixesFunction( + /*hardcodedBlacklistedPackagePrefixes=*/ ImmutableSet.of(), + /*additionalBlacklistedPackagePrefixesFile=*/ PathFragment.EMPTY_FRAGMENT)); skyFunctions.put(SkyFunctions.PACKAGE, new PackageFunction(null, null, null, null, null, null, null)); skyFunctions.put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(ruleClassProvider)); @@ -145,8 +147,6 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe driver = new SequentialBuildDriver(evaluator); PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID()); PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get()); - PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set( - differencer, PathFragment.EMPTY_FRAGMENT); } private Artifact sourceArtifact(String path) { -- cgit v1.2.3