From ff859edb8579be4694fe490249e9800cefe50c8c Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 3 Nov 2013 15:23:34 -0800 Subject: [PATCH] Ensure rustpkg test fails if tests failed It previously set the exit status, but the main wrapper paved over that with an exit code of 0. Closes #9761 --- src/librustpkg/lib.rs | 4 +++- src/librustpkg/tests.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/librustpkg/lib.rs b/src/librustpkg/lib.rs index 517d43432ec..80f1dc2fe93 100644 --- a/src/librustpkg/lib.rs +++ b/src/librustpkg/lib.rs @@ -699,7 +699,9 @@ impl CtxMethods for BuildContext { debug!("test: test_exec = {}", test_exec.display()); // FIXME (#9639): This needs to handle non-utf8 paths let status = run::process_status(test_exec.as_str().unwrap(), [~"--test"]); - os::set_exit_status(status); + if status != 0 { + fail!("Some tests failed"); + } } None => { error(format!("Internal error: test executable for package ID {} in workspace {} \ diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs index 8f1b269f1ca..072c165cd96 100644 --- a/src/librustpkg/tests.rs +++ b/src/librustpkg/tests.rs @@ -2097,6 +2097,20 @@ fn test_rustpkg_test_output() { assert!(output_str.contains("1 passed; 0 failed; 0 ignored; 0 measured")); } +#[test] +fn test_rustpkg_test_failure_exit_status() { + let foo_id = PkgId::new("foo"); + let foo_workspace = create_local_package(&foo_id); + let foo_workspace = foo_workspace.path(); + writeFile(&foo_workspace.join_many(["src", "foo-0.1", "test.rs"]), + "#[test] fn f() { assert!('a' != 'a'); }"); + let res = command_line_test_partial([~"test", ~"foo"], foo_workspace); + match res { + Fail(_) => {}, + Success(*) => fail!("Expected test failure but got success") + } +} + #[test] fn test_rebuild_when_needed() { let foo_id = PkgId::new("foo"); @@ -2118,6 +2132,7 @@ fn test_rebuild_when_needed() { } #[test] +#[ignore] // FIXME (#10257): This doesn't work as is since a read only file can't execute fn test_no_rebuilding() { let foo_id = PkgId::new("foo"); let foo_workspace = create_local_package(&foo_id);