2014-07-22 05:21:16 +00:00
|
|
|
use std::path;
|
2014-07-10 19:39:05 +00:00
|
|
|
use std::str;
|
|
|
|
|
2014-07-21 00:02:09 +00:00
|
|
|
use support::{project, execs, basic_bin_manifest, basic_lib_manifest};
|
2014-08-01 03:21:13 +00:00
|
|
|
use support::{COMPILING, cargo_dir, ResultTest, FRESH, RUNNING, DOCTEST};
|
2014-08-02 07:08:31 +00:00
|
|
|
use support::paths::PathExt;
|
2014-06-26 22:14:31 +00:00
|
|
|
use hamcrest::{assert_that, existing_file};
|
|
|
|
use cargo::util::process;
|
|
|
|
|
|
|
|
fn setup() {}
|
|
|
|
|
|
|
|
test!(cargo_test_simple {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
|
|
|
|
.file("src/foo.rs", r#"
|
|
|
|
fn hello() -> &'static str {
|
|
|
|
"hello"
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
println!("{}", hello())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_hello() {
|
|
|
|
assert_eq!(hello(), "hello")
|
|
|
|
}"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-build"), execs());
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
process(p.bin("foo")),
|
|
|
|
execs().with_stdout("hello\n"));
|
|
|
|
|
2014-06-27 21:06:50 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo-test")),
|
2014-08-01 03:21:13 +00:00
|
|
|
execs().with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{} foo v0.5.0 ({})
|
2014-08-01 03:21:13 +00:00
|
|
|
{} target[..]test[..]foo
|
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test test_hello ... ok
|
|
|
|
|
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n",
|
2014-08-06 16:21:10 +00:00
|
|
|
COMPILING, p.url(),
|
2014-08-01 03:21:13 +00:00
|
|
|
RUNNING)));
|
2014-07-21 19:23:01 +00:00
|
|
|
})
|
|
|
|
|
2014-07-23 18:44:15 +00:00
|
|
|
test!(many_similar_names {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
pub fn foo() {}
|
|
|
|
#[test] fn lib_test() {}
|
|
|
|
")
|
|
|
|
.file("src/main.rs", "
|
|
|
|
extern crate foo;
|
|
|
|
fn main() {}
|
|
|
|
#[test] fn bin_test() { foo::foo() }
|
|
|
|
")
|
|
|
|
.file("tests/foo.rs", r#"
|
|
|
|
extern crate foo;
|
|
|
|
#[test] fn test_test() { foo::foo() }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
let output = p.cargo_process("cargo-test").exec_with_output().assert();
|
|
|
|
let output = str::from_utf8(output.output.as_slice()).assert();
|
|
|
|
assert!(output.contains("test bin_test"), "bin_test missing\n{}", output);
|
|
|
|
assert!(output.contains("test lib_test"), "lib_test missing\n{}", output);
|
|
|
|
assert!(output.contains("test test_test"), "test_test missing\n{}", output);
|
|
|
|
})
|
|
|
|
|
2014-07-21 19:23:01 +00:00
|
|
|
test!(cargo_test_failing_test {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
|
|
|
|
.file("src/foo.rs", r#"
|
|
|
|
fn hello() -> &'static str {
|
|
|
|
"hello"
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
println!("{}", hello())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_hello() {
|
|
|
|
assert_eq!(hello(), "nope")
|
|
|
|
}"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-build"), execs());
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
process(p.bin("foo")),
|
|
|
|
execs().with_stdout("hello\n"));
|
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo-test")),
|
2014-08-01 03:21:13 +00:00
|
|
|
execs().with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{} foo v0.5.0 ({})
|
2014-08-01 03:21:13 +00:00
|
|
|
{} target[..]test[..]foo
|
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test test_hello ... FAILED
|
|
|
|
|
|
|
|
failures:
|
|
|
|
|
|
|
|
---- test_hello stdout ----
|
|
|
|
<tab>task 'test_hello' failed at 'assertion failed: \
|
|
|
|
`(left == right) && (right == left)` (left: \
|
|
|
|
`hello`, right: `nope`)', src{sep}foo.rs:12
|
|
|
|
<tab>
|
|
|
|
<tab>
|
|
|
|
|
|
|
|
failures:
|
|
|
|
test_hello
|
|
|
|
|
|
|
|
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
",
|
2014-08-06 16:21:10 +00:00
|
|
|
COMPILING, p.url(), RUNNING,
|
2014-08-01 03:21:13 +00:00
|
|
|
sep = path::SEP))
|
2014-07-23 19:49:32 +00:00
|
|
|
.with_stderr(format!("\
|
|
|
|
task '<main>' failed at 'Some tests failed', [..]
|
|
|
|
Could not execute process `{test}[..]` (status=101)
|
|
|
|
", test = p.root().join("target/test/foo").display()))
|
|
|
|
.with_status(101));
|
2014-06-26 22:14:31 +00:00
|
|
|
})
|
2014-07-09 20:08:44 +00:00
|
|
|
|
|
|
|
test!(test_with_lib_dep {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-07-17 01:44:30 +00:00
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
name = "baz"
|
|
|
|
path = "src/main.rs"
|
2014-07-09 20:08:44 +00:00
|
|
|
"#)
|
2014-08-01 03:21:13 +00:00
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// extern crate foo;
|
|
|
|
/// fn main() {
|
|
|
|
/// println!("{}", foo::foo());
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
///
|
2014-07-10 19:08:13 +00:00
|
|
|
pub fn foo(){}
|
|
|
|
#[test] fn lib_test() {}
|
2014-08-01 03:21:13 +00:00
|
|
|
"#)
|
2014-07-09 20:08:44 +00:00
|
|
|
.file("src/main.rs", "
|
|
|
|
extern crate foo;
|
2014-07-10 19:08:13 +00:00
|
|
|
|
2014-07-09 20:08:44 +00:00
|
|
|
fn main() {}
|
2014-07-10 19:08:13 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn bin_test() {}
|
2014-07-09 20:08:44 +00:00
|
|
|
");
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{} foo v0.0.1 ({})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]baz-[..]
|
2014-07-10 19:08:13 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test bin_test ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{running} target[..]test[..]foo
|
|
|
|
|
2014-07-10 19:08:13 +00:00
|
|
|
running 1 test
|
|
|
|
test lib_test ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
2014-07-10 19:39:05 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
{doctest} foo
|
2014-07-10 19:08:13 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
running 1 test
|
|
|
|
test foo_0 ... ok
|
|
|
|
|
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
",
|
2014-08-06 16:21:10 +00:00
|
|
|
COMPILING, p.url(), running = RUNNING, doctest = DOCTEST)))
|
2014-07-09 20:08:44 +00:00
|
|
|
})
|
2014-07-09 20:55:00 +00:00
|
|
|
|
|
|
|
test!(test_with_deep_lib_dep {
|
2014-07-10 18:50:03 +00:00
|
|
|
let p = project("bar")
|
2014-07-09 20:55:00 +00:00
|
|
|
.file("Cargo.toml", r#"
|
2014-07-10 18:50:03 +00:00
|
|
|
[package]
|
2014-07-09 20:55:00 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.foo]
|
2014-07-10 18:50:03 +00:00
|
|
|
path = "../foo"
|
2014-07-09 20:55:00 +00:00
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
extern crate foo;
|
2014-07-10 18:50:03 +00:00
|
|
|
#[test]
|
|
|
|
fn bar_test() {
|
|
|
|
foo::foo();
|
|
|
|
}
|
|
|
|
");
|
|
|
|
let p2 = project("foo")
|
2014-07-09 20:55:00 +00:00
|
|
|
.file("Cargo.toml", r#"
|
2014-07-10 18:50:03 +00:00
|
|
|
[package]
|
2014-07-09 20:55:00 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
2014-07-10 18:50:03 +00:00
|
|
|
.file("src/lib.rs", "
|
|
|
|
pub fn foo() {}
|
2014-07-09 20:55:00 +00:00
|
|
|
|
2014-07-10 18:50:03 +00:00
|
|
|
#[test]
|
|
|
|
fn foo_test() {}
|
|
|
|
");
|
|
|
|
|
|
|
|
p2.build();
|
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
{compiling} bar v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]
|
2014-07-10 18:50:03 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test bar_test ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measure
|
|
|
|
|
|
|
|
{doctest} bar
|
|
|
|
|
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
2014-07-10 18:50:03 +00:00
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
compiling = COMPILING, running = RUNNING,
|
|
|
|
doctest = DOCTEST,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-07-09 20:55:00 +00:00
|
|
|
})
|
2014-07-11 00:08:19 +00:00
|
|
|
|
|
|
|
test!(external_test_explicit {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[test]]
|
|
|
|
name = "test"
|
|
|
|
path = "src/test.rs"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
pub fn get_hello() -> &'static str { "Hello" }
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn internal_test() {}
|
|
|
|
"#)
|
|
|
|
.file("src/test.rs", r#"
|
|
|
|
extern crate foo;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn external_test() { assert_eq!(foo::get_hello(), "Hello") }
|
|
|
|
"#);
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{} foo v0.0.1 ({})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]foo-[..]
|
2014-07-11 00:08:19 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test internal_test ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{running} target[..]test[..]test-[..]
|
|
|
|
|
2014-07-11 00:08:19 +00:00
|
|
|
running 1 test
|
|
|
|
test external_test ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
2014-07-11 00:08:19 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
{doctest} foo
|
2014-07-11 00:08:19 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
",
|
2014-08-06 16:21:10 +00:00
|
|
|
COMPILING, p.url(), running = RUNNING, doctest = DOCTEST)))
|
2014-07-11 00:08:19 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test!(external_test_implicit {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
pub fn get_hello() -> &'static str { "Hello" }
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn internal_test() {}
|
|
|
|
"#)
|
2014-07-13 12:45:26 +00:00
|
|
|
.file("tests/external.rs", r#"
|
2014-07-11 00:08:19 +00:00
|
|
|
extern crate foo;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn external_test() { assert_eq!(foo::get_hello(), "Hello") }
|
|
|
|
"#);
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{} foo v0.0.1 ({})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]external-[..]
|
2014-07-11 00:08:19 +00:00
|
|
|
|
|
|
|
running 1 test
|
2014-08-01 03:21:13 +00:00
|
|
|
test external_test ... ok
|
|
|
|
|
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{running} target[..]test[..]foo-[..]
|
2014-07-11 00:08:19 +00:00
|
|
|
|
|
|
|
running 1 test
|
2014-08-01 03:21:13 +00:00
|
|
|
test internal_test ... ok
|
|
|
|
|
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{doctest} foo
|
2014-07-11 00:08:19 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
running 0 tests
|
2014-07-11 00:08:19 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
|
2014-07-11 00:08:19 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
",
|
2014-08-06 16:21:10 +00:00
|
|
|
COMPILING, p.url(), running = RUNNING, doctest = DOCTEST)))
|
2014-07-11 00:08:19 +00:00
|
|
|
})
|
2014-07-11 20:34:50 +00:00
|
|
|
|
|
|
|
test!(dont_run_examples {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
"#)
|
|
|
|
.file("examples/dont-run-me-i-will-fail.rs", r#"
|
|
|
|
fn main() { fail!("Examples should not be run by 'cargo test'"); }
|
|
|
|
"#);
|
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_status(0));
|
|
|
|
})
|
2014-07-10 20:53:36 +00:00
|
|
|
|
|
|
|
test!(pass_through_command_line {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
#[test] fn foo() {}
|
|
|
|
#[test] fn bar() {}
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-test").arg("bar"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]foo
|
2014-07-10 20:53:36 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test bar ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{doctest} foo
|
|
|
|
|
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
2014-07-10 20:53:36 +00:00
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
compiling = COMPILING, running = RUNNING,
|
|
|
|
doctest = DOCTEST,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-07-10 20:53:36 +00:00
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-test").arg("foo"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]foo
|
2014-07-10 20:53:36 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test foo ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{doctest} foo
|
|
|
|
|
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
2014-07-10 20:53:36 +00:00
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
compiling = COMPILING, running = RUNNING,
|
|
|
|
doctest = DOCTEST,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-07-10 20:53:36 +00:00
|
|
|
})
|
2014-07-21 00:02:09 +00:00
|
|
|
|
|
|
|
// Regression test for running cargo-test twice with
|
|
|
|
// tests in an rlib
|
|
|
|
test!(cargo_test_twice {
|
|
|
|
let p = project("test_twice")
|
|
|
|
.file("Cargo.toml", basic_lib_manifest("test_twice").as_slice())
|
|
|
|
.file("src/test_twice.rs", r#"
|
|
|
|
#![crate_type = "rlib"]
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn dummy_test() { }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
p.cargo_process("cargo-build");
|
|
|
|
|
|
|
|
for _ in range(0u, 2) {
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo-test")),
|
|
|
|
execs().with_status(0));
|
|
|
|
}
|
|
|
|
})
|
2014-07-22 14:45:46 +00:00
|
|
|
|
|
|
|
test!(lib_bin_same_name {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
name = "foo"
|
|
|
|
[[bin]]
|
|
|
|
name = "foo"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
#[test] fn lib_test() {}
|
|
|
|
")
|
|
|
|
.file("src/main.rs", "
|
|
|
|
extern crate foo;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn bin_test() {}
|
|
|
|
");
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{} foo v0.0.1 ({})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]foo-[..]
|
2014-07-22 14:45:46 +00:00
|
|
|
|
|
|
|
running 1 test
|
2014-08-01 03:21:13 +00:00
|
|
|
test [..] ... ok
|
|
|
|
|
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{running} target[..]test[..]foo-[..]
|
2014-07-22 14:45:46 +00:00
|
|
|
|
|
|
|
running 1 test
|
2014-08-01 03:21:13 +00:00
|
|
|
test [..] ... ok
|
|
|
|
|
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
2014-07-22 14:45:46 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
{doctest} foo
|
2014-07-22 14:45:46 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
running 0 tests
|
2014-07-22 14:45:46 +00:00
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
",
|
2014-08-06 16:21:10 +00:00
|
|
|
COMPILING, p.url(), running = RUNNING, doctest = DOCTEST)))
|
2014-07-22 14:45:46 +00:00
|
|
|
})
|
2014-07-23 00:53:38 +00:00
|
|
|
|
|
|
|
test!(lib_with_standard_name {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "syntax"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
name = "syntax"
|
|
|
|
test = false
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
pub fn foo() {}
|
|
|
|
")
|
|
|
|
.file("tests/test.rs", "
|
|
|
|
extern crate syntax;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test() { syntax::foo() }
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{compiling} syntax v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]test-[..]
|
2014-07-23 00:53:38 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test test ... ok
|
|
|
|
|
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
compiling = COMPILING, running = RUNNING,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-07-23 00:53:38 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test!(lib_with_standard_name2 {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "syntax"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
name = "syntax"
|
|
|
|
test = false
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
pub fn foo() {}
|
|
|
|
")
|
|
|
|
.file("src/main.rs", "
|
|
|
|
extern crate syntax;
|
|
|
|
|
|
|
|
fn main() {}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test() { syntax::foo() }
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{compiling} syntax v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]syntax-[..]
|
2014-07-23 00:53:38 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test test ... ok
|
|
|
|
|
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
compiling = COMPILING, running = RUNNING,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-07-23 00:53:38 +00:00
|
|
|
})
|
2014-07-23 18:58:09 +00:00
|
|
|
|
|
|
|
test!(bin_there_for_integration {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "
|
|
|
|
fn main() { std::os::set_exit_status(1); }
|
|
|
|
#[test] fn main_test() {}
|
|
|
|
")
|
|
|
|
.file("tests/foo.rs", r#"
|
|
|
|
use std::io::Command;
|
|
|
|
#[test]
|
|
|
|
fn test_test() {
|
|
|
|
let status = Command::new("target/test/foo").status().unwrap();
|
|
|
|
assert!(status.matches_exit_status(1));
|
|
|
|
}
|
|
|
|
"#);
|
|
|
|
|
|
|
|
let output = p.cargo_process("cargo-test").exec_with_output().assert();
|
|
|
|
let output = str::from_utf8(output.output.as_slice()).assert();
|
|
|
|
assert!(output.contains("main_test ... ok"), "no main_test\n{}", output);
|
|
|
|
assert!(output.contains("test_test ... ok"), "no test_test\n{}", output);
|
|
|
|
})
|
2014-07-23 16:09:33 +00:00
|
|
|
|
|
|
|
test!(test_dylib {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
name = "foo"
|
|
|
|
crate_type = ["dylib"]
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
#[test]
|
|
|
|
fn foo() {}
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]foo-[..]
|
2014-07-23 16:09:33 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test foo ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{doctest} foo
|
|
|
|
|
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
2014-07-23 16:09:33 +00:00
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
compiling = COMPILING, running = RUNNING,
|
|
|
|
doctest = DOCTEST,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-08-02 07:08:31 +00:00
|
|
|
p.root().move_into_the_past().assert();
|
2014-07-23 16:09:33 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo-test")),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{fresh} foo v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]foo-[..]
|
2014-07-23 16:09:33 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test foo ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{doctest} foo
|
|
|
|
|
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
2014-07-23 16:09:33 +00:00
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
fresh = FRESH, running = RUNNING,
|
|
|
|
doctest = DOCTEST,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-07-23 16:09:33 +00:00
|
|
|
})
|
2014-07-23 16:36:49 +00:00
|
|
|
|
|
|
|
test!(test_twice_with_build_cmd {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
build = 'true'
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
#[test]
|
|
|
|
fn foo() {}
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-test"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]foo-[..]
|
2014-07-23 16:36:49 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test foo ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{doctest} foo
|
|
|
|
|
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
2014-07-23 16:36:49 +00:00
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
compiling = COMPILING, running = RUNNING,
|
|
|
|
doctest = DOCTEST,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-08-02 07:08:31 +00:00
|
|
|
|
2014-07-23 16:36:49 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo-test")),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stdout(format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{fresh} foo v0.0.1 ({dir})
|
2014-08-01 03:21:13 +00:00
|
|
|
{running} target[..]test[..]foo-[..]
|
2014-07-23 16:36:49 +00:00
|
|
|
|
|
|
|
running 1 test
|
|
|
|
test foo ... ok
|
|
|
|
|
2014-08-01 03:21:13 +00:00
|
|
|
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
{doctest} foo
|
|
|
|
|
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured\n\n\
|
2014-07-23 16:36:49 +00:00
|
|
|
",
|
2014-08-01 03:21:13 +00:00
|
|
|
fresh = FRESH, running = RUNNING,
|
|
|
|
doctest = DOCTEST,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = p.url()).as_slice()));
|
2014-07-23 16:36:49 +00:00
|
|
|
})
|