about summary refs log tree commit diff
path: root/src/test/run-fail
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-01-12 22:17:21 -0800
committerBrian Anderson <banderson@mozilla.com>2012-01-12 22:24:27 -0800
commit0616cba62be78082f10f6673d45ba4d94da423dc (patch)
tree0cd1d0cf9434a751b293b8292da1c153065da491 /src/test/run-fail
parentdcac427795285a46232722a38e8a5f88ae4dc891 (diff)
downloadrust-0616cba62be78082f10f6673d45ba4d94da423dc.tar.gz
rust-0616cba62be78082f10f6673d45ba4d94da423dc.zip
libcore: Add sys::set_exit_status
Sets the process exit code
Diffstat (limited to 'src/test/run-fail')
-rw-r--r--src/test/run-fail/rt-set-exit-status-fail.rs10
-rw-r--r--src/test/run-fail/rt-set-exit-status-fail2.rs15
-rw-r--r--src/test/run-fail/rt-set-exit-status.rs8
3 files changed, 33 insertions, 0 deletions
diff --git a/src/test/run-fail/rt-set-exit-status-fail.rs b/src/test/run-fail/rt-set-exit-status-fail.rs
new file mode 100644
index 00000000000..fd32ff04600
--- /dev/null
+++ b/src/test/run-fail/rt-set-exit-status-fail.rs
@@ -0,0 +1,10 @@
+// error-pattern:whatever
+
+fn main() {
+    log(error, "whatever");
+    // Setting the exit status only works when the scheduler terminates
+    // normally. In this case we're going to fail, so instead of of
+    // returning 50 the process will return the typical rt failure code.
+    sys::set_exit_status(50);
+    fail;
+}
\ No newline at end of file
diff --git a/src/test/run-fail/rt-set-exit-status-fail2.rs b/src/test/run-fail/rt-set-exit-status-fail2.rs
new file mode 100644
index 00000000000..5d973d2a9e3
--- /dev/null
+++ b/src/test/run-fail/rt-set-exit-status-fail2.rs
@@ -0,0 +1,15 @@
+// error-pattern:whatever
+
+fn main() {
+    log(error, "whatever");
+    task::spawn {||
+        resource r(_i: ()) {
+            // Setting the exit status after the runtime has already
+            // failed has no effect and the process exits with the
+            // runtime's exit code
+            sys::set_exit_status(50);
+        }
+        let i = r(());
+    };
+    fail;
+}
\ No newline at end of file
diff --git a/src/test/run-fail/rt-set-exit-status.rs b/src/test/run-fail/rt-set-exit-status.rs
new file mode 100644
index 00000000000..e9e8f239434
--- /dev/null
+++ b/src/test/run-fail/rt-set-exit-status.rs
@@ -0,0 +1,8 @@
+// error-pattern:whatever
+
+fn main() {
+    log(error, "whatever");
+    // 101 is the code the runtime uses on task failure and the value
+    // compiletest expects run-fail tests to return.
+    sys::set_exit_status(101);
+}
\ No newline at end of file