aboutsummaryrefslogtreecommitdiff
path: root/paludis/util/process_TEST.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-20 20:44:58 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-21 14:58:17 +0100
commite0829dd6ab62d8bd25308fc806072d1b378a1523 (patch)
treec3b66fde4f00680f159ff206eea92e90e55ff4ed /paludis/util/process_TEST.cc
parentfcd415e70607343e806be7e05e99629969483edd (diff)
downloadpaludis-e0829dd6ab62d8bd25308fc806072d1b378a1523.tar.gz
paludis-e0829dd6ab62d8bd25308fc806072d1b378a1523.tar.xz
Process::prefix_std{out,err}
Diffstat (limited to 'paludis/util/process_TEST.cc')
-rw-r--r--paludis/util/process_TEST.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/paludis/util/process_TEST.cc b/paludis/util/process_TEST.cc
index 71f2170f4..69fc5fdc1 100644
--- a/paludis/util/process_TEST.cc
+++ b/paludis/util/process_TEST.cc
@@ -349,5 +349,37 @@ namespace test_cases
TEST_CHECK(! std::getline(stdout_stream, line));
}
} test_captured_pipe_command;
+
+ struct PrefixStdoutTest : TestCase
+ {
+ PrefixStdoutTest() : TestCase("prefix stdout") { }
+
+ void run()
+ {
+ std::stringstream stdout_stream;
+ Process echo_process(ProcessCommand({ "sh", "-c", "echo monkey ; echo in ; echo space"}));
+ echo_process.capture_stdout(stdout_stream);
+ echo_process.prefix_stdout("prefix> ");
+
+ TEST_CHECK_EQUAL(echo_process.run().wait(), 0);
+ TEST_CHECK_EQUAL(stdout_stream.str(), "prefix> monkey\nprefix> in\nprefix> space\n");
+ }
+ } test_prefix_stdout;
+
+ struct PrefixStderrTest : TestCase
+ {
+ PrefixStderrTest() : TestCase("prefix stderr") { }
+
+ void run()
+ {
+ std::stringstream stderr_stream;
+ Process echo_process(ProcessCommand({ "sh", "-c", "echo monkey 1>&2 ; echo in 1>&2 ; echo space 1>&2"}));
+ echo_process.capture_stderr(stderr_stream);
+ echo_process.prefix_stderr("prefix> ");
+
+ TEST_CHECK_EQUAL(echo_process.run().wait(), 0);
+ TEST_CHECK_EQUAL(stderr_stream.str(), "prefix> monkey\nprefix> in\nprefix> space\n");
+ }
+ } test_prefix_stderr;
}