mirror of https://github.com/rust-lang/cargo
Minor testsuite organization.
This commit is contained in:
parent
750cb1482e
commit
83571aee56
|
@ -1,3 +1,14 @@
|
|||
//! Support for cross-compile tests with the `--target` flag.
|
||||
//!
|
||||
//! Note that cross-testing is very limited. You need to install the
|
||||
//! "alternate" target to the host (32-bit for 64-bit hosts or vice-versa).
|
||||
//!
|
||||
//! Set CFG_DISABLE_CROSS_TESTS=1 environment variable to disable these tests
|
||||
//! if you are unable to use the alternate target. Unfortunately 32-bit
|
||||
//! support on macOS is going away, so macOS users are out of luck.
|
||||
//!
|
||||
//! These tests are all disabled on rust-lang/rust's CI, but run in Cargo's CI.
|
||||
|
||||
use crate::{basic_bin_manifest, main_file, project};
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for alternative registries.
|
||||
|
||||
use cargo::util::IntoUrl;
|
||||
use cargo_test_support::publish::validate_alt_upload;
|
||||
use cargo_test_support::registry::{self, Package};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for some invalid .cargo/config files.
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for invalid --manifest-path arguments.
|
||||
|
||||
use cargo_test_support::{basic_bin_manifest, main_file, project};
|
||||
|
||||
fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo bench` command.
|
||||
|
||||
use cargo_test_support::is_nightly;
|
||||
use cargo_test_support::paths::CargoPathExt;
|
||||
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo build` command.
|
||||
|
||||
use cargo::util::paths::dylib_path_envvar;
|
||||
use cargo_test_support::paths::{root, CargoPathExt};
|
||||
use cargo_test_support::registry::Package;
|
||||
|
@ -4607,3 +4609,65 @@ d
|
|||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn build_lib_only() {
|
||||
let p = project()
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("src/lib.rs", r#" "#)
|
||||
.build();
|
||||
|
||||
p.cargo("build --lib -v")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link -C debuginfo=2 \
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn build_with_no_lib() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build --lib")
|
||||
.with_status(101)
|
||||
.with_stderr("[ERROR] no library targets found in package `foo`")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn build_with_relative_cargo_home_path() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = ["wycats@example.com"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
"test-dependency" = { path = "src/test_dependency" }
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("src/test_dependency/src/lib.rs", r#" "#)
|
||||
.file(
|
||||
"src/test_dependency/Cargo.toml",
|
||||
&basic_manifest("test-dependency", "0.0.1"),
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build").env("CARGO_HOME", "./cargo_home/").run();
|
||||
}
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
use cargo_test_support::{basic_bin_manifest, basic_manifest, project};
|
||||
|
||||
#[cargo_test]
|
||||
fn build_lib_only() {
|
||||
let p = project()
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("src/lib.rs", r#" "#)
|
||||
.build();
|
||||
|
||||
p.cargo("build --lib -v")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link -C debuginfo=2 \
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn build_with_no_lib() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build --lib")
|
||||
.with_status(101)
|
||||
.with_stderr("[ERROR] no library targets found in package `foo`")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn build_with_relative_cargo_home_path() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = ["wycats@example.com"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
"test-dependency" = { path = "src/test_dependency" }
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("src/test_dependency/src/lib.rs", r#" "#)
|
||||
.file(
|
||||
"src/test_dependency/Cargo.toml",
|
||||
&basic_manifest("test-dependency", "0.0.1"),
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build").env("CARGO_HOME", "./cargo_home/").run();
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for --build-plan feature.
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{basic_bin_manifest, basic_manifest, main_file, project};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for build.rs scripts.
|
||||
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for build.rs rerun-if-env-changed.
|
||||
|
||||
use std::fs::File;
|
||||
|
||||
use cargo_test_support::project;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for caching compiler diagnostics.
|
||||
|
||||
use cargo_test_support::{
|
||||
clippy_is_available, is_coarse_mtime, process, project, registry::Package, sleep_ms,
|
||||
};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for `[alias]` config command aliases.
|
||||
|
||||
use cargo_test_support::{basic_bin_manifest, project};
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for custom cargo commands and other global command features.
|
||||
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for `cargo-features` definitions.
|
||||
|
||||
use cargo_test_support::{project, registry};
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for cfg() expressions.
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::rustc_host;
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo check` command.
|
||||
|
||||
use std::fmt::{self, Write};
|
||||
|
||||
use cargo_test_support::install::exe;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo clean` command.
|
||||
|
||||
use std::env;
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo clippy` command.
|
||||
|
||||
use cargo_test_support::{clippy_is_available, project, registry::Package};
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
//! Tests for when multiple artifacts have the same output filename.
|
||||
//! See https://github.com/rust-lang/cargo/issues/6313 for more details.
|
||||
//! Ideally these should never happen, but I don't think we'll ever be able to
|
||||
//! prevent all collisions.
|
||||
|
||||
use cargo_test_support::basic_manifest;
|
||||
use cargo_test_support::project;
|
||||
use std::env;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for running multiple `cargo` processes at the same time.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
use std::net::TcpListener;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for config settings.
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use std::collections;
|
||||
use std::fs;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for corrupt git repos.
|
||||
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
//! Tests for cross compiling with --target.
|
||||
//!
|
||||
//! See `cargo_test_support::cross_compile` for more detail.
|
||||
|
||||
use cargo_test_support::{basic_bin_manifest, basic_manifest, cross_compile, project};
|
||||
use cargo_test_support::{is_nightly, rustc_host};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for publishing using the `--target` flag.
|
||||
|
||||
use std::fs::File;
|
||||
|
||||
use cargo_test_support::{cross_compile, project, publish, registry};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for custom json target specifications.
|
||||
|
||||
use cargo_test_support::is_nightly;
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for ctrl-C handling.
|
||||
|
||||
use std::fs;
|
||||
use std::io::{self, Read};
|
||||
use std::net::TcpListener;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
//! Tests for dep-info files. This includes the dep-info file Cargo creates in
|
||||
//! the output directory, and the ones stored in the fingerprint.
|
||||
|
||||
use cargo_test_support::paths::{self, CargoPathExt};
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for directory sources.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo doc` command.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::Read;
|
||||
use std::str;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for edition setting.
|
||||
|
||||
use cargo_test_support::{basic_lib_manifest, project};
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for `[features]` table.
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo fetch` command.
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::rustc_host;
|
||||
use cargo_test_support::{basic_manifest, cross_compile, project};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo fix` command.
|
||||
|
||||
use std::fs::File;
|
||||
|
||||
use cargo_test_support::git;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for fingerprinting (rebuild detection).
|
||||
|
||||
use filetime::FileTime;
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::io;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo generate-lockfile` command.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for git support.
|
||||
|
||||
use git2;
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for git authentication.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::io::prelude::*;
|
||||
use std::io::BufReader;
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for git garbage collection.
|
||||
|
||||
use std::env;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo init` command.
|
||||
|
||||
use cargo_test_support;
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo install` command.
|
||||
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::io::prelude::*;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for `cargo install` where it upgrades a package if it is out-of-date.
|
||||
|
||||
use cargo::core::PackageId;
|
||||
use std::collections::BTreeSet;
|
||||
use std::env;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the jobserver protocol.
|
||||
|
||||
use std::net::TcpListener;
|
||||
use std::process::Command;
|
||||
use std::thread;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for target filter flags giving suggestions on which targets are available.
|
||||
|
||||
use cargo_test_support::project;
|
||||
|
||||
const EXAMPLE: u8 = 0x1;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for local-registry sources.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for supporting older versions of the Cargo.lock file format.
|
||||
|
||||
use cargo_test_support::git;
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{basic_manifest, lines_match, project};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo login` command.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
@ -16,8 +16,6 @@ mod bad_config;
|
|||
mod bad_manifest_path;
|
||||
mod bench;
|
||||
mod build;
|
||||
mod build_auth;
|
||||
mod build_lib;
|
||||
mod build_plan;
|
||||
mod build_script;
|
||||
mod build_script_env;
|
||||
|
@ -47,6 +45,8 @@ mod fix;
|
|||
mod freshness;
|
||||
mod generate_lockfile;
|
||||
mod git;
|
||||
mod git_auth;
|
||||
mod git_gc;
|
||||
mod init;
|
||||
mod install;
|
||||
mod install_upgrade;
|
||||
|
@ -59,14 +59,15 @@ mod member_errors;
|
|||
mod message_format;
|
||||
mod metabuild;
|
||||
mod metadata;
|
||||
mod minimal_versions;
|
||||
mod net_config;
|
||||
mod new;
|
||||
mod offline;
|
||||
mod out_dir;
|
||||
mod overrides;
|
||||
mod package;
|
||||
mod patch;
|
||||
mod path;
|
||||
mod paths;
|
||||
mod plugins;
|
||||
mod proc_macro;
|
||||
mod profile_config;
|
||||
|
@ -80,8 +81,8 @@ mod publish_lockfile;
|
|||
mod read_manifest;
|
||||
mod registry;
|
||||
mod rename_deps;
|
||||
mod replace;
|
||||
mod required_features;
|
||||
mod resolve;
|
||||
mod run;
|
||||
mod rustc;
|
||||
mod rustc_info_cache;
|
||||
|
@ -90,7 +91,6 @@ mod rustdocflags;
|
|||
mod rustflags;
|
||||
mod search;
|
||||
mod shell_quoting;
|
||||
mod small_fd_limits;
|
||||
mod standard_lib;
|
||||
mod test;
|
||||
mod timings;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for workspace member errors.
|
||||
|
||||
use cargo::core::resolver::ResolveError;
|
||||
use cargo::core::{compiler::CompileMode, Shell, Workspace};
|
||||
use cargo::ops::{self, CompileOptions};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for --message-format flag.
|
||||
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the metabuild feature (declarative build scripts).
|
||||
|
||||
use cargo_test_support::{
|
||||
basic_lib_manifest, basic_manifest, is_coarse_mtime, project, registry::Package, rustc_host,
|
||||
Project,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo metadata` command.
|
||||
|
||||
use cargo_test_support::cross_compile::alternate;
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, main_file, project, rustc_host};
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
//! Tests for minimal-version resolution.
|
||||
//!
|
||||
//! Note: Some tests are located in the resolver-tests package.
|
||||
|
||||
use cargo_test_support::project;
|
||||
use cargo_test_support::registry::Package;
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for network configuration.
|
||||
|
||||
use cargo_test_support::project;
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo new` command.
|
||||
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for --offline flag.
|
||||
|
||||
use cargo_test_support::{basic_manifest, git, main_file, path2url, project, registry::Package};
|
||||
use std::fs;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for --out-dir flag.
|
||||
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::path::Path;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo package` command.
|
||||
|
||||
use std;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for `[patch]` table source replacement.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::{Read, Write};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for `path` dependencies.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
||||
|
@ -1015,32 +1017,3 @@ fn workspace_produces_rlib() {
|
|||
assert!(p.root().join("target/debug/libtop.rlib").is_file());
|
||||
assert!(!p.root().join("target/debug/libfoo.rlib").is_file());
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn thin_lto_works() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[project]
|
||||
name = "top"
|
||||
version = "0.5.0"
|
||||
authors = []
|
||||
|
||||
[profile.release]
|
||||
lto = 'thin'
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build --release -v")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] top [..]
|
||||
[RUNNING] `rustc [..] -C lto=thin [..]`
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,226 @@
|
|||
//! Tests for `paths` overrides.
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
|
||||
#[cargo_test]
|
||||
fn broken_path_override_warns() {
|
||||
Package::new("bar", "0.1.0").publish();
|
||||
Package::new("bar", "0.2.0").publish();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
a = { path = "a1" }
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file(
|
||||
"a1/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "a"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = "0.1"
|
||||
"#,
|
||||
)
|
||||
.file("a1/src/lib.rs", "")
|
||||
.file(
|
||||
"a2/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "a"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = "0.2"
|
||||
"#,
|
||||
)
|
||||
.file("a2/src/lib.rs", "")
|
||||
.file(".cargo/config", r#"paths = ["a2"]"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] [..]
|
||||
warning: path override for crate `a` has altered the original list of
|
||||
dependencies; the dependency on `bar` was either added or
|
||||
modified to not match the previously resolved version
|
||||
|
||||
This is currently allowed but is known to produce buggy behavior with spurious
|
||||
recompiles and changes to the crate graph. Path overrides unfortunately were
|
||||
never intended to support this feature, so for now this message is just a
|
||||
warning. In the future, however, this message will become a hard error.
|
||||
|
||||
To change the dependency graph via an override it's recommended to use the
|
||||
`[replace]` feature of Cargo instead of the path override feature. This is
|
||||
documented online at the url below for more information.
|
||||
|
||||
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#overriding-dependencies
|
||||
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] [..]
|
||||
[COMPILING] [..]
|
||||
[COMPILING] [..]
|
||||
[COMPILING] [..]
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn override_to_path_dep() {
|
||||
Package::new("bar", "0.1.0").dep("baz", "0.1").publish();
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = "0.1.0"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file(
|
||||
"bar/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
baz = { path = "baz" }
|
||||
"#,
|
||||
)
|
||||
.file("bar/src/lib.rs", "")
|
||||
.file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.0.1"))
|
||||
.file("bar/baz/src/lib.rs", "")
|
||||
.file(".cargo/config", r#"paths = ["bar"]"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build").run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn paths_ok_with_optional() {
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = { path = "bar" }
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file(
|
||||
"bar/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1", optional = true }
|
||||
"#,
|
||||
)
|
||||
.file("bar/src/lib.rs", "")
|
||||
.file(
|
||||
"bar2/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1", optional = true }
|
||||
"#,
|
||||
)
|
||||
.file("bar2/src/lib.rs", "")
|
||||
.file(".cargo/config", r#"paths = ["bar2"]"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] bar v0.1.0 ([..]bar2)
|
||||
[COMPILING] foo v0.0.1 ([..])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn paths_add_optional_bad() {
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = { path = "bar" }
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("bar/src/lib.rs", "")
|
||||
.file(
|
||||
"bar2/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1", optional = true }
|
||||
"#,
|
||||
)
|
||||
.file("bar2/src/lib.rs", "")
|
||||
.file(".cargo/config", r#"paths = ["bar2"]"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
warning: path override for crate `bar` has altered the original list of
|
||||
dependencies; the dependency on `baz` was either added or\
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for rustc plugins.
|
||||
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
use cargo_test_support::{is_nightly, rustc_host};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for proc-macros.
|
||||
|
||||
use cargo_test_support::is_nightly;
|
||||
use cargo_test_support::project;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for profiles defined in config files.
|
||||
|
||||
use cargo_test_support::{basic_lib_manifest, paths, project};
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for named profiles.
|
||||
|
||||
use cargo_test_support::{basic_lib_manifest, project};
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for profile overrides (build-override and per-package overrides).
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{basic_lib_manifest, basic_manifest, project};
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use cargo_test_support::{basic_manifest, is_nightly, project, Project};
|
||||
//! Tests for checking exactly how profiles correspond with each unit. For
|
||||
//! example, the `test` profile applying to test targets, but not other
|
||||
//! targets, etc.
|
||||
|
||||
// These tests try to exercise exactly which profiles are selected for every target.
|
||||
use cargo_test_support::{basic_manifest, is_nightly, project, Project};
|
||||
|
||||
fn all_target_project() -> Project {
|
||||
// This abuses the `codegen-units` setting so that we can verify exactly
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for profiles.
|
||||
|
||||
use std::env;
|
||||
|
||||
use cargo_test_support::project;
|
||||
|
@ -437,3 +439,32 @@ fn debug_0_report() {
|
|||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn thin_lto_works() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[project]
|
||||
name = "top"
|
||||
version = "0.5.0"
|
||||
authors = []
|
||||
|
||||
[profile.release]
|
||||
lto = 'thin'
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build --release -v")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] top [..]
|
||||
[RUNNING] `rustc [..] -C lto=thin [..]`
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for public/private dependencies.
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{is_nightly, project};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo publish` command.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for including `Cargo.lock` when publishing/packaging.
|
||||
|
||||
use std;
|
||||
use std::fs::File;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo read-manifest` command.
|
||||
|
||||
use cargo_test_support::{basic_bin_manifest, main_file, project};
|
||||
|
||||
static MANIFEST_OUTPUT: &str = r#"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for normal registry dependencies.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for renaming dependencies.
|
||||
|
||||
use cargo_test_support::git;
|
||||
use cargo_test_support::paths;
|
||||
use cargo_test_support::registry::Package;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for `[replace]` table source replacement.
|
||||
|
||||
use cargo_test_support::git;
|
||||
use cargo_test_support::paths;
|
||||
use cargo_test_support::registry::Package;
|
||||
|
@ -813,84 +815,6 @@ fn no_override_self() {
|
|||
p.cargo("build --verbose").run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn broken_path_override_warns() {
|
||||
Package::new("bar", "0.1.0").publish();
|
||||
Package::new("bar", "0.2.0").publish();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
a = { path = "a1" }
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file(
|
||||
"a1/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "a"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = "0.1"
|
||||
"#,
|
||||
)
|
||||
.file("a1/src/lib.rs", "")
|
||||
.file(
|
||||
"a2/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "a"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = "0.2"
|
||||
"#,
|
||||
)
|
||||
.file("a2/src/lib.rs", "")
|
||||
.file(".cargo/config", r#"paths = ["a2"]"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] [..]
|
||||
warning: path override for crate `a` has altered the original list of
|
||||
dependencies; the dependency on `bar` was either added or
|
||||
modified to not match the previously resolved version
|
||||
|
||||
This is currently allowed but is known to produce buggy behavior with spurious
|
||||
recompiles and changes to the crate graph. Path overrides unfortunately were
|
||||
never intended to support this feature, so for now this message is just a
|
||||
warning. In the future, however, this message will become a hard error.
|
||||
|
||||
To change the dependency graph via an override it's recommended to use the
|
||||
`[replace]` feature of Cargo instead of the path override feature. This is
|
||||
documented online at the url below for more information.
|
||||
|
||||
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#overriding-dependencies
|
||||
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] [..]
|
||||
[COMPILING] [..]
|
||||
[COMPILING] [..]
|
||||
[COMPILING] [..]
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn override_an_override() {
|
||||
Package::new("chrono", "0.2.0")
|
||||
|
@ -1118,46 +1042,6 @@ fn no_warnings_when_replace_is_used_in_another_workspace_member() {
|
|||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn override_to_path_dep() {
|
||||
Package::new("bar", "0.1.0").dep("baz", "0.1").publish();
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = "0.1.0"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file(
|
||||
"bar/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
baz = { path = "baz" }
|
||||
"#,
|
||||
)
|
||||
.file("bar/src/lib.rs", "")
|
||||
.file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.0.1"))
|
||||
.file("bar/baz/src/lib.rs", "")
|
||||
.file(".cargo/config", r#"paths = ["bar"]"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build").run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn replace_to_path_dep() {
|
||||
Package::new("bar", "0.1.0").dep("baz", "0.1").publish();
|
||||
|
@ -1203,110 +1087,6 @@ fn replace_to_path_dep() {
|
|||
p.cargo("build").run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn paths_ok_with_optional() {
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = { path = "bar" }
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file(
|
||||
"bar/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1", optional = true }
|
||||
"#,
|
||||
)
|
||||
.file("bar/src/lib.rs", "")
|
||||
.file(
|
||||
"bar2/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1", optional = true }
|
||||
"#,
|
||||
)
|
||||
.file("bar2/src/lib.rs", "")
|
||||
.file(".cargo/config", r#"paths = ["bar2"]"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] bar v0.1.0 ([..]bar2)
|
||||
[COMPILING] foo v0.0.1 ([..])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn paths_add_optional_bad() {
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = { path = "bar" }
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("bar/src/lib.rs", "")
|
||||
.file(
|
||||
"bar2/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1", optional = true }
|
||||
"#,
|
||||
)
|
||||
.file("bar2/src/lib.rs", "")
|
||||
.file(".cargo/config", r#"paths = ["bar2"]"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
warning: path override for crate `bar` has altered the original list of
|
||||
dependencies; the dependency on `baz` was either added or\
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn override_with_default_feature() {
|
||||
Package::new("another", "0.1.0").publish();
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for targets with `required-features`.
|
||||
|
||||
use cargo_test_support::install::{
|
||||
assert_has_installed_exe, assert_has_not_installed_exe, cargo_home,
|
||||
};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo run` command.
|
||||
|
||||
use cargo::util::paths::dylib_path_envvar;
|
||||
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, project, Project};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo rustc` command.
|
||||
|
||||
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project};
|
||||
|
||||
const CARGO_RUSTC_ERROR: &str =
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the cache file for the rustc version info.
|
||||
|
||||
use cargo_test_support::paths::CargoPathExt;
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
use std::env;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo rustdoc` command.
|
||||
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for setting custom rustdoc flags.
|
||||
|
||||
use cargo_test_support::project;
|
||||
|
||||
#[cargo_test]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for setting custom rustc flags.
|
||||
|
||||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo search` command.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! this file tests that when the commands being run are shown
|
||||
//! This file tests that when the commands being run are shown
|
||||
//! in the output, their arguments are quoted properly
|
||||
//! so that the command can be run in a terminal
|
||||
//! so that the command can be run in a terminal.
|
||||
|
||||
use cargo_test_support::project;
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
//! Tests for building the standard library (-Zbuild-std).
|
||||
//!
|
||||
//! These tests all use a "mock" standard library so that we don't have to
|
||||
//! rebuild the real one. There is a separate integration test `build-std`
|
||||
//! which builds the real thing, but that should be avoided if possible.
|
||||
|
||||
use cargo_test_support::registry::{Dependency, Package};
|
||||
use cargo_test_support::ProjectBuilder;
|
||||
use cargo_test_support::{is_nightly, paths, project, rustc_host, Execs};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo test` command.
|
||||
|
||||
use cargo;
|
||||
use cargo_test_support::paths::CargoPathExt;
|
||||
use cargo_test_support::registry::Package;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for -Ztimings.
|
||||
|
||||
use cargo_test_support::project;
|
||||
use cargo_test_support::registry::Package;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for configuration values that point to programs.
|
||||
|
||||
use cargo_test_support::rustc_host;
|
||||
use cargo_test_support::{basic_lib_manifest, project};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo update` command.
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo vendor` command.
|
||||
|
||||
use cargo_test_support::git;
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{basic_lib_manifest, project, Project};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for the `cargo verify-project` command.
|
||||
|
||||
use cargo_test_support::{basic_bin_manifest, main_file, project};
|
||||
|
||||
fn verify_project_success_output() -> String {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for displaying the cargo version.
|
||||
|
||||
use cargo;
|
||||
use cargo_test_support::project;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for whether or not warnings are displayed for build scripts.
|
||||
|
||||
use cargo_test_support::registry::Package;
|
||||
use cargo_test_support::{project, Project};
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Tests for workspaces.
|
||||
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{Read, Write};
|
||||
|
|
Loading…
Reference in New Issue