summaryrefslogtreecommitdiffstats
path: root/src/test/ui/print-stdout-eprint-stderr.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/print-stdout-eprint-stderr.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/print-stdout-eprint-stderr.rs b/src/test/ui/print-stdout-eprint-stderr.rs
new file mode 100644
index 000000000..cfa9aec80
--- /dev/null
+++ b/src/test/ui/print-stdout-eprint-stderr.rs
@@ -0,0 +1,32 @@
+// run-pass
+// ignore-emscripten spawning processes is not supported
+// ignore-sgx no processes
+
+use std::{env, process};
+
+fn child() {
+ print!("[stdout 0]");
+ print!("[stdout {}]", 1);
+ println!("[stdout {}]", 2);
+ println!();
+ eprint!("[stderr 0]");
+ eprint!("[stderr {}]", 1);
+ eprintln!("[stderr {}]", 2);
+ eprintln!();
+}
+
+fn parent() {
+ let this = env::args().next().unwrap();
+ let output = process::Command::new(this).arg("-").output().unwrap();
+ assert!(output.status.success());
+
+ let stdout = String::from_utf8(output.stdout).unwrap();
+ let stderr = String::from_utf8(output.stderr).unwrap();
+
+ assert_eq!(stdout, "[stdout 0][stdout 1][stdout 2]\n\n");
+ assert_eq!(stderr, "[stderr 0][stderr 1][stderr 2]\n\n");
+}
+
+fn main() {
+ if env::args().count() == 2 { child() } else { parent() }
+}