diff --git a/test/integration/subprocess/subprocess_main.cc b/test/integration/subprocess/subprocess_main.cc index e903e3e..d3afa05 100644 --- a/test/integration/subprocess/subprocess_main.cc +++ b/test/integration/subprocess/subprocess_main.cc @@ -34,7 +34,6 @@ class OutputSink if (dest == "cout" || dest == "both") { std::cout << val << std::endl; - } else if (dest == "cerr" || dest == "both") { @@ -59,6 +58,10 @@ int main(int argc, char **argv) int iter_ms = 0; app.add_option("--iteration-ms", iter_ms, "length of one iteration"); + bool environment = false; + app.add_flag("--environment", environment, + "print the environment variables"); + CLI11_PARSE(app, argc, argv); auto sink = OutputSink(output); @@ -68,6 +71,9 @@ int main(int argc, char **argv) std::this_thread::sleep_for(std::chrono::milliseconds(iter_ms)); } - sink.Write(gz::utils::printenv()); + if (environment) + { + sink.Write(gz::utils::printenv()); + } return 0; } diff --git a/test/integration/subprocess_TEST.cc b/test/integration/subprocess_TEST.cc index ef539d9..911ac60 100644 --- a/test/integration/subprocess_TEST.cc +++ b/test/integration/subprocess_TEST.cc @@ -124,7 +124,7 @@ TEST(Subprocess, Environment) { // Default behavior is to inherit the environment - auto proc = Subprocess({kExecutablePath, "--output=cout"}); + auto proc = Subprocess({kExecutablePath, "--output=cout", "--environment"}); // Block until the executable is done auto ret = proc.Join(); EXPECT_EQ(0u, ret); @@ -137,7 +137,8 @@ TEST(Subprocess, Environment) { // Passing an empty map as the second arg clears the environment - auto proc = Subprocess({kExecutablePath, "--output=cout"}, {}); + auto proc = Subprocess( + {kExecutablePath, "--output=cout", "--environment"}, {}); // Block until the executable is done auto ret = proc.Join(); EXPECT_EQ(0u, ret); @@ -150,7 +151,8 @@ TEST(Subprocess, Environment) { // Passing a map sets those variables, clearing the rest - auto proc = Subprocess({kExecutablePath, "--output=cout"}, { + auto proc = Subprocess( + {kExecutablePath, "--output=cout", "--environment"}, { {"QUX_KEY", "QUX_VAL"} }); // Block until the executable is done