use of com.google.devtools.build.skyframe.SkyValue in project bazel by bazelbuild.
the class FileFunctionTest method assertChangesIfChanges.
/**
* Asserts that if the contents of {@code changedPathString} changes, then the FileValue
* corresponding to {@code pathString} will change. Returns the paths of all files seen. Not meant
* to be called directly by tests.
*/
private Set<RootedPath> assertChangesIfChanges(String changedPathString, boolean isFile, boolean changes, String pathString) throws Exception {
SequentialBuildDriver driver = makeDriver();
SkyKey key = skyKey(pathString);
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()));
}
SkyValue oldValue = result.get(key);
Pair<ImmutableList<String>, Runnable> changeResult = change(changedPathString, isFile);
ImmutableList<String> changedPathStrings = changeResult.first;
Runnable undoCallback = changeResult.second;
differencer.invalidate(Iterables.transform(changedPathStrings, new Function<String, SkyKey>() {
@Override
public SkyKey apply(String input) {
return fileStateSkyKey(input);
}
}));
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()));
}
SkyValue newValue = result.get(key);
assertTrue(String.format("Changing the contents of %s %s should%s change the value for file %s.", isFile ? "file" : "directory", changedPathString, changes ? "" : " not", pathString), changes != newValue.equals(oldValue));
// Restore the original file.
undoCallback.run();
return filesSeen(driver.getGraphForTesting());
}
Aggregations