From bec2fe85bdf07d944d0cb650b59732ea8d3e804c Mon Sep 17 00:00:00 2001 From: ruperts Date: Tue, 5 Dec 2017 21:53:50 -0800 Subject: Make ProcessWrapperUtil aware of the execution statistics file, and add new ExecutionStatisticsProvider. RELNOTES: None. PiperOrigin-RevId: 178056182 --- .../build/lib/runtime/ProcessWrapperUtilTest.java | 40 ++++++++++------------ 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'src/test/java/com/google/devtools/build/lib/runtime') diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java index 91735e3a22..6d182f29a8 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java @@ -17,8 +17,8 @@ package com.google.devtools.build.lib.runtime; import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.testutil.MoreAsserts.expectThrows; +import com.google.common.collect.ImmutableList; import java.time.Duration; -import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,9 +30,7 @@ public final class ProcessWrapperUtilTest { @Test public void testProcessWrapperCommandLineBuilder_ProcessWrapperPathIsRequired() { - List commandArguments = new ArrayList<>(); - commandArguments.add("echo"); - commandArguments.add("hello, world"); + ImmutableList commandArguments = ImmutableList.of("echo", "hello, world"); Exception e = expectThrows( @@ -62,13 +60,10 @@ public final class ProcessWrapperUtilTest { public void testProcessWrapperCommandLineBuilder_BuildsWithoutOptionalArguments() { String processWrapperPath = "process-wrapper"; - List commandArguments = new ArrayList<>(); - commandArguments.add("echo"); - commandArguments.add("hello, world"); + ImmutableList commandArguments = ImmutableList.of("echo", "hello, world"); - List expectedCommandLine = new ArrayList<>(); - expectedCommandLine.add(processWrapperPath); - expectedCommandLine.addAll(commandArguments); + ImmutableList expectedCommandLine = + ImmutableList.builder().add(processWrapperPath).addAll(commandArguments).build(); List commandLine = ProcessWrapperUtil.commandLineBuilder() @@ -83,22 +78,24 @@ public final class ProcessWrapperUtilTest { public void testProcessWrapperCommandLineBuilder_BuildsWithOptionalArguments() { String processWrapperPath = "process-wrapper"; - List commandArguments = new ArrayList<>(); - commandArguments.add("echo"); - commandArguments.add("hello, world"); + ImmutableList commandArguments = ImmutableList.of("echo", "hello, world"); Duration timeout = Duration.ofSeconds(10); Duration killDelay = Duration.ofSeconds(2); String stdoutPath = "stdout.txt"; String stderrPath = "stderr.txt"; - - List expectedCommandLine = new ArrayList<>(); - expectedCommandLine.add(processWrapperPath); - expectedCommandLine.add("--timeout=" + timeout.getSeconds()); - expectedCommandLine.add("--kill_delay=" + killDelay.getSeconds()); - expectedCommandLine.add("--stdout=" + stdoutPath); - expectedCommandLine.add("--stderr=" + stderrPath); - expectedCommandLine.addAll(commandArguments); + String statisticsPath = "stats.out"; + + ImmutableList expectedCommandLine = + ImmutableList.builder() + .add(processWrapperPath) + .add("--timeout=" + timeout.getSeconds()) + .add("--kill_delay=" + killDelay.getSeconds()) + .add("--stdout=" + stdoutPath) + .add("--stderr=" + stderrPath) + .add("--stats=" + statisticsPath) + .addAll(commandArguments) + .build(); List commandLine = ProcessWrapperUtil.commandLineBuilder() @@ -108,6 +105,7 @@ public final class ProcessWrapperUtilTest { .setKillDelay(killDelay) .setStdoutPath(stdoutPath) .setStderrPath(stderrPath) + .setStatisticsPath(statisticsPath) .build(); assertThat(commandLine).containsExactlyElementsIn(expectedCommandLine); -- cgit v1.2.3