use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FilesetEntryFunctionTest method assertRecursiveTraversalForPackage.
private void assertRecursiveTraversalForPackage(SymlinkBehavior symlinks, PackageBoundaryMode pkgBoundaryMode) throws Exception {
Artifact buildFile = createSourceArtifact("foo/BUILD");
Artifact subpkgBuildFile = createSourceArtifact("foo/subpkg/BUILD");
Artifact subpkgSymlink = getSourceArtifact("foo/subpkg_sym");
RootedPath fileA = createFile(siblingOf(buildFile, "file.a"), "blah");
RootedPath fileAsym = siblingOf(buildFile, "subdir/file.a.sym");
RootedPath fileB = createFile(siblingOf(subpkgBuildFile, "file.b"), "blah");
scratch.dir(fileAsym.asPath().getParentDirectory().getPathString());
fileAsym.asPath().createSymbolicLink(new PathFragment("../file.a"));
subpkgSymlink.getPath().createSymbolicLink(new PathFragment("subpkg"));
FilesetOutputSymlink outBuild = symlink("output-name/BUILD", buildFile);
FilesetOutputSymlink outA = symlink("output-name/file.a", fileA);
FilesetOutputSymlink outAsym = null;
FilesetOutputSymlink outSubpkgBuild = symlink("output-name/subpkg/BUILD", subpkgBuildFile);
FilesetOutputSymlink outSubpkgB = symlink("output-name/subpkg/file.b", fileB);
FilesetOutputSymlink outSubpkgSymBuild;
switch(symlinks) {
case COPY:
outAsym = symlink("output-name/subdir/file.a.sym", "../file.a");
outSubpkgSymBuild = symlink("output-name/subpkg_sym", "subpkg");
break;
case DEREFERENCE:
outAsym = symlink("output-name/subdir/file.a.sym", fileA);
outSubpkgSymBuild = symlink("output-name/subpkg_sym", getSourceArtifact("foo/subpkg"));
break;
default:
throw new IllegalStateException(symlinks.toString());
}
FilesetTraversalParams params = FilesetTraversalParamsFactory.recursiveTraversalOfPackage(/*ownerLabel=*/
label("//foo"), /*directoryToTraverse=*/
buildFile, /*destPath=*/
new PathFragment("output-name"), /*excludes=*/
null, /*symlinkBehaviorMode=*/
symlinks, /*pkgBoundaryMode=*/
pkgBoundaryMode);
switch(pkgBoundaryMode) {
case CROSS:
assertSymlinksInOrder(params, outBuild, outA, outSubpkgSymBuild, outAsym, outSubpkgBuild, outSubpkgB);
break;
case DONT_CROSS:
assertSymlinksInOrder(params, outBuild, outA, outAsym);
break;
case REPORT_ERROR:
SkyKey key = FilesetEntryValue.key(params);
EvaluationResult<SkyValue> result = eval(key);
assertThat(result.hasError()).isTrue();
assertThat(result.getError(key).getException().getMessage()).contains("'foo' crosses package boundary into package rooted at foo/subpkg");
break;
default:
throw new IllegalStateException(pkgBoundaryMode.toString());
}
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FilesystemValueCheckerTest method testSimple.
@Test
public void testSimple() throws Exception {
FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Path path = fs.getPath("/foo");
FileSystemUtils.createEmptyFile(path);
assertEmptyDiff(getDirtyFilesystemKeys(evaluator, checker));
SkyKey skyKey = FileStateValue.key(RootedPath.toRootedPath(fs.getRootDirectory(), new PathFragment("foo")));
EvaluationResult<SkyValue> result = driver.evaluate(ImmutableList.of(skyKey), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertFalse(result.hasError());
assertEmptyDiff(getDirtyFilesystemKeys(evaluator, checker));
FileSystemUtils.writeContentAsLatin1(path, "hello");
assertDiffWithNewValues(getDirtyFilesystemKeys(evaluator, checker), skyKey);
// The dirty bits are not reset until the FileValues are actually revalidated.
assertDiffWithNewValues(getDirtyFilesystemKeys(evaluator, checker), skyKey);
differencer.invalidate(ImmutableList.of(skyKey));
result = driver.evaluate(ImmutableList.of(skyKey), false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
assertFalse(result.hasError());
assertEmptyDiff(getDirtyFilesystemKeys(evaluator, checker));
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class ArtifactFunctionTest method testMiddlemanArtifact.
@Test
public void testMiddlemanArtifact() throws Throwable {
Artifact output = createDerivedArtifact("output");
Artifact input1 = createSourceArtifact("input1");
Artifact input2 = createDerivedArtifact("input2");
Action action = new DummyAction(ImmutableList.of(input1, input2), output, MiddlemanType.AGGREGATING_MIDDLEMAN);
// Overwrite default generating action with this one.
for (Iterator<ActionAnalysisMetadata> it = actions.iterator(); it.hasNext(); ) {
if (it.next().getOutputs().contains(output)) {
it.remove();
break;
}
}
actions.add(action);
file(input2.getPath(), "contents");
file(input1.getPath(), "source contents");
evaluate(Iterables.toArray(ArtifactSkyKey.mandatoryKeys(ImmutableSet.of(input2, input1, input2)), SkyKey.class));
SkyValue value = evaluateArtifactValue(output);
assertThat(((AggregatingArtifactValue) value).getInputs()).containsExactly(Pair.of(input1, create(input1)), Pair.of(input2, create(input2)));
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class ConfigurationsForTargetsTest method getConfiguredDeps.
/**
* Returns the configured deps for a given target, assuming the target uses the target
* configuration.
*/
private Multimap<Attribute, ConfiguredTarget> getConfiguredDeps(String targetLabel) throws Exception {
update(targetLabel);
SkyKey key = ComputeDependenciesFunction.key(getTarget(targetLabel), getTargetConfiguration());
// Must re-enable analysis for Skyframe functions that create configured targets.
skyframeExecutor.getSkyframeBuildView().enableAnalysis(true);
Object evalResult = SkyframeExecutorTestUtils.evaluate(skyframeExecutor, key, /*keepGoing=*/
false, reporter);
skyframeExecutor.getSkyframeBuildView().enableAnalysis(false);
SkyValue value = ((EvaluationResult<ComputeDependenciesFunction.Value>) evalResult).get(key);
return ((ComputeDependenciesFunction.Value) value).depMap;
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FileFunctionTest method testRelativeSymlinksToFilesOutsideRootWhenExternalAssumedNonExistentAndImmutable.
@Test
public void testRelativeSymlinksToFilesOutsideRootWhenExternalAssumedNonExistentAndImmutable() throws Exception {
file("../outsideroot");
symlink("a", "../outsideroot");
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();
assertFalse(value.exists());
}
Aggregations