aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2017-05-02 17:09:24 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-05-03 10:55:25 +0200
commit59b099b2a7868a0516c54f38f59e89fef8704473 (patch)
treed668d2a38f2d77b56e1950f67b47edf73847feaa /src/test
parentc2cb0342e12897380d4afa5b2688355fa1b7c60a (diff)
Handle null action inputs in TreeNodeRepository
The SpawnInputExpander can return null action inputs to indicate that we should create an empty file at the corresponding location, without a corresponding input file. PiperOrigin-RevId: 154832564
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/remote/TreeNodeRepositoryTest.java28
-rwxr-xr-xsrc/test/shell/bazel/remote_execution_test.sh23
2 files changed, 51 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/remote/TreeNodeRepositoryTest.java b/src/test/java/com/google/devtools/build/lib/remote/TreeNodeRepositoryTest.java
index db4e55dae1..4bb8883269 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/TreeNodeRepositoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/remote/TreeNodeRepositoryTest.java
@@ -29,7 +29,10 @@ import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystem.HashFunction;
import com.google.devtools.build.lib.vfs.Path;
+import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.ArrayList;
+import java.util.SortedMap;
+import java.util.TreeMap;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -124,4 +127,29 @@ public class TreeNodeRepositoryTest {
// Reusing same node for the "foo" subtree: only need the root, root child, foo, and contents:
assertThat(repo.getAllDigests(root)).hasSize(4);
}
+
+ @Test
+ public void testNullArtifacts() throws Exception {
+ Artifact foo = new Artifact(scratch.file("/exec/root/a/foo", "1"), rootDir);
+ SortedMap<PathFragment, ActionInput> inputs = new TreeMap<>();
+ inputs.put(foo.getExecPath(), foo);
+ inputs.put(PathFragment.create("a/bar"), null);
+ TreeNodeRepository repo = createTestTreeNodeRepository();
+ TreeNode root = repo.buildFromActionInputs(inputs);
+ repo.computeMerkleDigests(root);
+
+ TreeNode aNode = root.getChildEntries().get(0).getChild();
+ TreeNode fooNode = aNode.getChildEntries().get(1).getChild(); // foo > bar in sort order!
+ TreeNode barNode = aNode.getChildEntries().get(0).getChild();
+ ImmutableCollection<ContentDigest> digests = repo.getAllDigests(root);
+ ContentDigest rootDigest = repo.getMerkleDigest(root);
+ ContentDigest aDigest = repo.getMerkleDigest(aNode);
+ ContentDigest fooDigest = repo.getMerkleDigest(fooNode);
+ ContentDigest fooContentsDigest = ContentDigests.computeDigest(foo.getPath());
+ ContentDigest barDigest = repo.getMerkleDigest(barNode);
+ ContentDigest barContentsDigest = ContentDigests.computeDigest(new byte[0]);
+ assertThat(digests)
+ .containsExactly(
+ rootDigest, aDigest, barDigest, barContentsDigest, fooDigest, fooContentsDigest);
+ }
}
diff --git a/src/test/shell/bazel/remote_execution_test.sh b/src/test/shell/bazel/remote_execution_test.sh
index f3514d2593..66a99a6654 100755
--- a/src/test/shell/bazel/remote_execution_test.sh
+++ b/src/test/shell/bazel/remote_execution_test.sh
@@ -189,6 +189,29 @@ EOF
|| fail "Remote cache generated different result"
}
+function test_py_test() {
+ mkdir -p a
+ cat > a/BUILD <<EOF
+package(default_visibility = ["//visibility:public"])
+py_test(
+name = 'test',
+srcs = [ 'test.py' ],
+)
+EOF
+ cat > a/test.py <<EOF
+import sys
+if __name__ == "__main__":
+ sys.exit(0)
+EOF
+ bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 test \
+ --spawn_strategy=remote \
+ --remote_worker=localhost:${worker_port} \
+ --remote_cache=localhost:${worker_port} \
+ --test_output=errors \
+ //a:test >& $TEST_log \
+ || fail "Failed to run //a:test with remote execution"
+}
+
# TODO(alpha): Add a test that fails remote execution when remote worker
# supports sandbox.