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());
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FileFunctionTest method testFilesOutsideRootIsReEvaluated.
@Test
public void testFilesOutsideRootIsReEvaluated() throws Exception {
Path file = file("/outsideroot");
SequentialBuildDriver driver = makeDriver();
SkyKey key = skyKey("/outsideroot");
EvaluationResult<SkyValue> result;
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 oldValue = (FileValue) result.get(key);
assertTrue(oldValue.exists());
file.delete();
differencer.invalidate(ImmutableList.of(fileStateSkyKey("/outsideroot")));
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 newValue = (FileValue) result.get(key);
assertNotSame(oldValue, newValue);
assertFalse(newValue.exists());
}
use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class MavenServerFunction method getDefaultSettingsFile.
private Map<String, FileValue> getDefaultSettingsFile(BlazeDirectories directories, Environment env) throws InterruptedException {
// The system settings file is at $M2_HOME/conf/settings.xml.
String m2Home = System.getenv("M2_HOME");
ImmutableList.Builder<SkyKey> settingsFilesBuilder = ImmutableList.builder();
SkyKey systemKey = null;
if (m2Home != null) {
PathFragment mavenInstallSettings = new PathFragment(m2Home).getRelative("conf/settings.xml");
systemKey = FileValue.key(RootedPath.toRootedPath(directories.getWorkspace().getRelative(mavenInstallSettings), PathFragment.EMPTY_FRAGMENT));
settingsFilesBuilder.add(systemKey);
}
// The user settings file is at $HOME/.m2/settings.xml.
String userHome = System.getenv("HOME");
SkyKey userKey = null;
if (userHome != null) {
PathFragment userSettings = new PathFragment(userHome).getRelative(".m2/settings.xml");
userKey = FileValue.key(RootedPath.toRootedPath(directories.getWorkspace().getRelative(userSettings), PathFragment.EMPTY_FRAGMENT));
settingsFilesBuilder.add(userKey);
}
ImmutableList<SkyKey> settingsFiles = settingsFilesBuilder.build();
if (settingsFiles.isEmpty()) {
return ImmutableMap.of();
}
Map<SkyKey, SkyValue> values = env.getValues(settingsFiles);
ImmutableMap.Builder<String, FileValue> settingsBuilder = ImmutableMap.builder();
for (Map.Entry<SkyKey, SkyValue> entry : values.entrySet()) {
if (entry.getValue() == null) {
return null;
}
if (systemKey != null && systemKey.equals(entry.getKey())) {
settingsBuilder.put(SYSTEM_KEY, (FileValue) entry.getValue());
} else if (userKey != null && userKey.equals(entry.getKey())) {
settingsBuilder.put(USER_KEY, (FileValue) entry.getValue());
}
}
return settingsBuilder.build();
}
Aggregations