Skip to content

Commit

Permalink
Auto merge of #2743 - alexcrichton:better-test-suite, r=alexcrichton
Browse files Browse the repository at this point in the history
Split the test suite into multiple binaries

Helps reduce compile time of tests, more ergonomic names to type, more conventional configuration, and makes it basically easier to work with.

The previous `support` module is now a separate `cargotest` crate.
  • Loading branch information
bors committed May 26, 2016
2 parents 3ff108a + 763ba53 commit 07c1d99
Show file tree
Hide file tree
Showing 54 changed files with 2,824 additions and 2,130 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,9 @@ winapi = "0.2"
hamcrest = "0.1"
bufstream = "0.1"
filetime = "0.1"
cargotest = { path = "tests/cargotest" }

[[bin]]
name = "cargo"
test = false
doc = false

[[test]]
name = "tests"

[[test]]
name = "resolve"
104 changes: 62 additions & 42 deletions tests/test_bad_config.rs → tests/bad-config.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use support::{project, execs};
use support::registry::Package;
use hamcrest::assert_that;
extern crate cargotest;
extern crate hamcrest;

fn setup() {}
use cargotest::support::{project, execs};
use cargotest::support::registry::Package;
use hamcrest::assert_that;

test!(bad1 {
#[test]
fn bad1() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -23,9 +25,10 @@ test!(bad1 {
[ERROR] expected table for configuration key `target.nonexistent-target`, \
but found string in [..]config
"));
});
}

test!(bad2 {
#[test]
fn bad2() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand Down Expand Up @@ -54,9 +57,10 @@ Caused by:
Caused by:
found TOML configuration value of unknown type `float`
"));
});
}

test!(bad3 {
#[test]
fn bad3() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -75,9 +79,10 @@ test!(bad3 {
[ERROR] invalid configuration for key `http.proxy`
expected a string, but found a boolean in [..]config
"));
});
}

test!(bad4 {
#[test]
fn bad4() {
let foo = project("foo")
.file(".cargo/config", r#"
[cargo-new]
Expand All @@ -91,9 +96,10 @@ Caused by:
invalid configuration for key `cargo-new.name`
expected a string, but found a boolean in [..]config
"));
});
}

test!(bad5 {
#[test]
fn bad5() {
let foo = project("foo")
.file(".cargo/config", r#"
foo = ""
Expand All @@ -115,9 +121,10 @@ Caused by:
Caused by:
expected integer, but found string
"));
});
}

test!(bad_cargo_config_jobs {
#[test]
fn bad_cargo_config_jobs() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -134,9 +141,10 @@ test!(bad_cargo_config_jobs {
execs().with_status(101).with_stderr("\
[ERROR] build.jobs must be positive, but found -1 in [..]
"));
});
}

test!(default_cargo_config_jobs {
#[test]
fn default_cargo_config_jobs() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -151,9 +159,10 @@ test!(default_cargo_config_jobs {
"#);
assert_that(foo.cargo_process("build").arg("-v"),
execs().with_status(0));
});
}

test!(good_cargo_config_jobs {
#[test]
fn good_cargo_config_jobs() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -168,9 +177,10 @@ test!(good_cargo_config_jobs {
"#);
assert_that(foo.cargo_process("build").arg("-v"),
execs().with_status(0));
});
}

test!(invalid_global_config {
#[test]
fn invalid_global_config() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -196,9 +206,10 @@ Caused by:
[..]config:1:2 expected `=`, but found eof
"));
});
}

test!(bad_cargo_lock {
#[test]
fn bad_cargo_lock() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -216,9 +227,10 @@ test!(bad_cargo_lock {
Caused by:
expected a section for the key `root`
"));
});
}

test!(bad_git_dependency {
#[test]
fn bad_git_dependency() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -242,9 +254,10 @@ Caused by:
Caused by:
[[..]] 'file:///' is not a valid local file URI
"));
});
}

test!(bad_crate_type {
#[test]
fn bad_crate_type() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -263,9 +276,10 @@ warning: crate-type \"bad_type\" was not one of lib|rlib|dylib|staticlib
[COMPILING] foo v0.0.0 (file:///[..])
[RUNNING] `rustc [..] --crate-type rlib [..]`
"));
});
}

test!(malformed_override {
#[test]
fn malformed_override() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -289,9 +303,10 @@ Caused by:
Cargo.toml:[..]
"));
});
}

test!(duplicate_binary_names {
#[test]
fn duplicate_binary_names() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -317,9 +332,10 @@ test!(duplicate_binary_names {
Caused by:
found duplicate binary name e, but all binary targets must have a unique name
"));
});
}

test!(duplicate_example_names {
#[test]
fn duplicate_example_names() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -345,9 +361,10 @@ test!(duplicate_example_names {
Caused by:
found duplicate example name ex, but all binary targets must have a unique name
"));
});
}

test!(duplicate_bench_names {
#[test]
fn duplicate_bench_names() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -373,9 +390,10 @@ test!(duplicate_bench_names {
Caused by:
found duplicate bench name ex, but all binary targets must have a unique name
"));
});
}

test!(duplicate_deps {
#[test]
fn duplicate_deps() {
let foo = project("foo")
.file("shim-bar/Cargo.toml", r#"
[package]
Expand Down Expand Up @@ -416,9 +434,10 @@ test!(duplicate_deps {
Caused by:
found duplicate dependency name bar, but all dependencies must have a unique name
"));
});
}

test!(unused_keys {
#[test]
fn unused_keys() {
let foo = project("foo")
.file("Cargo.toml", r#"
[package]
Expand All @@ -436,9 +455,10 @@ test!(unused_keys {
warning: unused manifest key: target.foo.bar
[COMPILING] foo v0.1.0 (file:///[..])
"));
});
}

test!(empty_dependencies {
#[test]
fn empty_dependencies() {
let p = project("empty_deps")
.file("Cargo.toml", r#"
[package]
Expand All @@ -458,4 +478,4 @@ test!(empty_dependencies {
warning: dependency (foo) specified without providing a local path, Git repository, or version \
to use. This will be considered an error in future versions
"));
});
}
Loading

0 comments on commit 07c1d99

Please sign in to comment.