Set TEST_BINARY env variable for the xml generator

Otherwise the test name is not generated correctly. This is caught by
our existing integration tests, and I'm adding an assertion to our unit
tests as well.

Progress on #4608.

PiperOrigin-RevId: 223338264
diff --git a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
index 365a0ec..e643331 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
@@ -44,6 +44,7 @@
 import com.google.devtools.build.lib.events.ExtendedEventHandler;
 import com.google.devtools.build.lib.events.StoredEventHandler;
 import com.google.devtools.build.lib.exec.TestStrategy.TestOutputFormat;
+import com.google.devtools.build.lib.util.OS;
 import com.google.devtools.build.lib.util.io.FileOutErr;
 import com.google.devtools.build.lib.vfs.FileSystemUtils;
 import com.google.devtools.build.lib.vfs.Path;
@@ -541,6 +542,11 @@
                     /*forciblyRunRemotely=*/ false,
                     /*catastrophe=*/ false);
               } else {
+                String testName =
+                    OS.getCurrent() == OS.WINDOWS
+                        ? "standalone/failing_test.exe"
+                        : "standalone/failing_test";
+                assertThat(spawn.getEnvironment()).containsEntry("TEST_BINARY", testName);
                 return ImmutableList.of(xmlGeneratorSpawnResult);
               }
             });