@@ -590,6 +590,54 @@ public void downloadOutputs_relativeDirectorySymlink_success() throws Exception
590
590
assertThat (context .isLockOutputFilesCalled ()).isTrue ();
591
591
}
592
592
593
+ @ Test
594
+ public void downloadOutputs_relativeOutputSymlinks_success () throws Exception {
595
+ // Test that download outputs works when the action result only contains output_symlinks
596
+ // and not output_file_symlinks or output_directory_symlinks, which are deprecated.
597
+ ActionResult .Builder builder = ActionResult .newBuilder ();
598
+ builder .addOutputSymlinksBuilder ().setPath ("outputs/a/b/link" ).setTarget ("../../foo" );
599
+ RemoteActionResult result =
600
+ RemoteActionResult .createFromCache (CachedActionResult .remote (builder .build ()));
601
+ Spawn spawn = newSpawnFromResult (result );
602
+ FakeSpawnExecutionContext context = newSpawnExecutionContext (spawn );
603
+ RemoteExecutionService service = newRemoteExecutionService ();
604
+ RemoteAction action = service .buildRemoteAction (spawn , context );
605
+
606
+ // Doesn't check for dangling links, hence download succeeds.
607
+ service .downloadOutputs (action , result );
608
+
609
+ Path path = execRoot .getRelative ("outputs/a/b/link" );
610
+ assertThat (path .isSymbolicLink ()).isTrue ();
611
+ assertThat (path .readSymbolicLink ()).isEqualTo (PathFragment .create ("../../foo" ));
612
+ assertThat (context .isLockOutputFilesCalled ()).isTrue ();
613
+ }
614
+
615
+ @ Test
616
+ public void downloadOutputs_outputSymlinksCompatibility_success () throws Exception {
617
+ // Test that download outputs works when the action result contains both output_symlinks
618
+ // and output_file_symlinks (or output_directory_symlinks).
619
+ //
620
+ // Remote Execution Server may set both fields to ensure backward compatibility with
621
+ // clients that don't support output_symlinks.
622
+ ActionResult .Builder builder = ActionResult .newBuilder ();
623
+ builder .addOutputFileSymlinksBuilder ().setPath ("outputs/a/b/link" ).setTarget ("foo" );
624
+ builder .addOutputSymlinksBuilder ().setPath ("outputs/a/b/link" ).setTarget ("foo" );
625
+ RemoteActionResult result =
626
+ RemoteActionResult .createFromCache (CachedActionResult .remote (builder .build ()));
627
+ Spawn spawn = newSpawnFromResult (result );
628
+ FakeSpawnExecutionContext context = newSpawnExecutionContext (spawn );
629
+ RemoteExecutionService service = newRemoteExecutionService ();
630
+ RemoteAction action = service .buildRemoteAction (spawn , context );
631
+
632
+ // Doesn't check for dangling links, hence download succeeds.
633
+ service .downloadOutputs (action , result );
634
+
635
+ Path path = execRoot .getRelative ("outputs/a/b/link" );
636
+ assertThat (path .isSymbolicLink ()).isTrue ();
637
+ assertThat (path .readSymbolicLink ()).isEqualTo (PathFragment .create ("foo" ));
638
+ assertThat (context .isLockOutputFilesCalled ()).isTrue ();
639
+ }
640
+
593
641
@ Test
594
642
public void downloadOutputs_relativeSymlinkInDirectory_success () throws Exception {
595
643
Tree tree =
@@ -2014,6 +2062,12 @@ private Spawn newSpawnFromResult(
2014
2062
outputs .add (output );
2015
2063
}
2016
2064
2065
+ for (OutputSymlink symlink : result .getOutputSymlinks ()) {
2066
+ Path path = remotePathResolver .outputPathToLocalPath (symlink .getPath ());
2067
+ Artifact output = ActionsTestUtil .createArtifact (artifactRoot , path );
2068
+ outputs .add (output );
2069
+ }
2070
+
2017
2071
return newSpawn (executionInfo , outputs .build ());
2018
2072
}
2019
2073
0 commit comments