}
let (doctest, docerrors) = run_doc_tests(options, test_args, &compilation)?;
+ let test = if docerrors.is_empty() { test } else { doctest };
errors.extend(docerrors);
if errors.is_empty() {
Ok(None)
} else {
- Ok(Some(CargoTestError::new(doctest, errors)))
+ Ok(Some(CargoTestError::new(test, errors)))
}
}
match result {
Err(CargoError(CargoErrorKind::ProcessErrorKind(e), .. )) => {
- errors.push(e);
+ errors.push((kind.clone(), test.clone(), e));
if !options.no_fail_fast {
- return Ok((Test::UnitTest(kind.clone(), test.clone()), errors))
+ break;
}
}
Err(e) => {
Ok(()) => {}
}
}
- Ok((Test::Multiple, errors))
+
+ if errors.len() == 1 {
+ let (kind, test, e) = errors.pop().unwrap();
+ Ok((Test::UnitTest(kind, test), vec![e]))
+ } else {
+ Ok((Test::Multiple, errors.into_iter().map((|(_, _, e)| e)).collect()))
+ }
}
fn run_doc_tests(options: &TestOptions,
assert_that(workspace.cargo("test").arg("--all").arg("--target").arg(rustc_host()),
execs().with_status(0));
}
+
+#[test]
+fn test_hint_not_masked_by_doctest() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#)
+ .file("src/lib.rs", r#"
+ /// ```
+ /// assert_eq!(1, 1);
+ /// ```
+ pub fn this_works() {}
+ "#)
+ .file("tests/integ.rs", r#"
+ #[test]
+ fn this_fails() {
+ panic!();
+ }
+ "#);
+ assert_that(p.cargo_process("test")
+ .arg("--no-fail-fast"),
+ execs()
+ .with_status(101)
+ .with_stdout_contains("test this_fails ... FAILED")
+ .with_stdout_contains("[..]this_works (line [..]ok")
+ .with_stderr_contains("[ERROR] test failed, to rerun pass \
+ '--test integ'"));
+}