Skip to content

Ensure rustpkg test fails if tests failed #10254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustpkg/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} \
Expand Down
15 changes: 15 additions & 0 deletions src/librustpkg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand Down