Skip to content

Commit

Permalink
Mark tool runfiles as such in expanded execution log
Browse files Browse the repository at this point in the history
The expanded execution log did not mark any runfiles as tools, but the (local and remote) worker implementations explicitly do check whether a runfiles middleman is a tool.

Also uses a previously unused test parameter in `testRunfileSymlinkFileWithDirectoryContents`.
  • Loading branch information
fmeum committed Sep 21, 2024
1 parent b084956 commit 20a32e9
Showing 1 changed file with 59 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public void testUnresolvedSymlinkInput(@TestParameter InputsMode inputsMode) thr
}

@Test
public void testRunfilesFileInput() throws Exception {
public void testRunfilesFileInput(@TestParameter InputsMode inputsMode) throws Exception {
Artifact runfilesInput = ActionsTestUtil.createArtifact(rootDir, "data.txt");
Artifact runfilesMiddleman = ActionsTestUtil.createArtifact(middlemanDir, "runfiles");

Expand All @@ -420,12 +420,15 @@ public void testRunfilesFileInput() throws Exception {
PathFragment runfilesRoot = outputDir.getExecPath().getRelative("foo.runfiles");
RunfilesTree runfilesTree = createRunfilesTree(runfilesRoot, runfilesInput);

Spawn spawn = defaultSpawnBuilder().withInput(runfilesMiddleman).build();
SpawnBuilder spawnBuilder = defaultSpawnBuilder().withInput(runfilesMiddleman);
if (inputsMode.isTool()) {
spawnBuilder.withTool(runfilesMiddleman);
}

SpawnLogContext context = createSpawnLogContext();

context.logSpawn(
spawn,
spawnBuilder.build(),
createInputMetadataProvider(runfilesMiddleman, runfilesTree, runfilesInput),
createInputMap(runfilesTree),
fs,
Expand All @@ -442,12 +445,15 @@ public void testRunfilesFileInput() throws Exception {
+ "-out/k8-fastbuild/bin/foo.runfiles/"
+ WORKSPACE_NAME
+ "/data.txt")
.setDigest(getDigest("abc")))
.setDigest(getDigest("abc"))
.setIsTool(inputsMode.isTool()))
.build());
}

@Test
public void testRunfilesDirectoryInput(@TestParameter DirContents dirContents) throws Exception {
public void testRunfilesDirectoryInput(
@TestParameter DirContents dirContents, @TestParameter InputsMode inputsMode)
throws Exception {
Artifact runfilesMiddleman = ActionsTestUtil.createArtifact(middlemanDir, "runfiles");
Artifact runfilesInput = ActionsTestUtil.createArtifact(rootDir, "dir");

Expand All @@ -459,12 +465,15 @@ public void testRunfilesDirectoryInput(@TestParameter DirContents dirContents) t
PathFragment runfilesRoot = outputDir.getExecPath().getRelative("foo.runfiles");
RunfilesTree runfilesTree = createRunfilesTree(runfilesRoot, runfilesInput);

Spawn spawn = defaultSpawnBuilder().withInput(runfilesMiddleman).build();
SpawnBuilder spawnBuilder = defaultSpawnBuilder().withInput(runfilesMiddleman);
if (inputsMode.isTool()) {
spawnBuilder.withTool(runfilesMiddleman);
}

SpawnLogContext context = createSpawnLogContext();

context.logSpawn(
spawn,
spawnBuilder.build(),
createInputMetadataProvider(runfilesMiddleman, runfilesTree, runfilesInput),
createInputMap(runfilesTree),
fs,
Expand All @@ -485,12 +494,13 @@ public void testRunfilesDirectoryInput(@TestParameter DirContents dirContents) t
+ WORKSPACE_NAME
+ "/dir/data.txt")
.setDigest(getDigest("abc"))
.setIsTool(inputsMode.isTool())
.build()))
.build());
}

@Test
public void testRunfilesEmptyInput() throws Exception {
public void testRunfilesEmptyInput(@TestParameter InputsMode inputsMode) throws Exception {
Artifact runfilesMiddleman = ActionsTestUtil.createArtifact(middlemanDir, "runfiles");

Artifact runfilesInput = ActionsTestUtil.createArtifact(rootDir, "sub/dir/script.py");
Expand Down Expand Up @@ -518,12 +528,15 @@ public void testRunfilesEmptyInput() throws Exception {
createRunfilesTree(
runfilesRoot, runfilesInput, externalGenArtifact, externalSourceArtifact);

Spawn spawn = defaultSpawnBuilder().withInput(runfilesMiddleman).build();
SpawnBuilder spawnBuilder = defaultSpawnBuilder().withInput(runfilesMiddleman);
if (inputsMode.isTool()) {
spawnBuilder.withTool(runfilesMiddleman);
}

SpawnLogContext context = createSpawnLogContext();

context.logSpawn(
spawn,
spawnBuilder.build(),
createInputMetadataProvider(
runfilesMiddleman,
runfilesTree,
Expand All @@ -540,59 +553,69 @@ public void testRunfilesEmptyInput() throws Exception {
defaultSpawnExecBuilder()
.addInputs(
File.newBuilder()
.setPath(PRODUCT_NAME + "-out/k8-fastbuild/bin/foo.runfiles/__init__.py"))
.setPath(PRODUCT_NAME + "-out/k8-fastbuild/bin/foo.runfiles/__init__.py")
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/foo.runfiles/"
+ WORKSPACE_NAME
+ "/sub/__init__.py"))
+ "/sub/__init__.py")
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/foo.runfiles/"
+ WORKSPACE_NAME
+ "/sub/dir/__init__.py"))
+ "/sub/dir/__init__.py")
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/foo.runfiles/"
+ WORKSPACE_NAME
+ "/sub/dir/script.py")
.setDigest(getDigest("abc")))
.setDigest(getDigest("abc"))
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME + "-out/k8-fastbuild/bin/foo.runfiles/some_repo/__init__.py"))
PRODUCT_NAME + "-out/k8-fastbuild/bin/foo.runfiles/some_repo/__init__.py")
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/foo.runfiles/some_repo/other/__init__.py"))
+ "-out/k8-fastbuild/bin/foo.runfiles/some_repo/other/__init__.py")
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/foo.runfiles/some_repo/other/pkg/__init__.py"))
+ "-out/k8-fastbuild/bin/foo.runfiles/some_repo/other/pkg/__init__.py")
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/foo.runfiles/some_repo/other/pkg/gen.py")
.setDigest(getDigest("external_gen")))
.setDigest(getDigest("external_gen"))
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/foo.runfiles/some_repo/pkg/__init__.py"))
+ "-out/k8-fastbuild/bin/foo.runfiles/some_repo/pkg/__init__.py")
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME + "-out/k8-fastbuild/bin/foo.runfiles/some_repo/pkg/lib.py")
.setDigest(getDigest("external_source")))
.setDigest(getDigest("external_source"))
.setIsTool(inputsMode.isTool()))
.build());
}

Expand Down Expand Up @@ -1291,7 +1314,8 @@ public void testRunfilesPostOrderCollision(@TestParameter boolean nestBoth) thro
}

@Test
public void testRunfilesSymlinkTargets(@TestParameter boolean rootSymlinks) throws Exception {
public void testRunfilesSymlinkTargets(
@TestParameter boolean rootSymlinks, @TestParameter InputsMode inputsMode) throws Exception {
Artifact sourceFile = ActionsTestUtil.createArtifact(rootDir, "pkg/file.txt");
writeFile(sourceFile, "source");
Artifact sourceDir = ActionsTestUtil.createArtifact(rootDir, "pkg/source_dir");
Expand Down Expand Up @@ -1329,12 +1353,15 @@ public void testRunfilesSymlinkTargets(@TestParameter boolean rootSymlinks) thro
: ImmutableMap.of(),
/* legacyExternalRunfiles= */ false);

Spawn spawn = defaultSpawnBuilder().withInput(runfilesMiddleman).build();
var spawnBuilder = defaultSpawnBuilder().withInput(runfilesMiddleman);
if (inputsMode.isTool()) {
spawnBuilder.withTool(runfilesMiddleman);
}

SpawnLogContext context = createSpawnLogContext();

context.logSpawn(
spawn,
spawnBuilder.build(),
createInputMetadataProvider(
runfilesMiddleman, runfilesTree, sourceFile, sourceDir, genDir, symlink),
createInputMap(runfilesTree),
Expand All @@ -1352,31 +1379,35 @@ public void testRunfilesSymlinkTargets(@TestParameter boolean rootSymlinks) thro
+ "-out/k8-fastbuild/bin/tools/foo.runfiles/"
+ WORKSPACE_NAME
+ "/file")
.setDigest(getDigest("source")))
.setDigest(getDigest("source"))
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/tools/foo.runfiles/"
+ WORKSPACE_NAME
+ "/gen_dir/other_file")
.setDigest(getDigest("gen_dir_file")))
.setDigest(getDigest("gen_dir_file"))
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/tools/foo.runfiles/"
+ WORKSPACE_NAME
+ "/source_dir/some_file")
.setDigest(getDigest("source_dir_file")))
.setDigest(getDigest("source_dir_file"))
.setIsTool(inputsMode.isTool()))
.addInputs(
File.newBuilder()
.setPath(
PRODUCT_NAME
+ "-out/k8-fastbuild/bin/tools/foo.runfiles/"
+ WORKSPACE_NAME
+ "/symlink")
.setSymlinkTargetPath("/some/path"))
.setSymlinkTargetPath("/some/path")
.setIsTool(inputsMode.isTool()))
.build());
}

Expand Down Expand Up @@ -1407,7 +1438,7 @@ public void testRunfileSymlinkFileWithDirectoryContents(
spawn,
createInputMetadataProvider(runfilesMiddleman, runfilesTree, genFile),
createInputMap(runfilesTree),
fs,
outputsMode.getActionFileSystem(fs),
defaultTimeout(),
defaultSpawnResult());

Expand Down

0 comments on commit 20a32e9

Please sign in to comment.