TestStrategy: Truncate the tmp dir name to 32 character to avoid exceeding path length limit on Windows and macOS

Fixes https://github.com/bazelbuild/bazel/issues/10124

RELNOTES: None
PiperOrigin-RevId: 277483256
diff --git a/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java
index f8c4dff..3430486 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java
@@ -312,7 +312,8 @@
     digest.addPath(action.getExecutionSettings().getExecutable().getExecPath());
     digest.addInt(action.getShardNum());
     digest.addInt(action.getRunNumber());
-    return digest.hexDigestAndReset();
+    // Truncate the string to 32 character to avoid exceeding path length limit on Windows and macOS
+    return digest.hexDigestAndReset().substring(0, 32);
   }
 
   /** Parse a test result XML file into a {@link TestCase}. */