Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile tests for multiple packages #1828

Merged
merged 7 commits into from
Sep 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/bin/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd};
#[derive(RustcDecodable)]
struct Options {
flag_no_run: bool,
flag_package: Option<String>,
flag_package: Vec<String>,
flag_jobs: Option<u32>,
flag_features: Vec<String>,
flag_no_default_features: bool,
Expand All @@ -29,22 +29,22 @@ Usage:
cargo bench [options] [--] [<args>...]

Options:
-h, --help Print this message
--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 target
--bench NAME Benchmark only the specified bench target
--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
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to build benchmarks for
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
-h, --help Print this message
--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 target
--bench NAME Benchmark only the specified bench target
--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
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to build benchmarks for
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never

All of the trailing arguments are passed to the benchmark binaries generated
for filtering benchmarks and generally providing options configuring how they
Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
target: options.flag_target.as_ref().map(|s| &s[..]),
features: &options.flag_features,
no_default_features: options.flag_no_default_features,
spec: options.flag_package.as_ref().map(|s| &s[..]),
spec: &options.flag_package,
exec_engine: None,
release: true,
mode: ops::CompileMode::Bench,
Expand Down
36 changes: 18 additions & 18 deletions src/bin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cargo::util::{CliResult, CliError, Config};

#[derive(RustcDecodable)]
struct Options {
flag_package: Option<String>,
flag_package: Vec<String>,
flag_jobs: Option<u32>,
flag_features: Vec<String>,
flag_no_default_features: bool,
Expand All @@ -31,22 +31,22 @@ Usage:
cargo build [options]

Options:
-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 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 target
--bench NAME Build only the specified benchmark target
--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
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
-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 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 target
--bench NAME Build only the specified benchmark target
--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
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never

If the --package argument is given, then SPEC is a package id specification
which indicates which package should be built. If it is not given, then the
Expand All @@ -72,7 +72,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
target: options.flag_target.as_ref().map(|t| &t[..]),
features: &options.flag_features,
no_default_features: options.flag_no_default_features,
spec: options.flag_package.as_ref().map(|s| &s[..]),
spec: &options.flag_package,
exec_engine: None,
mode: ops::CompileMode::Build,
release: options.flag_release,
Expand Down
18 changes: 9 additions & 9 deletions src/bin/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd};

#[derive(RustcDecodable)]
struct Options {
flag_package: Option<String>,
flag_package: Vec<String>,
flag_target: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
Expand All @@ -21,13 +21,13 @@ Usage:
cargo clean [options]

Options:
-h, --help Print this message
-p SPEC, --package SPEC Package to clean artifacts for
--manifest-path PATH Path to the manifest to the package to clean
--target TRIPLE Target triple to clean output for (default all)
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
-h, --help Print this message
-p SPEC, --package SPEC ... Package to clean artifacts for
--manifest-path PATH Path to the manifest to the package to clean
--target TRIPLE Target triple to clean output for (default all)
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never

If the --package argument is given, then SPEC is a package id specification
which indicates which package's artifacts should be cleaned out. If it is not
Expand All @@ -43,7 +43,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
let opts = ops::CleanOptions {
config: config,
spec: options.flag_package.as_ref().map(|s| &s[..]),
spec: &options.flag_package,
target: options.flag_target.as_ref().map(|s| &s[..]),
};
ops::clean(&root, &opts).map(|_| None).map_err(|err| {
Expand Down
30 changes: 15 additions & 15 deletions src/bin/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct Options {
flag_release: bool,
flag_quiet: bool,
flag_color: Option<String>,
flag_package: Option<String>,
flag_package: Vec<String>,
}

pub const USAGE: &'static str = "
Expand All @@ -25,19 +25,19 @@ Usage:
cargo doc [options]

Options:
-h, --help Print this message
--open Opens the docs in a browser after the operation
-p SPEC, --package SPEC Package to document
--no-deps Don't build documentation for dependencies
-j N, --jobs N The number of jobs to run in parallel
--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
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to document
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
-h, --help Print this message
--open Opens the docs in a browser after the operation
-p SPEC, --package SPEC ... Package to document
--no-deps Don't build documentation for dependencies
-j N, --jobs N The number of jobs to run in parallel
--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
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to document
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never

By default the documentation for the local package and all dependencies is
built. The output is all placed in `target/doc` in rustdoc's usual format.
Expand All @@ -62,7 +62,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
target: options.flag_target.as_ref().map(|t| &t[..]),
features: &options.flag_features,
no_default_features: options.flag_no_default_features,
spec: options.flag_package.as_ref().map(|s| &s[..]),
spec: &options.flag_package,
exec_engine: None,
filter: ops::CompileFilter::Everything,
release: options.flag_release,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
target: options.flag_target.as_ref().map(|t| &t[..]),
features: &options.flag_features,
no_default_features: options.flag_no_default_features,
spec: None,
spec: &[],
exec_engine: None,
release: options.flag_release,
mode: ops::CompileMode::Build,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
target: options.flag_target.as_ref().map(|t| &t[..]),
features: &options.flag_features,
no_default_features: options.flag_no_default_features,
spec: options.flag_package.as_ref().map(|s| &s[..]),
spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]),
exec_engine: None,
mode: ops::CompileMode::Build,
release: options.flag_release,
Expand Down
40 changes: 20 additions & 20 deletions src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct Options {
flag_manifest_path: Option<String>,
flag_no_default_features: bool,
flag_no_run: bool,
flag_package: Option<String>,
flag_package: Vec<String>,
flag_target: Option<String>,
flag_lib: bool,
flag_bin: Vec<String>,
Expand All @@ -31,24 +31,24 @@ Usage:
cargo test [options] [--] [<args>...]

Options:
-h, --help Print this message
--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 target
--bench NAME Test only the specified benchmark target
--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
--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
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to build tests for
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--no-fail-fast Run all tests regardless of failure
-h, --help Print this message
--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 target
--bench NAME Test only the specified benchmark target
--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
--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
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to build tests for
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--no-fail-fast Run all tests regardless of failure

All of the trailing arguments are passed to the test binaries generated for
filtering tests and generally providing options configuring how they run. For
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
target: options.flag_target.as_ref().map(|s| &s[..]),
features: &options.flag_features,
no_default_features: options.flag_no_default_features,
spec: options.flag_package.as_ref().map(|s| &s[..]),
spec: &options.flag_package,
exec_engine: None,
release: options.flag_release,
mode: ops::CompileMode::Test,
Expand Down
22 changes: 10 additions & 12 deletions src/bin/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cargo::util::important_paths::find_root_manifest_for_cwd;

#[derive(RustcDecodable)]
struct Options {
flag_package: Option<String>,
flag_package: Vec<String>,
flag_aggressive: bool,
flag_precise: Option<String>,
flag_manifest_path: Option<String>,
Expand All @@ -22,14 +22,14 @@ Usage:
cargo update [options]

Options:
-h, --help Print this message
-p SPEC, --package SPEC Package to update
--aggressive Force updating all dependencies of <name> as well
--precise PRECISE Update a single dependency to exactly PRECISE
--manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
-h, --help Print this message
-p SPEC, --package SPEC ... Package to update
--aggressive Force updating all dependencies of <name> as well
--precise PRECISE Update a single dependency to exactly PRECISE
--manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never

This command requires that a `Cargo.lock` already exists as generated by
`cargo build` or related commands.
Expand Down Expand Up @@ -58,12 +58,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));

let spec = options.flag_package.as_ref();

let update_opts = ops::UpdateOptions {
aggressive: options.flag_aggressive,
precise: options.flag_precise.as_ref().map(|s| &s[..]),
to_update: spec.map(|s| &s[..]),
to_update: &options.flag_package,
config: config,
};

Expand Down
8 changes: 4 additions & 4 deletions src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'cfg> PackageRegistry<'cfg> {
self.sources
}

fn ensure_loaded(&mut self, namespace: &SourceId) -> CargoResult<()> {
fn ensure_loaded(&mut self, namespace: &SourceId, kind: Kind) -> CargoResult<()> {
match self.source_ids.get(namespace) {
// We've previously loaded this source, and we've already locked it,
// so we're not allowed to change it even if `namespace` has a
Expand Down Expand Up @@ -143,13 +143,13 @@ impl<'cfg> PackageRegistry<'cfg> {
}
}

try!(self.load(namespace, Kind::Normal));
try!(self.load(namespace, kind));
Ok(())
}

pub fn add_sources(&mut self, ids: &[SourceId]) -> CargoResult<()> {
for id in ids.iter() {
try!(self.load(id, Kind::Locked));
try!(self.ensure_loaded(id, Kind::Locked));
}
Ok(())
}
Expand Down Expand Up @@ -288,7 +288,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {

let ret = if overrides.len() == 0 {
// Ensure the requested source_id is loaded
try!(self.ensure_loaded(dep.source_id()));
try!(self.ensure_loaded(dep.source_id(), Kind::Normal));
let mut ret = Vec::new();
for (id, src) in self.sources.sources_mut() {
if id == dep.source_id() {
Expand Down
Loading