mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 03:32:39 +00:00
Add cargo check --all
This'll check all `build` targets for all packages in a workspace
This commit is contained in:
parent
6ed5a43bb5
commit
97c1bba165
|
@ -1,7 +1,7 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use cargo::core::Workspace;
|
use cargo::core::Workspace;
|
||||||
use cargo::ops::{self, CompileOptions, MessageFormat};
|
use cargo::ops::{self, CompileOptions, MessageFormat, Packages};
|
||||||
use cargo::util::{CliResult, Config};
|
use cargo::util::{CliResult, Config};
|
||||||
use cargo::util::important_paths::find_root_manifest_for_wd;
|
use cargo::util::important_paths::find_root_manifest_for_wd;
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@ Usage:
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Print this message
|
-h, --help Print this message
|
||||||
-p SPEC, --package SPEC ... Package to check
|
-p SPEC, --package SPEC ... Package(s) to check
|
||||||
|
--all Check all packages in the workspace
|
||||||
-j N, --jobs N Number of parallel jobs, defaults to # of CPUs
|
-j N, --jobs N Number of parallel jobs, defaults to # of CPUs
|
||||||
--lib Check only this package's library
|
--lib Check only this package's library
|
||||||
--bin NAME Check only the specified binary
|
--bin NAME Check only the specified binary
|
||||||
|
@ -64,6 +65,7 @@ pub struct Options {
|
||||||
flag_bench: Vec<String>,
|
flag_bench: Vec<String>,
|
||||||
flag_locked: bool,
|
flag_locked: bool,
|
||||||
flag_frozen: bool,
|
flag_frozen: bool,
|
||||||
|
flag_all: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(options: Options, config: &Config) -> CliResult {
|
pub fn execute(options: Options, config: &Config) -> CliResult {
|
||||||
|
@ -79,6 +81,12 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
|
||||||
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
|
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
|
||||||
let ws = Workspace::new(&root, config)?;
|
let ws = Workspace::new(&root, config)?;
|
||||||
|
|
||||||
|
let spec = if options.flag_all {
|
||||||
|
Packages::All
|
||||||
|
} else {
|
||||||
|
Packages::Packages(&options.flag_package)
|
||||||
|
};
|
||||||
|
|
||||||
let opts = CompileOptions {
|
let opts = CompileOptions {
|
||||||
config: config,
|
config: config,
|
||||||
jobs: options.flag_jobs,
|
jobs: options.flag_jobs,
|
||||||
|
@ -86,7 +94,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
|
||||||
features: &options.flag_features,
|
features: &options.flag_features,
|
||||||
all_features: options.flag_all_features,
|
all_features: options.flag_all_features,
|
||||||
no_default_features: options.flag_no_default_features,
|
no_default_features: options.flag_no_default_features,
|
||||||
spec: ops::Packages::Packages(&options.flag_package),
|
spec: spec,
|
||||||
mode: ops::CompileMode::Check,
|
mode: ops::CompileMode::Check,
|
||||||
release: options.flag_release,
|
release: options.flag_release,
|
||||||
filter: ops::CompileFilter::new(options.flag_lib,
|
filter: ops::CompileFilter::new(options.flag_lib,
|
||||||
|
|
|
@ -383,3 +383,41 @@ fn rustc_check_err() {
|
||||||
.arg("--emit=metadata"),
|
.arg("--emit=metadata"),
|
||||||
execs().with_status(101));
|
execs().with_status(101));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_all() {
|
||||||
|
if !is_nightly() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let foo = project("foo")
|
||||||
|
.file("Cargo.toml", r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = []
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
[dependencies]
|
||||||
|
b = { path = "b" }
|
||||||
|
"#)
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
.file("examples/a.rs", "fn main() {}")
|
||||||
|
.file("tests/a.rs", "")
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.file("b/Cargo.toml", r#"
|
||||||
|
[package]
|
||||||
|
name = "b"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = []
|
||||||
|
"#)
|
||||||
|
.file("b/src/main.rs", "fn main() {}")
|
||||||
|
.file("b/src/lib.rs", "");
|
||||||
|
|
||||||
|
assert_that(foo.cargo_process("check").arg("--all").arg("-v"),
|
||||||
|
execs().with_status(0)
|
||||||
|
.with_stderr_contains("[..] --crate-name foo src[/]lib.rs [..]")
|
||||||
|
.with_stderr_contains("[..] --crate-name foo src[/]main.rs [..]")
|
||||||
|
.with_stderr_contains("[..] --crate-name b b[/]src[/]lib.rs [..]")
|
||||||
|
.with_stderr_contains("[..] --crate-name b b[/]src[/]main.rs [..]")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue