git push -f https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
env:
global:
- secure: scGpeetUfba5RWyuS4yt10bPoFAI9wpHEReIFqEx7eH5vr2Anajk6+70jW6GdrWVdUvdINiArlQ3An2DeB9vEUWcBjw8WvuPtOH0tDMoSsuVloPlFD8yn1Ac0Bx9getAO5ofxqtoNg+OV4MDVuGabEesqAOWqURNrBC7XK+ntC8=
+ - secure: scGpeetUfba5RWyuS4yt10bPoFAI9wpHEReIFqEx7eH5vr2Anajk6+70jW6GdrWVdUvdINiArlQ3An2DeB9vEUWcBjw8WvuPtOH0tDMoSsuVloPlFD8yn1Ac0Bx9getAO5ofxqtoNg+OV4MDVuGabEesqAOWqURNrBC7XK+ntC8=
+ - RUST_TEST_THREADS=1
os:
- linux
- osx
flag_package: Option<String>,
flag_jobs: Option<u32>,
flag_features: Vec<String>,
- flag_bench: Option<String>,
flag_no_default_features: bool,
flag_target: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_lib: bool,
+ flag_bin: Vec<String>,
+ flag_example: Vec<String>,
+ flag_test: Vec<String>,
+ flag_bench: Vec<String>,
arg_args: Vec<String>,
}
Options:
-h, --help Print this message
- --bench NAME Name of the bench to run
+ --lib Benchmark only this package's library
+ --bin NAME Benchmark only the specified binary
+ --example NAME Benchmark only the specified example
+ --test NAME Benchmark only the specified test
+ --bench NAME Benchmark only the specified bench
--no-run Compile, but don't run benchmarks
-p SPEC, --package SPEC Package to run benchmarks for
-j N, --jobs N The number of jobs to run in parallel
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
config.shell().set_verbose(options.flag_verbose);
- let mut benches = Vec::new();
- if let Some(s) = options.flag_bench {
- benches.push(s);
- }
-
let ops = ops::TestOptions {
no_run: options.flag_no_run,
compile_opts: ops::CompileOptions {
exec_engine: None,
release: true,
mode: ops::CompileMode::Bench,
- filter: if benches.is_empty() {
- ops::CompileFilter::Everything
- } else {
- ops::CompileFilter::Only {
- lib: false, bins: &[], examples: &[], tests: &[],
- benches: &benches,
- }
- },
+ filter: ops::CompileFilter::new(options.flag_lib,
+ &options.flag_bin,
+ &options.flag_test,
+ &options.flag_example,
+ &options.flag_bench),
},
};
flag_manifest_path: Option<String>,
flag_verbose: bool,
flag_release: bool,
- flag_lib: bool
+ flag_lib: bool,
+ flag_bin: Vec<String>,
+ flag_example: Vec<String>,
+ flag_test: Vec<String>,
+ flag_bench: Vec<String>,
}
pub const USAGE: &'static str = "
-h, --help Print this message
-p SPEC, --package SPEC Package to build
-j N, --jobs N The number of jobs to run in parallel
- --lib Build only lib (if present in package)
+ --lib Build only this package's library
+ --bin NAME Build only the specified binary
+ --example NAME Build only the specified example
+ --test NAME Build only the specified test
+ --bench NAME Build only the specified benchmark
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
exec_engine: None,
mode: ops::CompileMode::Build,
release: options.flag_release,
- filter: if options.flag_lib {
- ops::CompileFilter::Only {
- lib: true, bins: &[], examples: &[], benches: &[], tests: &[]
- }
- } else {
- ops::CompileFilter::Everything
- },
+ filter: ops::CompileFilter::new(options.flag_lib,
+ &options.flag_bin,
+ &options.flag_test,
+ &options.flag_example,
+ &options.flag_bench),
};
ops::compile(&root, &opts).map(|_| None).map_err(|err| {
flag_features: Vec<String>,
flag_jobs: Option<u32>,
flag_manifest_path: Option<String>,
- flag_test: Option<String>,
- flag_bin: Option<String>,
flag_no_default_features: bool,
flag_no_run: bool,
flag_package: Option<String>,
flag_target: Option<String>,
+ flag_lib: bool,
+ flag_bin: Vec<String>,
+ flag_example: Vec<String>,
+ flag_test: Vec<String>,
+ flag_bench: Vec<String>,
flag_verbose: bool,
}
Options:
-h, --help Print this message
- --test NAME Name of the integration test to run
- --bin NAME Name of the binary to run tests for
+ --lib Test only this package's library
+ --bin NAME Test only the specified binary
+ --example NAME Test only the specified example
+ --test NAME Test only the specified integration test
+ --bench NAME Test only the specified benchmark
--no-run Compile, but don't run tests
-p SPEC, --package SPEC Package to run tests for
-j N, --jobs N The number of jobs to run in parallel
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
config.shell().set_verbose(options.flag_verbose);
- let (mut tests, mut bins) = (Vec::new(), Vec::new());
- if let Some(s) = options.flag_test {
- tests.push(s);
- }
- if let Some(s) = options.flag_bin {
- bins.push(s);
- }
-
let ops = ops::TestOptions {
no_run: options.flag_no_run,
compile_opts: ops::CompileOptions {
exec_engine: None,
release: false,
mode: ops::CompileMode::Test,
- filter: if tests.is_empty() && bins.is_empty() {
- ops::CompileFilter::Everything
- } else {
- ops::CompileFilter::Only {
- lib: false, examples: &[], benches: &[],
- tests: &tests, bins: &bins,
- }
- }
+ filter: ops::CompileFilter::new(options.flag_lib,
+ &options.flag_bin,
+ &options.flag_test,
+ &options.flag_example,
+ &options.flag_bench),
},
};
}
impl<'a> CompileFilter<'a> {
+ pub fn new(lib_only: bool,
+ bins: &'a [String],
+ tests: &'a [String],
+ examples: &'a [String],
+ benches: &'a [String]) -> CompileFilter<'a> {
+ if lib_only || !bins.is_empty() || !tests.is_empty() ||
+ !examples.is_empty() || !benches.is_empty() {
+ CompileFilter::Only {
+ lib: lib_only, bins: bins, examples: examples, benches: benches,
+ tests: tests,
+ }
+ } else {
+ CompileFilter::Everything
+ }
+ }
+
pub fn matches(&self, target: &Target) -> bool {
match *self {
CompileFilter::Everything => true,
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(101));
});
+
+test!(filtering {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ .file("src/bin/a.rs", "fn main() {}")
+ .file("src/bin/b.rs", "fn main() {}")
+ .file("examples/a.rs", "fn main() {}")
+ .file("examples/b.rs", "fn main() {}");
+ p.build();
+
+ assert_that(p.cargo("build").arg("--lib"),
+ execs().with_status(0));
+ assert_that(&p.bin("a"), is_not(existing_file()));
+
+ assert_that(p.cargo("build").arg("--bin=a").arg("--example=a"),
+ execs().with_status(0));
+ assert_that(&p.bin("a"), existing_file());
+ assert_that(&p.bin("b"), is_not(existing_file()));
+ assert_that(&p.bin("examples/a"), existing_file());
+ assert_that(&p.bin("examples/b"), is_not(existing_file()));
+});