Search in sources :

Example 1 with SequentialBuildDriver

use of com.google.devtools.build.skyframe.SequentialBuildDriver in project bazel by bazelbuild.

the class RecursiveFilesystemTraversalFunctionTest method setUp.

@Before
public final void setUp() throws Exception {
    AnalysisMock analysisMock = AnalysisMock.get();
    pkgLocator = new AtomicReference<>(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)));
    AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages = new AtomicReference<>(ImmutableSet.<PackageIdentifier>of());
    BlazeDirectories directories = new BlazeDirectories(rootDirectory, outputBase, rootDirectory, analysisMock.getProductName());
    ExternalFilesHelper externalFilesHelper = new ExternalFilesHelper(pkgLocator, ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS, directories);
    ConfiguredRuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider();
    Map<SkyFunctionName, SkyFunction> skyFunctions = new HashMap<>();
    skyFunctions.put(SkyFunctions.FILE_STATE, new FileStateFunction(new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper));
    skyFunctions.put(SkyFunctions.FILE, new FileFunction(pkgLocator));
    skyFunctions.put(SkyFunctions.DIRECTORY_LISTING, new DirectoryListingFunction());
    skyFunctions.put(SkyFunctions.DIRECTORY_LISTING_STATE, new DirectoryListingStateFunction(externalFilesHelper));
    skyFunctions.put(SkyFunctions.RECURSIVE_FILESYSTEM_TRAVERSAL, new RecursiveFilesystemTraversalFunction());
    skyFunctions.put(SkyFunctions.PACKAGE_LOOKUP, new PackageLookupFunction(deletedPackages, CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD)));
    skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, new BlacklistedPackagePrefixesFunction());
    skyFunctions.put(SkyFunctions.PACKAGE, new PackageFunction(null, null, null, null, null, null, null));
    skyFunctions.put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(ruleClassProvider));
    skyFunctions.put(SkyFunctions.WORKSPACE_FILE, new WorkspaceFileFunction(ruleClassProvider, analysisMock.getPackageFactoryForTesting().create(ruleClassProvider, scratch.getFileSystem()), directories));
    skyFunctions.put(SkyFunctions.EXTERNAL_PACKAGE, new ExternalPackageFunction());
    skyFunctions.put(SkyFunctions.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction());
    progressReceiver = new RecordingEvaluationProgressReceiver();
    differencer = new RecordingDifferencer();
    evaluator = new InMemoryMemoizingEvaluator(skyFunctions, differencer, progressReceiver);
    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);
}
Also used : RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) HashMap(java.util.HashMap) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyFunctionName(com.google.devtools.build.skyframe.SkyFunctionName) ImmutableSet(com.google.common.collect.ImmutableSet) SkyFunction(com.google.devtools.build.skyframe.SkyFunction) InMemoryMemoizingEvaluator(com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator) AtomicReference(java.util.concurrent.atomic.AtomicReference) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) AnalysisMock(com.google.devtools.build.lib.analysis.util.AnalysisMock) Before(org.junit.Before)

Example 2 with SequentialBuildDriver

use of com.google.devtools.build.skyframe.SequentialBuildDriver in project bazel by bazelbuild.

the class FileFunctionTest method testAbsoluteSymlinksBackIntoSourcesOkWhenExternalDisallowed.

@Test
public void testAbsoluteSymlinksBackIntoSourcesOkWhenExternalDisallowed() throws Exception {
    Path file = file("insideroot");
    symlink("a", file.getPathString());
    SequentialBuildDriver driver = makeDriver(ExternalFileAction.ASSUME_NON_EXISTENT_AND_IMMUTABLE_FOR_EXTERNAL_PATHS);
    SkyKey key = skyKey("a");
    EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(key), false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    assertThatEvaluationResult(result).hasNoError();
    FileValue value = (FileValue) result.get(key);
    assertThat(value).isNotNull();
    assertTrue(value.exists());
    assertThat(value.realRootedPath().getRelativePath().getPathString()).isEqualTo("insideroot");
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) Test(org.junit.Test)

Example 3 with SequentialBuildDriver

use of com.google.devtools.build.skyframe.SequentialBuildDriver in project bazel by bazelbuild.

the class FileFunctionTest method testAbsoluteSymlinksReferredByInternalFilesToFilesOutsideRootWhenExternalAssumedNonExistentAndImmutable.

@Test
public void testAbsoluteSymlinksReferredByInternalFilesToFilesOutsideRootWhenExternalAssumedNonExistentAndImmutable() throws Exception {
    file("/outsideroot/src/foo/bar");
    symlink("/root/src", "/outsideroot/src");
    SequentialBuildDriver driver = makeDriver(ExternalFileAction.ASSUME_NON_EXISTENT_AND_IMMUTABLE_FOR_EXTERNAL_PATHS);
    SkyKey key = skyKey("/root/src/foo/bar");
    EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(key), false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    assertThatEvaluationResult(result).hasNoError();
    FileValue value = (FileValue) result.get(key);
    assertThat(value).isNotNull();
    assertFalse(value.exists());
}
Also used : SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) Test(org.junit.Test)

Example 4 with SequentialBuildDriver

use of com.google.devtools.build.skyframe.SequentialBuildDriver in project bazel by bazelbuild.

the class FileFunctionTest method testFileStateEquality.

@Test
public void testFileStateEquality() throws Exception {
    file("a");
    symlink("b1", "a");
    symlink("b2", "a");
    symlink("b3", "zzz");
    directory("d1");
    directory("d2");
    SkyKey file = fileStateSkyKey("a");
    SkyKey symlink1 = fileStateSkyKey("b1");
    SkyKey symlink2 = fileStateSkyKey("b2");
    SkyKey symlink3 = fileStateSkyKey("b3");
    SkyKey missing1 = fileStateSkyKey("c1");
    SkyKey missing2 = fileStateSkyKey("c2");
    SkyKey directory1 = fileStateSkyKey("d1");
    SkyKey directory2 = fileStateSkyKey("d2");
    ImmutableList<SkyKey> keys = ImmutableList.of(file, symlink1, symlink2, symlink3, missing1, missing2, directory1, directory2);
    SequentialBuildDriver driver = makeDriver();
    EvaluationResult<SkyValue> result = driver.evaluate(keys, false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    new EqualsTester().addEqualityGroup(result.get(file)).addEqualityGroup(result.get(symlink1), result.get(symlink2)).addEqualityGroup(result.get(symlink3)).addEqualityGroup(result.get(missing1), result.get(missing2)).addEqualityGroup(result.get(directory1), result.get(directory2)).testEquals();
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyValue(com.google.devtools.build.skyframe.SkyValue) EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 5 with SequentialBuildDriver

use of com.google.devtools.build.skyframe.SequentialBuildDriver in project bazel by bazelbuild.

the class FilesetEntryFunctionTest method setUp.

@Before
public final void setUp() throws Exception {
    pkgLocator = new AtomicReference<>(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)));
    AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages = new AtomicReference<>(ImmutableSet.<PackageIdentifier>of());
    ExternalFilesHelper externalFilesHelper = new ExternalFilesHelper(pkgLocator, ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS, new BlazeDirectories(outputBase, outputBase, rootDirectory, TestConstants.PRODUCT_NAME));
    Map<SkyFunctionName, SkyFunction> skyFunctions = new HashMap<>();
    skyFunctions.put(SkyFunctions.FILE_STATE, new FileStateFunction(new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper));
    skyFunctions.put(SkyFunctions.FILE, new FileFunction(pkgLocator));
    skyFunctions.put(SkyFunctions.DIRECTORY_LISTING, new DirectoryListingFunction());
    skyFunctions.put(SkyFunctions.DIRECTORY_LISTING_STATE, new DirectoryListingStateFunction(externalFilesHelper));
    skyFunctions.put(SkyFunctions.RECURSIVE_FILESYSTEM_TRAVERSAL, new RecursiveFilesystemTraversalFunction());
    skyFunctions.put(SkyFunctions.PACKAGE_LOOKUP, new PackageLookupFunction(deletedPackages, CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD)));
    skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, new BlacklistedPackagePrefixesFunction());
    skyFunctions.put(SkyFunctions.FILESET_ENTRY, new FilesetEntryFunction());
    skyFunctions.put(SkyFunctions.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction());
    differencer = new RecordingDifferencer();
    evaluator = new InMemoryMemoizingEvaluator(skyFunctions, differencer);
    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);
}
Also used : RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) SkyFunction(com.google.devtools.build.skyframe.SkyFunction) InMemoryMemoizingEvaluator(com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) SkyFunctionName(com.google.devtools.build.skyframe.SkyFunctionName) ImmutableSet(com.google.common.collect.ImmutableSet) Before(org.junit.Before)

Aggregations

SequentialBuildDriver (com.google.devtools.build.skyframe.SequentialBuildDriver)28 SkyKey (com.google.devtools.build.skyframe.SkyKey)18 PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)11 InMemoryMemoizingEvaluator (com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator)11 RecordingDifferencer (com.google.devtools.build.skyframe.RecordingDifferencer)11 SkyFunction (com.google.devtools.build.skyframe.SkyFunction)10 SkyValue (com.google.devtools.build.skyframe.SkyValue)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)10 Test (org.junit.Test)10 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)9 SkyFunctionName (com.google.devtools.build.skyframe.SkyFunctionName)9 Before (org.junit.Before)9 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)6 ErrorInfo (com.google.devtools.build.skyframe.ErrorInfo)6 HashMap (java.util.HashMap)6 Path (com.google.devtools.build.lib.vfs.Path)5 ImmutableSet (com.google.common.collect.ImmutableSet)3 AnalysisMock (com.google.devtools.build.lib.analysis.util.AnalysisMock)3 PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)3 StoredEventHandler (com.google.devtools.build.lib.events.StoredEventHandler)3