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());
}
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);
}
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());
}
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<>();
}
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");
}
Aggregations