Search in sources :

Example 21 with SequentialBuildDriver

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

the class FileFunctionTest method assertRealPath.

private void assertRealPath(String pathString, String expectedRealPathString) throws Exception {
    SequentialBuildDriver driver = makeDriver();
    SkyKey key = skyKey(pathString);
    EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(key), false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
    if (result.hasError()) {
        fail(String.format("Evaluation error for %s: %s", key, result.getError()));
    }
    FileValue fileValue = (FileValue) result.get(key);
    assertEquals(pkgRoot.getRelative(expectedRealPathString).toString(), fileValue.realRootedPath().asPath().toString());
}
Also used : SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue)

Example 22 with SequentialBuildDriver

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

the class ContainingPackageLookupFunctionTest method setUp.

@Before
public final void setUp() throws Exception {
    AtomicReference<PathPackageLocator> pkgLocator = new AtomicReference<>(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)));
    deletedPackages = new AtomicReference<>(ImmutableSet.<PackageIdentifier>of());
    ExternalFilesHelper externalFilesHelper = new ExternalFilesHelper(pkgLocator, ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS, new BlazeDirectories(rootDirectory, rootDirectory, rootDirectory, TestConstants.PRODUCT_NAME));
    Map<SkyFunctionName, SkyFunction> skyFunctions = new HashMap<>();
    skyFunctions.put(SkyFunctions.PACKAGE_LOOKUP, new PackageLookupFunction(deletedPackages, CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD)));
    skyFunctions.put(SkyFunctions.CONTAINING_PACKAGE_LOOKUP, new ContainingPackageLookupFunction());
    skyFunctions.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, new BlacklistedPackagePrefixesFunction());
    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.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction());
    RecordingDifferencer 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) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) Before(org.junit.Before)

Example 23 with SequentialBuildDriver

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

the class ActionTemplateExpansionFunctionTest method setUp.

@Before
public void setUp() throws Exception {
    artifactValueMap = new LinkedHashMap<>();
    AtomicReference<PathPackageLocator> pkgLocator = new AtomicReference<>(new PathPackageLocator(rootDirectory.getFileSystem().getPath("/outputbase"), ImmutableList.of(rootDirectory)));
    RecordingDifferencer differencer = new RecordingDifferencer();
    MemoizingEvaluator evaluator = new InMemoryMemoizingEvaluator(ImmutableMap.<SkyFunctionName, SkyFunction>builder().put(SkyFunctions.ARTIFACT, new DummyArtifactFunction(artifactValueMap)).put(SkyFunctions.ACTION_TEMPLATE_EXPANSION, new ActionTemplateExpansionFunction()).build(), differencer);
    driver = new SequentialBuildDriver(evaluator);
    PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID());
    PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get());
}
Also used : PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyFunctionName(com.google.devtools.build.skyframe.SkyFunctionName) InMemoryMemoizingEvaluator(com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator) SkyFunction(com.google.devtools.build.skyframe.SkyFunction) InMemoryMemoizingEvaluator(com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator) MemoizingEvaluator(com.google.devtools.build.skyframe.MemoizingEvaluator) AtomicReference(java.util.concurrent.atomic.AtomicReference) Before(org.junit.Before)

Example 24 with SequentialBuildDriver

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

the class ArtifactFunctionTestCase method baseSetUp.

@Before
public void baseSetUp() throws Exception {
    setupRoot(new CustomInMemoryFs());
    AtomicReference<PathPackageLocator> pkgLocator = new AtomicReference<>(new PathPackageLocator(root.getFileSystem().getPath("/outputbase"), ImmutableList.of(root)));
    BlazeDirectories directories = new BlazeDirectories(root, root, root, TestConstants.PRODUCT_NAME);
    ExternalFilesHelper externalFilesHelper = new ExternalFilesHelper(pkgLocator, ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS, directories);
    differencer = new RecordingDifferencer();
    evaluator = new InMemoryMemoizingEvaluator(ImmutableMap.<SkyFunctionName, SkyFunction>builder().put(SkyFunctions.FILE_STATE, new FileStateFunction(new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper)).put(SkyFunctions.FILE, new FileFunction(pkgLocator)).put(SkyFunctions.ARTIFACT, new ArtifactFunction(allowedMissingInputsPredicate)).put(SkyFunctions.ACTION_EXECUTION, new SimpleActionExecutionFunction()).put(SkyFunctions.PACKAGE, new PackageFunction(null, null, null, null, null, null, null)).put(SkyFunctions.PACKAGE_LOOKUP, new PackageLookupFunction(null, CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD))).put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(TestRuleClassProvider.getRuleClassProvider())).put(SkyFunctions.WORKSPACE_FILE, new WorkspaceFileFunction(TestRuleClassProvider.getRuleClassProvider(), TestConstants.PACKAGE_FACTORY_FACTORY_FOR_TESTING.create(TestRuleClassProvider.getRuleClassProvider(), root.getFileSystem()), directories)).put(SkyFunctions.EXTERNAL_PACKAGE, new ExternalPackageFunction()).put(SkyFunctions.ACTION_TEMPLATE_EXPANSION, new ActionTemplateExpansionFunction()).build(), differencer);
    driver = new SequentialBuildDriver(evaluator);
    PrecomputedValue.BUILD_ID.set(differencer, UUID.randomUUID());
    PrecomputedValue.PATH_PACKAGE_LOCATOR.set(differencer, pkgLocator.get());
    actions = new HashSet<>();
}
Also used : RecordingDifferencer(com.google.devtools.build.skyframe.RecordingDifferencer) InMemoryMemoizingEvaluator(com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator) 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) Before(org.junit.Before)

Example 25 with SequentialBuildDriver

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

the class FileFunctionTest method runTestInfiniteSymlinkExpansion.

private void runTestInfiniteSymlinkExpansion(boolean symlinkToAncestor, boolean absoluteSymlink) throws Exception {
    Path otherPath = path("other");
    RootedPath otherRootedPath = RootedPath.toRootedPath(pkgRoot, otherPath.relativeTo(pkgRoot));
    Path ancestorPath = path("a");
    RootedPath ancestorRootedPath = RootedPath.toRootedPath(pkgRoot, ancestorPath.relativeTo(pkgRoot));
    FileSystemUtils.ensureSymbolicLink(otherPath, ancestorPath);
    Path intermediatePath = path("inter");
    RootedPath intermediateRootedPath = RootedPath.toRootedPath(pkgRoot, intermediatePath.relativeTo(pkgRoot));
    Path descendantPath = path("a/b/c/d/e");
    RootedPath descendantRootedPath = RootedPath.toRootedPath(pkgRoot, descendantPath.relativeTo(pkgRoot));
    if (symlinkToAncestor) {
        FileSystemUtils.ensureSymbolicLink(descendantPath, intermediatePath);
        if (absoluteSymlink) {
            FileSystemUtils.ensureSymbolicLink(intermediatePath, ancestorPath);
        } else {
            FileSystemUtils.ensureSymbolicLink(intermediatePath, ancestorRootedPath.getRelativePath());
        }
    } else {
        FileSystemUtils.ensureSymbolicLink(ancestorPath, intermediatePath);
        if (absoluteSymlink) {
            FileSystemUtils.ensureSymbolicLink(intermediatePath, descendantPath);
        } else {
            FileSystemUtils.ensureSymbolicLink(intermediatePath, descendantRootedPath.getRelativePath());
        }
    }
    StoredEventHandler eventHandler = new StoredEventHandler();
    SequentialBuildDriver driver = makeDriver();
    SkyKey ancestorPathKey = FileValue.key(ancestorRootedPath);
    SkyKey descendantPathKey = FileValue.key(descendantRootedPath);
    SkyKey otherPathKey = FileValue.key(otherRootedPath);
    ImmutableList<SkyKey> keys;
    ImmutableList<SkyKey> errorKeys;
    ImmutableList<RootedPath> expectedChain;
    if (symlinkToAncestor) {
        keys = ImmutableList.of(descendantPathKey, otherPathKey);
        errorKeys = ImmutableList.of(descendantPathKey);
        expectedChain = ImmutableList.of(descendantRootedPath, intermediateRootedPath, ancestorRootedPath);
    } else {
        keys = ImmutableList.of(ancestorPathKey, otherPathKey);
        errorKeys = keys;
        expectedChain = ImmutableList.of(ancestorRootedPath, intermediateRootedPath, descendantRootedPath);
    }
    EvaluationResult<FileValue> result = driver.evaluate(keys, /*keepGoing=*/
    true, DEFAULT_THREAD_COUNT, eventHandler);
    assertTrue(result.hasError());
    for (SkyKey key : errorKeys) {
        ErrorInfo errorInfo = result.getError(key);
        // FileFunction detects infinite symlink expansion explicitly.
        assertThat(errorInfo.getCycleInfo()).isEmpty();
        FileSymlinkInfiniteExpansionException fsiee = (FileSymlinkInfiniteExpansionException) errorInfo.getException();
        assertThat(fsiee.getMessage()).contains("Infinite symlink expansion");
        assertThat(fsiee.getChain()).containsExactlyElementsIn(expectedChain).inOrder();
    }
    // Check that the unique symlink expansion error was reported exactly once.
    assertThat(eventHandler.getEvents()).hasSize(1);
    assertThat(Iterables.getOnlyElement(eventHandler.getEvents()).getMessage()).contains("infinite symlink expansion detected");
}
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) StoredEventHandler(com.google.devtools.build.lib.events.StoredEventHandler) ErrorInfo(com.google.devtools.build.skyframe.ErrorInfo) RootedPath(com.google.devtools.build.lib.vfs.RootedPath)

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