about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-09-04 10:33:42 +0000
committerbors <bors@rust-lang.org>2015-09-04 10:33:42 +0000
commit6f1014f3510f3c5cc2b524aa4cb18bf91c3fd50f (patch)
treee855c86773552140e5f2deca9ba37a4c20f153c6 /src/test
parentb4de424e4175eefb4fda6e3ed634acfab3ec0daf (diff)
parent04c09f9466c57dca50c643c6099c0f9957d62220 (diff)
downloadrust-6f1014f3510f3c5cc2b524aa4cb18bf91c3fd50f.tar.gz
rust-6f1014f3510f3c5cc2b524aa4cb18bf91c3fd50f.zip
Auto merge of #28069 - alexcrichton:rt-atexit, r=brson
This adds a call to `rt::cleanup` on `process::exit` to make sure we clean up
after ourselves on the way out from Rust.

Closes #28065
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/exit-flushes.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/run-pass/exit-flushes.rs b/src/test/run-pass/exit-flushes.rs
new file mode 100644
index 00000000000..76ecbfd2f22
--- /dev/null
+++ b/src/test/run-pass/exit-flushes.rs
@@ -0,0 +1,25 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::env;
+use std::process::{exit, Command};
+
+fn main() {
+    if env::args().len() > 1 {
+        print!("hello!");
+        exit(0);
+    } else {
+        let out = Command::new(env::args().next().unwrap()).arg("foo")
+                          .output().unwrap();
+        assert!(out.status.success());
+        assert_eq!(String::from_utf8(out.stdout).unwrap(), "hello!");
+        assert_eq!(String::from_utf8(out.stderr).unwrap(), "");
+    }
+}