Skip to content

Commit ff859ed

Browse files
committed
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
1 parent 702767d commit ff859ed

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/librustpkg/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,9 @@ impl CtxMethods for BuildContext {
699699
debug!("test: test_exec = {}", test_exec.display());
700700
// FIXME (#9639): This needs to handle non-utf8 paths
701701
let status = run::process_status(test_exec.as_str().unwrap(), [~"--test"]);
702-
os::set_exit_status(status);
702+
if status != 0 {
703+
fail!("Some tests failed");
704+
}
703705
}
704706
None => {
705707
error(format!("Internal error: test executable for package ID {} in workspace {} \

src/librustpkg/tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,20 @@ fn test_rustpkg_test_output() {
20972097
assert!(output_str.contains("1 passed; 0 failed; 0 ignored; 0 measured"));
20982098
}
20992099
2100+
#[test]
2101+
fn test_rustpkg_test_failure_exit_status() {
2102+
let foo_id = PkgId::new("foo");
2103+
let foo_workspace = create_local_package(&foo_id);
2104+
let foo_workspace = foo_workspace.path();
2105+
writeFile(&foo_workspace.join_many(["src", "foo-0.1", "test.rs"]),
2106+
"#[test] fn f() { assert!('a' != 'a'); }");
2107+
let res = command_line_test_partial([~"test", ~"foo"], foo_workspace);
2108+
match res {
2109+
Fail(_) => {},
2110+
Success(*) => fail!("Expected test failure but got success")
2111+
}
2112+
}
2113+
21002114
#[test]
21012115
fn test_rebuild_when_needed() {
21022116
let foo_id = PkgId::new("foo");
@@ -2118,6 +2132,7 @@ fn test_rebuild_when_needed() {
21182132
}
21192133
21202134
#[test]
2135+
#[ignore] // FIXME (#10257): This doesn't work as is since a read only file can't execute
21212136
fn test_no_rebuilding() {
21222137
let foo_id = PkgId::new("foo");
21232138
let foo_workspace = create_local_package(&foo_id);

0 commit comments

Comments
 (0)