diff --git a/crates/cargo-test-support/src/registry.rs b/crates/cargo-test-support/src/registry.rs
index cf6cff8d2c2..6d3db585a34 100644
--- a/crates/cargo-test-support/src/registry.rs
+++ b/crates/cargo-test-support/src/registry.rs
@@ -442,7 +442,7 @@ impl Package {
} else {
registry_path.join(&file)
};
- let prev = fs::read_to_string(&dst).unwrap_or(String::new());
+ let prev = fs::read_to_string(&dst).unwrap_or_default();
t!(fs::create_dir_all(dst.parent().unwrap()));
t!(fs::write(&dst, prev + &line[..] + "\n"));
diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs
index 7fc1da57a86..23ed0ca53a3 100644
--- a/src/bin/cargo/cli.rs
+++ b/src/bin/cargo/cli.rs
@@ -1,5 +1,5 @@
use cargo::core::features;
-use cargo::{self, CliResult, Config};
+use cargo::{self, drop_print, drop_println, CliResult, Config};
use clap::{AppSettings, Arg, ArgMatches};
use super::commands;
@@ -25,7 +25,8 @@ pub fn main(config: &mut Config) -> CliResult {
};
if args.value_of("unstable-features") == Some("help") {
- println!(
+ drop_println!(
+ config,
"
Available unstable (nightly-only) flags:
@@ -40,7 +41,8 @@ Available unstable (nightly-only) flags:
Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
);
if !features::nightly_features_allowed() {
- println!(
+ drop_println!(
+ config,
"\nUnstable flags are only available on the nightly channel \
of Cargo, but this is the `{}` channel.\n\
{}",
@@ -48,7 +50,8 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
features::SEE_CHANNELS
);
}
- println!(
+ drop_println!(
+ config,
"\nSee https://doc.rust-lang.org/nightly/cargo/reference/unstable.html \
for more information about these flags."
);
@@ -58,7 +61,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
let is_verbose = args.occurrences_of("verbose") > 0;
if args.is_present("version") {
let version = get_version_string(is_verbose);
- print!("{}", version);
+ drop_print!(config, "{}", version);
return Ok(());
}
@@ -69,19 +72,19 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
}
if args.is_present("list") {
- println!("Installed Commands:");
+ drop_println!(config, "Installed Commands:");
for command in list_commands(config) {
match command {
CommandInfo::BuiltIn { name, about } => {
let summary = about.unwrap_or_default();
let summary = summary.lines().next().unwrap_or(&summary); // display only the first line
- println!(" {:<20} {}", name, summary)
+ drop_println!(config, " {:<20} {}", name, summary);
}
CommandInfo::External { name, path } => {
if is_verbose {
- println!(" {:<20} {}", name, path.display())
+ drop_println!(config, " {:<20} {}", name, path.display());
} else {
- println!(" {}", name)
+ drop_println!(config, " {}", name);
}
}
}
diff --git a/src/bin/cargo/commands/locate_project.rs b/src/bin/cargo/commands/locate_project.rs
index df0c424aa4a..5897de108b3 100644
--- a/src/bin/cargo/commands/locate_project.rs
+++ b/src/bin/cargo/commands/locate_project.rs
@@ -1,6 +1,4 @@
use crate::command_prelude::*;
-
-use cargo::print_json;
use serde::Serialize;
pub fn cli() -> App {
@@ -30,6 +28,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let location = ProjectLocation { root };
- print_json(&location);
+ config.shell().print_json(&location);
Ok(())
}
diff --git a/src/bin/cargo/commands/metadata.rs b/src/bin/cargo/commands/metadata.rs
index 1130f074e8f..616df735379 100644
--- a/src/bin/cargo/commands/metadata.rs
+++ b/src/bin/cargo/commands/metadata.rs
@@ -1,7 +1,5 @@
use crate::command_prelude::*;
-
use cargo::ops::{self, OutputMetadataOptions};
-use cargo::print_json;
pub fn cli() -> App {
subcommand("metadata")
@@ -54,6 +52,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
};
let result = ops::output_metadata(&ws, &options)?;
- print_json(&result);
+ config.shell().print_json(&result);
Ok(())
}
diff --git a/src/bin/cargo/commands/pkgid.rs b/src/bin/cargo/commands/pkgid.rs
index 57be0d11877..453c95a184d 100644
--- a/src/bin/cargo/commands/pkgid.rs
+++ b/src/bin/cargo/commands/pkgid.rs
@@ -37,6 +37,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let spec = args.value_of("spec").or_else(|| args.value_of("package"));
let spec = ops::pkgid(&ws, spec)?;
- println!("{}", spec);
+ cargo::drop_println!(config, "{}", spec);
Ok(())
}
diff --git a/src/bin/cargo/commands/read_manifest.rs b/src/bin/cargo/commands/read_manifest.rs
index fe2528b18aa..96cba1e082a 100644
--- a/src/bin/cargo/commands/read_manifest.rs
+++ b/src/bin/cargo/commands/read_manifest.rs
@@ -1,7 +1,5 @@
use crate::command_prelude::*;
-use cargo::print_json;
-
pub fn cli() -> App {
subcommand("read-manifest")
.about(
@@ -17,6 +15,6 @@ Deprecated, use `cargo metadata --no-deps` instead.\
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
- print_json(&ws.current()?);
+ config.shell().print_json(&ws.current()?);
Ok(())
}
diff --git a/src/bin/cargo/commands/tree.rs b/src/bin/cargo/commands/tree.rs
index b98ee5f7aad..7eeac6cb8e7 100644
--- a/src/bin/cargo/commands/tree.rs
+++ b/src/bin/cargo/commands/tree.rs
@@ -102,7 +102,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
if args.is_present("version") {
let verbose = args.occurrences_of("verbose") > 0;
let version = cli::get_version_string(verbose);
- print!("{}", version);
+ cargo::drop_print!(config, "{}", version);
return Ok(());
}
let prefix = if args.is_present("no-indent") {
@@ -206,7 +206,7 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult App {
subcommand("verify-project")
.about("Check correctness of crate manifest")
@@ -13,19 +11,15 @@ pub fn cli() -> App {
}
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
- fn fail(reason: &str, value: &str) -> ! {
+ if let Err(e) = args.workspace(config) {
let mut h = HashMap::new();
- h.insert(reason.to_string(), value.to_string());
- print_json(&h);
+ h.insert("invalid".to_string(), e.to_string());
+ config.shell().print_json(&h);
process::exit(1)
}
- if let Err(e) = args.workspace(config) {
- fail("invalid", &e.to_string())
- }
-
let mut h = HashMap::new();
h.insert("success".to_string(), "true".to_string());
- print_json(&h);
+ config.shell().print_json(&h);
Ok(())
}
diff --git a/src/bin/cargo/commands/version.rs b/src/bin/cargo/commands/version.rs
index 81c6838e7ab..73172826150 100644
--- a/src/bin/cargo/commands/version.rs
+++ b/src/bin/cargo/commands/version.rs
@@ -1,6 +1,5 @@
-use crate::command_prelude::*;
-
use crate::cli;
+use crate::command_prelude::*;
pub fn cli() -> App {
subcommand("version")
@@ -8,9 +7,9 @@ pub fn cli() -> App {
.arg(opt("quiet", "No output printed to stdout").short("q"))
}
-pub fn exec(_config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
+pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let verbose = args.occurrences_of("verbose") > 0;
let version = cli::get_version_string(verbose);
- print!("{}", version);
+ cargo::drop_print!(config, "{}", version);
Ok(())
}
diff --git a/src/cargo/core/compiler/build_context/mod.rs b/src/cargo/core/compiler/build_context/mod.rs
index 8dac81cffd2..ac7d6eca295 100644
--- a/src/cargo/core/compiler/build_context/mod.rs
+++ b/src/cargo/core/compiler/build_context/mod.rs
@@ -10,7 +10,7 @@ use std::collections::HashMap;
use std::path::PathBuf;
mod target_info;
-pub use self::target_info::{FileFlavor, RustcTargetData, TargetInfo};
+pub use self::target_info::{FileFlavor, FileType, RustcTargetData, TargetInfo};
/// The build context, containing all information about a build task.
///
diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs
index 28d9589e1ef..ab3dc1c26a9 100644
--- a/src/cargo/core/compiler/build_context/target_info.rs
+++ b/src/cargo/core/compiler/build_context/target_info.rs
@@ -1,5 +1,5 @@
-use crate::core::compiler::{BuildOutput, CompileKind, CompileTarget};
-use crate::core::{Dependency, TargetKind, Workspace};
+use crate::core::compiler::{BuildOutput, CompileKind, CompileMode, CompileTarget, CrateType};
+use crate::core::{Dependency, Target, TargetKind, Workspace};
use crate::util::config::{Config, StringList, TargetConfig};
use crate::util::{CargoResult, CargoResultExt, ProcessBuilder, Rustc};
use cargo_platform::{Cfg, CfgExpr};
@@ -25,7 +25,7 @@ pub struct TargetInfo {
/// `Some((prefix, suffix))`, for example `libcargo.so` would be
/// `Some(("lib", ".so")). The value is `None` if the crate type is not
/// supported.
- crate_types: RefCell>>,
+ crate_types: RefCell>>,
/// `cfg` information extracted from `rustc --print=cfg`.
cfg: Vec,
/// Path to the sysroot.
@@ -40,8 +40,8 @@ pub struct TargetInfo {
pub rustflags: Vec,
/// Extra flags to pass to `rustdoc`, see `env_args`.
pub rustdocflags: Vec,
- /// Remove this when it hits stable (1.44)
- pub supports_bitcode_in_rlib: Option,
+ /// Remove this when it hits stable (1.45)
+ pub supports_embed_bitcode: Option,
}
/// Kind of each file generated by a Unit, part of `FileType`.
@@ -49,41 +49,73 @@ pub struct TargetInfo {
pub enum FileFlavor {
/// Not a special file type.
Normal,
- /// Like `Normal`, but not directly executable
+ /// Like `Normal`, but not directly executable.
+ /// For example, a `.wasm` file paired with the "normal" `.js` file.
Auxiliary,
/// Something you can link against (e.g., a library).
- Linkable { rmeta: bool },
+ Linkable,
+ /// An `.rmeta` Rust metadata file.
+ Rmeta,
/// Piece of external debug information (e.g., `.dSYM`/`.pdb` file).
DebugInfo,
}
/// Type of each file generated by a Unit.
+#[derive(Debug)]
pub struct FileType {
/// The kind of file.
pub flavor: FileFlavor,
+ /// The crate-type that generates this file.
+ ///
+ /// `None` for things that aren't associated with a specific crate type,
+ /// for example `rmeta` files.
+ pub crate_type: Option,
/// The suffix for the file (for example, `.rlib`).
/// This is an empty string for executables on Unix-like platforms.
suffix: String,
/// The prefix for the file (for example, `lib`).
/// This is an empty string for things like executables.
prefix: String,
- /// Flag to convert hyphen to underscore.
- ///
- /// wasm bin targets will generate two files in deps such as
- /// "web-stuff.js" and "web_stuff.wasm". Note the different usages of "-"
- /// and "_". This flag indicates that the stem "web-stuff" should be
- /// converted to "web_stuff".
+ /// Flag to convert hyphen to underscore when uplifting.
should_replace_hyphens: bool,
}
impl FileType {
- pub fn filename(&self, stem: &str) -> String {
- let stem = if self.should_replace_hyphens {
- stem.replace("-", "_")
+ /// The filename for this FileType crated by rustc.
+ pub fn output_filename(&self, target: &Target, metadata: Option<&str>) -> String {
+ match metadata {
+ Some(metadata) => format!(
+ "{}{}-{}{}",
+ self.prefix,
+ target.crate_name(),
+ metadata,
+ self.suffix
+ ),
+ None => format!("{}{}{}", self.prefix, target.crate_name(), self.suffix),
+ }
+ }
+
+ /// The filename for this FileType that Cargo should use when "uplifting"
+ /// it to the destination directory.
+ pub fn uplift_filename(&self, target: &Target) -> String {
+ let name = if self.should_replace_hyphens {
+ target.crate_name()
} else {
- stem.to_string()
+ target.name().to_string()
};
- format!("{}{}{}", self.prefix, stem, self.suffix)
+ format!("{}{}{}", self.prefix, name, self.suffix)
+ }
+
+ /// Creates a new instance representing a `.rmeta` file.
+ pub fn new_rmeta() -> FileType {
+ // Note that even binaries use the `lib` prefix.
+ FileType {
+ flavor: FileFlavor::Rmeta,
+ crate_type: None,
+ suffix: ".rmeta".to_string(),
+ prefix: "lib".to_string(),
+ should_replace_hyphens: true,
+ }
}
}
@@ -111,10 +143,10 @@ impl TargetInfo {
.args(&rustflags)
.env_remove("RUSTC_LOG");
- let mut bitcode_in_rlib_test = process.clone();
- bitcode_in_rlib_test.arg("-Cbitcode-in-rlib");
- let supports_bitcode_in_rlib = match kind {
- CompileKind::Host => Some(rustc.cached_output(&bitcode_in_rlib_test).is_ok()),
+ let mut embed_bitcode_test = process.clone();
+ embed_bitcode_test.arg("-Cembed-bitcode");
+ let supports_embed_bitcode = match kind {
+ CompileKind::Host => Some(rustc.cached_output(&embed_bitcode_test).is_ok()),
_ => None,
};
@@ -123,10 +155,16 @@ impl TargetInfo {
}
let crate_type_process = process.clone();
- const KNOWN_CRATE_TYPES: &[&str] =
- &["bin", "rlib", "dylib", "cdylib", "staticlib", "proc-macro"];
+ const KNOWN_CRATE_TYPES: &[CrateType] = &[
+ CrateType::Bin,
+ CrateType::Rlib,
+ CrateType::Dylib,
+ CrateType::Cdylib,
+ CrateType::Staticlib,
+ CrateType::ProcMacro,
+ ];
for crate_type in KNOWN_CRATE_TYPES.iter() {
- process.arg("--crate-type").arg(crate_type);
+ process.arg("--crate-type").arg(crate_type.as_str());
}
process.arg("--print=sysroot");
@@ -140,7 +178,7 @@ impl TargetInfo {
let mut map = HashMap::new();
for crate_type in KNOWN_CRATE_TYPES {
let out = parse_crate_type(crate_type, &process, &output, &error, &mut lines)?;
- map.insert(crate_type.to_string(), out);
+ map.insert(crate_type.clone(), out);
}
let line = match lines.next() {
@@ -202,7 +240,7 @@ impl TargetInfo {
"RUSTDOCFLAGS",
)?,
cfg,
- supports_bitcode_in_rlib,
+ supports_embed_bitcode,
})
}
@@ -226,15 +264,20 @@ impl TargetInfo {
/// Returns the list of file types generated by the given crate type.
///
/// Returns `None` if the target does not support the given crate type.
- pub fn file_types(
+ fn file_types(
&self,
- crate_type: &str,
+ crate_type: &CrateType,
flavor: FileFlavor,
- kind: &TargetKind,
target_triple: &str,
) -> CargoResult
+
+
+
+
Note: The
+#[bench] attribute
+is currently unstable and only available on the
+nightly channel.
+There are some packages available on
+crates.io that may help with
+running benchmarks on the stable channel, such as
+Criterion.
+
+
+
diff --git a/src/etc/man/cargo-bench.1 b/src/etc/man/cargo-bench.1
index 708d2066a8b..442f164d893 100644
--- a/src/etc/man/cargo-bench.1
+++ b/src/etc/man/cargo-bench.1
@@ -2,12 +2,12 @@
.\" Title: cargo-bench
.\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.10
-.\" Date: 2020-02-06
+.\" Date: 2020-05-08
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "CARGO\-BENCH" "1" "2020-02-06" "\ \&" "\ \&"
+.TH "CARGO\-BENCH" "1" "2020-05-08" "\ \&" "\ \&"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
@@ -59,6 +59,22 @@ the test harness to tell it to run only benchmarks.
The libtest harness may be disabled by setting \fBharness = false\fP in the target
manifest settings, in which case your code will need to provide its own \fBmain\fP
function to handle running benchmarks.
+.RS 3
+.ll -.6i
+.sp
+\fBNote\fP: The
+\c
+.URL "https://doc.rust\-lang.org/nightly/unstable\-book/library\-features/test.html" "\fB#[bench]\fP attribute"
+is currently unstable and only available on the
+.URL "https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html" "nightly channel" "."
+There are some packages available on
+.URL "https://crates.io/keywords/benchmark" "crates.io" " "
+that may help with
+running benchmarks on the stable channel, such as
+.URL "https://crates.io/crates/criterion" "Criterion" "."
+.br
+.RE
+.ll
.SH "OPTIONS"
.SS "Benchmark Options"
.sp
diff --git a/tests/internal.rs b/tests/internal.rs
new file mode 100644
index 00000000000..2631d787381
--- /dev/null
+++ b/tests/internal.rs
@@ -0,0 +1,93 @@
+//! Tests for internal code checks.
+use std::fs;
+
+#[test]
+fn check_forbidden_code() {
+ // Do not use certain macros, functions, etc.
+ if !cargo::util::is_ci() {
+ // Only check these on CI, otherwise it could be annoying.
+ return;
+ }
+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
+ for entry in walkdir::WalkDir::new(path)
+ .into_iter()
+ .filter_map(|e| e.ok())
+ {
+ let path = entry.path();
+ if !entry
+ .file_name()
+ .to_str()
+ .map(|s| s.ends_with(".rs"))
+ .unwrap_or(false)
+ {
+ continue;
+ }
+ let c = fs::read_to_string(path).unwrap();
+ for (line_index, line) in c.lines().enumerate() {
+ if line_has_print(line) {
+ if entry.file_name().to_str().unwrap() == "cargo_new.rs" && line.contains("Hello") {
+ // An exception.
+ continue;
+ }
+ panic!(
+ "found print macro in {}:{}\n\n{}\n\n\
+ print! macros should not be used in Cargo because they can panic.\n\
+ Use one of the drop_print macros instead.\n\
+ ",
+ path.display(),
+ line_index,
+ line
+ );
+ }
+ if line_has_macro(line, "dbg") {
+ panic!(
+ "found dbg! macro in {}:{}\n\n{}\n\n\
+ dbg! should not be used outside of debugging.",
+ path.display(),
+ line_index,
+ line
+ );
+ }
+ }
+ }
+}
+
+fn line_has_print(line: &str) -> bool {
+ line_has_macro(line, "print")
+ || line_has_macro(line, "eprint")
+ || line_has_macro(line, "println")
+ || line_has_macro(line, "eprintln")
+}
+
+#[test]
+fn line_has_print_works() {
+ assert!(line_has_print("print!"));
+ assert!(line_has_print("println!"));
+ assert!(line_has_print("eprint!"));
+ assert!(line_has_print("eprintln!"));
+ assert!(line_has_print("(print!(\"hi!\"))"));
+ assert!(!line_has_print("print"));
+ assert!(!line_has_print("i like to print things"));
+ assert!(!line_has_print("drop_print!"));
+ assert!(!line_has_print("drop_println!"));
+ assert!(!line_has_print("drop_eprint!"));
+ assert!(!line_has_print("drop_eprintln!"));
+}
+
+fn line_has_macro(line: &str, mac: &str) -> bool {
+ for (i, _) in line.match_indices(mac) {
+ if line.get(i + mac.len()..i + mac.len() + 1) != Some("!") {
+ continue;
+ }
+ if i == 0 {
+ return true;
+ }
+ // Check for identifier boundary start.
+ let prev1 = line.get(i - 1..i).unwrap().chars().next().unwrap();
+ if prev1.is_alphanumeric() || prev1 == '_' {
+ continue;
+ }
+ return true;
+ }
+ false
+}
diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs
index 225d5c9625e..b4d7de19aa8 100644
--- a/tests/testsuite/bench.rs
+++ b/tests/testsuite/bench.rs
@@ -1614,7 +1614,7 @@ fn json_artifact_includes_executable_for_benchmark() {
{
"executable": "[..]/foo/target/release/deps/benchmark-[..][EXE]",
"features": [],
- "filenames": [ "[..]/foo/target/release/deps/benchmark-[..][EXE]" ],
+ "filenames": "{...}",
"fresh": false,
"package_id": "foo 0.0.1 ([..])",
"profile": "{...}",
diff --git a/tests/testsuite/build_plan.rs b/tests/testsuite/build_plan.rs
index 092ff90e637..a6e8eaac8dd 100644
--- a/tests/testsuite/build_plan.rs
+++ b/tests/testsuite/build_plan.rs
@@ -154,9 +154,7 @@ fn cargo_build_plan_build_script() {
"env": "{...}",
"kind": null,
"links": "{...}",
- "outputs": [
- "[..]/foo/target/debug/build/[..]/build_script_build-[..]"
- ],
+ "outputs": "{...}",
"package_name": "foo",
"package_version": "0.5.0",
"program": "rustc",
diff --git a/tests/testsuite/cache_messages.rs b/tests/testsuite/cache_messages.rs
index 0503306b943..1df15b22764 100644
--- a/tests/testsuite/cache_messages.rs
+++ b/tests/testsuite/cache_messages.rs
@@ -194,7 +194,7 @@ fn clears_cache_after_fix() {
// Fill the cache.
p.cargo("check").with_stderr_contains("[..]asdf[..]").run();
let cpath = p
- .glob("target/debug/.fingerprint/foo-*/output")
+ .glob("target/debug/.fingerprint/foo-*/output-*")
.next()
.unwrap()
.unwrap();
@@ -215,7 +215,10 @@ fn clears_cache_after_fix() {
",
)
.run();
- assert_eq!(p.glob("target/debug/.fingerprint/foo-*/output").count(), 0);
+ assert_eq!(
+ p.glob("target/debug/.fingerprint/foo-*/output-*").count(),
+ 0
+ );
// And again, check the cache is correct.
p.cargo("check")
@@ -253,7 +256,10 @@ fn rustdoc() {
let rustdoc_stderr = as_str(&rustdoc_output.stderr);
assert!(rustdoc_stderr.contains("private"));
assert!(rustdoc_stderr.contains("\x1b["));
- assert_eq!(p.glob("target/debug/.fingerprint/foo-*/output").count(), 1);
+ assert_eq!(
+ p.glob("target/debug/.fingerprint/foo-*/output-*").count(),
+ 1
+ );
// Check the cached output.
let rustdoc_output = p
@@ -331,14 +337,23 @@ fn doesnt_create_extra_files() {
p.cargo("build").run();
- assert_eq!(p.glob("target/debug/.fingerprint/foo-*/output").count(), 0);
- assert_eq!(p.glob("target/debug/.fingerprint/dep-*/output").count(), 0);
+ assert_eq!(
+ p.glob("target/debug/.fingerprint/foo-*/output-*").count(),
+ 0
+ );
+ assert_eq!(
+ p.glob("target/debug/.fingerprint/dep-*/output-*").count(),
+ 0
+ );
if is_coarse_mtime() {
sleep_ms(1000);
}
p.change_file("src/lib.rs", "fn unused() {}");
p.cargo("build").run();
- assert_eq!(p.glob("target/debug/.fingerprint/foo-*/output").count(), 1);
+ assert_eq!(
+ p.glob("target/debug/.fingerprint/foo-*/output-*").count(),
+ 1
+ );
}
#[cargo_test]
@@ -491,3 +506,23 @@ fn rustc_workspace_wrapper() {
.with_stdout_does_not_contain("WRAPPER CALLED: rustc --crate-name foo src/lib.rs [..]")
.run();
}
+
+#[cargo_test]
+fn wacky_hashless_fingerprint() {
+ // On Windows, executables don't have hashes. This checks for a bad
+ // assumption that caused bad caching.
+ let p = project()
+ .file("src/bin/a.rs", "fn main() { let unused = 1; }")
+ .file("src/bin/b.rs", "fn main() {}")
+ .build();
+ p.cargo("build --bin b")
+ .with_stderr_does_not_contain("[..]unused[..]")
+ .run();
+ p.cargo("build --bin a")
+ .with_stderr_contains("[..]unused[..]")
+ .run();
+ // This should not pick up the cache from `a`.
+ p.cargo("build --bin b")
+ .with_stderr_does_not_contain("[..]unused[..]")
+ .run();
+}
diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs
index 80cff54754f..fa4e05a74d2 100644
--- a/tests/testsuite/cargo_command.rs
+++ b/tests/testsuite/cargo_command.rs
@@ -2,7 +2,9 @@
use std::env;
use std::fs::{self, File};
+use std::io::Read;
use std::path::{Path, PathBuf};
+use std::process::Stdio;
use std::str;
use cargo_test_support::cargo_process;
@@ -371,3 +373,24 @@ fn z_flags_help() {
.with_stdout_contains(" -Z unstable-options -- Allow the usage of unstable options")
.run();
}
+
+#[cargo_test]
+fn closed_output_ok() {
+ // Checks that closed output doesn't cause an error.
+ let mut p = cargo_process("--list").build_command();
+ p.stdout(Stdio::piped()).stderr(Stdio::piped());
+ let mut child = p.spawn().unwrap();
+ // Close stdout
+ drop(child.stdout.take());
+ // Read stderr
+ let mut s = String::new();
+ child
+ .stderr
+ .as_mut()
+ .unwrap()
+ .read_to_string(&mut s)
+ .unwrap();
+ let status = child.wait().unwrap();
+ assert!(status.success());
+ assert!(s.is_empty(), s);
+}
diff --git a/tests/testsuite/clean.rs b/tests/testsuite/clean.rs
index 32f3b29b539..673dc4969a1 100644
--- a/tests/testsuite/clean.rs
+++ b/tests/testsuite/clean.rs
@@ -1,9 +1,10 @@
//! Tests for the `cargo clean` command.
-use std::env;
-
+use cargo_test_support::paths::CargoPathExt;
use cargo_test_support::registry::Package;
-use cargo_test_support::{basic_bin_manifest, basic_manifest, git, main_file, project};
+use cargo_test_support::{basic_bin_manifest, basic_manifest, git, main_file, project, rustc_host};
+use std::env;
+use std::path::Path;
#[cargo_test]
fn cargo_clean_simple() {
@@ -291,6 +292,7 @@ fn clean_verbose() {
[REMOVING] [..]
[REMOVING] [..]
[REMOVING] [..]
+[REMOVING] [..]
",
)
.run();
@@ -319,3 +321,163 @@ fn clean_remove_rlib_rmeta() {
assert!(!p.target_debug_dir().join("libfoo.rlib").exists());
assert!(!rmeta.exists());
}
+
+#[cargo_test]
+fn package_cleans_all_the_things() {
+ // -p cleans everything
+ // Use dashes everywhere to make sure dash/underscore stuff is handled.
+ for crate_type in &["rlib", "dylib", "cdylib", "staticlib", "proc-macro"] {
+ // Try each crate type individually since the behavior changes when
+ // they are combined.
+ let p = project()
+ .file(
+ "Cargo.toml",
+ &format!(
+ r#"
+ [package]
+ name = "foo-bar"
+ version = "0.1.0"
+
+ [lib]
+ crate-type = ["{}"]
+ "#,
+ crate_type
+ ),
+ )
+ .file("src/lib.rs", "")
+ .build();
+ p.cargo("build").run();
+ p.cargo("clean -p foo-bar").run();
+ assert_all_clean(&p.build_dir());
+ }
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo-bar"
+ version = "0.1.0"
+ edition = "2018"
+
+ [lib]
+ crate-type = ["rlib", "dylib", "staticlib"]
+
+ [[example]]
+ name = "foo-ex-rlib"
+ crate-type = ["rlib"]
+ test = true
+
+ [[example]]
+ name = "foo-ex-cdylib"
+ crate-type = ["cdylib"]
+ test = true
+
+ [[example]]
+ name = "foo-ex-bin"
+ test = true
+ "#,
+ )
+ .file("src/lib.rs", "")
+ .file("src/main.rs", "fn main() {}")
+ .file("src/bin/other-main.rs", "fn main() {}")
+ .file("examples/foo-ex-rlib.rs", "")
+ .file("examples/foo-ex-cdylib.rs", "")
+ .file("examples/foo-ex-bin.rs", "fn main() {}")
+ .file("tests/foo-test.rs", "")
+ .file("benches/foo-bench.rs", "")
+ .file("build.rs", "fn main() {}")
+ .build();
+
+ p.cargo("build --all-targets")
+ .env("CARGO_INCREMENTAL", "1")
+ .run();
+ p.cargo("test --all-targets")
+ .env("CARGO_INCREMENTAL", "1")
+ .run();
+ p.cargo("check --all-targets")
+ .env("CARGO_INCREMENTAL", "1")
+ .run();
+ p.cargo("clean -p foo-bar").run();
+ assert_all_clean(&p.build_dir());
+
+ // Try some targets.
+ p.cargo("build --all-targets --target")
+ .arg(rustc_host())
+ .run();
+ p.cargo("clean -p foo-bar --target").arg(rustc_host()).run();
+ assert_all_clean(&p.build_dir());
+}
+
+// Ensures that all files for the package have been deleted.
+fn assert_all_clean(build_dir: &Path) {
+ let walker = walkdir::WalkDir::new(build_dir).into_iter();
+ for entry in walker.filter_entry(|e| {
+ let path = e.path();
+ // This is a known limitation, clean can't differentiate between
+ // the different build scripts from different packages.
+ !(path
+ .file_name()
+ .unwrap()
+ .to_str()
+ .unwrap()
+ .starts_with("build_script_build")
+ && path
+ .parent()
+ .unwrap()
+ .file_name()
+ .unwrap()
+ .to_str()
+ .unwrap()
+ == "incremental")
+ }) {
+ let entry = entry.unwrap();
+ let path = entry.path();
+ if let ".rustc_info.json" | ".cargo-lock" = path.file_name().unwrap().to_str().unwrap() {
+ continue;
+ }
+ if path.is_symlink() || path.is_file() {
+ panic!("{:?} was not cleaned", path);
+ }
+ }
+}
+
+#[cargo_test]
+fn clean_spec_multiple() {
+ // clean -p foo where foo matches multiple versions
+ Package::new("bar", "1.0.0").publish();
+ Package::new("bar", "2.0.0").publish();
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+
+ [dependencies]
+ bar1 = {version="1.0", package="bar"}
+ bar2 = {version="2.0", package="bar"}
+ "#,
+ )
+ .file("src/lib.rs", "")
+ .build();
+
+ p.cargo("build").run();
+ p.cargo("clean -p bar:1.0.0")
+ .with_stderr(
+ "warning: version qualifier in `-p bar:1.0.0` is ignored, \
+ cleaning all versions of `bar` found",
+ )
+ .run();
+ let mut walker = walkdir::WalkDir::new(p.build_dir())
+ .into_iter()
+ .filter_map(|e| e.ok())
+ .filter(|e| {
+ let n = e.file_name().to_str().unwrap();
+ n.starts_with("bar") || n.starts_with("libbar")
+ });
+ if let Some(e) = walker.next() {
+ panic!("{:?} was not cleaned", e.path());
+ }
+}
diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs
index 46dbca69d50..4cbea32f54a 100644
--- a/tests/testsuite/config.rs
+++ b/tests/testsuite/config.rs
@@ -574,7 +574,7 @@ opt-level = 'foo'
error in [..]/.cargo/config: could not load config key `profile.dev.opt-level`
Caused by:
- must be an integer, `z`, or `s`, but found: foo",
+ must be an integer, `z`, or `s`, but found the string: \"foo\"",
);
let config = ConfigBuilder::new()
@@ -587,7 +587,7 @@ Caused by:
error in environment variable `CARGO_PROFILE_DEV_OPT_LEVEL`: could not load config key `profile.dev.opt-level`
Caused by:
- must be an integer, `z`, or `s`, but found: asdf",
+ must be an integer, `z`, or `s`, but found the string: \"asdf\"",
);
}
diff --git a/tests/testsuite/dep_info.rs b/tests/testsuite/dep_info.rs
index 886ef862cc4..4223fb31198 100644
--- a/tests/testsuite/dep_info.rs
+++ b/tests/testsuite/dep_info.rs
@@ -272,13 +272,13 @@ fn relative_depinfo_paths_ws() {
assert_deps_contains(
&p,
- "target/debug/.fingerprint/pm-*/dep-lib-pm-*",
+ "target/debug/.fingerprint/pm-*/dep-lib-pm",
&[(1, "src/lib.rs"), (2, "debug/deps/libpmdep-*.rlib")],
);
assert_deps_contains(
&p,
- &format!("target/{}/debug/.fingerprint/foo-*/dep-bin-foo*", host),
+ &format!("target/{}/debug/.fingerprint/foo-*/dep-bin-foo", host),
&[
(1, "src/main.rs"),
(
@@ -296,7 +296,7 @@ fn relative_depinfo_paths_ws() {
assert_deps_contains(
&p,
- "target/debug/.fingerprint/foo-*/dep-build-script-build_script_build-*",
+ "target/debug/.fingerprint/foo-*/dep-build-script-build-script-build",
&[(1, "build.rs"), (2, "debug/deps/libbdep-*.rlib")],
);
@@ -400,13 +400,13 @@ fn relative_depinfo_paths_no_ws() {
assert_deps_contains(
&p,
- "target/debug/.fingerprint/pm-*/dep-lib-pm-*",
+ "target/debug/.fingerprint/pm-*/dep-lib-pm",
&[(1, "src/lib.rs"), (2, "debug/deps/libpmdep-*.rlib")],
);
assert_deps_contains(
&p,
- "target/debug/.fingerprint/foo-*/dep-bin-foo*",
+ "target/debug/.fingerprint/foo-*/dep-bin-foo",
&[
(1, "src/main.rs"),
(
@@ -424,7 +424,7 @@ fn relative_depinfo_paths_no_ws() {
assert_deps_contains(
&p,
- "target/debug/.fingerprint/foo-*/dep-build-script-build_script_build-*",
+ "target/debug/.fingerprint/foo-*/dep-build-script-build-script-build",
&[(1, "build.rs"), (2, "debug/deps/libbdep-*.rlib")],
);
@@ -461,7 +461,7 @@ fn reg_dep_source_not_tracked() {
assert_deps(
&p,
- "target/debug/.fingerprint/regdep-*/dep-lib-regdep-*",
+ "target/debug/.fingerprint/regdep-*/dep-lib-regdep",
|info_path, entries| {
for (kind, path) in entries {
if *kind == 1 {
@@ -513,7 +513,7 @@ fn canonical_path() {
assert_deps_contains(
&p,
- "target/debug/.fingerprint/foo-*/dep-lib-foo-*",
+ "target/debug/.fingerprint/foo-*/dep-lib-foo",
&[(1, "src/lib.rs"), (2, "debug/deps/libregdep-*.rmeta")],
);
}
diff --git a/tests/testsuite/git_auth.rs b/tests/testsuite/git_auth.rs
index 258014cf653..8fa920d0f6a 100644
--- a/tests/testsuite/git_auth.rs
+++ b/tests/testsuite/git_auth.rs
@@ -265,3 +265,62 @@ Caused by:
.run();
t.join().ok().unwrap();
}
+
+#[cargo_test]
+fn net_err_suggests_fetch_with_cli() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+
+ [dependencies]
+ foo = { git = "ssh://needs-proxy.invalid/git" }
+ "#,
+ )
+ .file("src/lib.rs", "")
+ .build();
+
+ p.cargo("build -v")
+ .with_status(101)
+ .with_stderr(
+ "\
+[UPDATING] git repository `ssh://needs-proxy.invalid/git`
+warning: spurious network error[..]
+warning: spurious network error[..]
+[ERROR] failed to get `foo` as a dependency of package `foo v0.0.0 [..]`
+
+Caused by:
+ failed to load source for dependency `foo`
+
+Caused by:
+ Unable to update ssh://needs-proxy.invalid/git
+
+Caused by:
+ failed to clone into: [..]
+ If your environment requires git authentication or proxying, try enabling `git-fetch-with-cli`
+ https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
+
+Caused by:
+ failed to resolve address for needs-proxy.invalid[..]
+",
+ )
+ .run();
+
+ p.change_file(
+ ".cargo/config",
+ "
+ [net]
+ git-fetch-with-cli = true
+ ",
+ );
+
+ p.cargo("build -v")
+ .with_status(101)
+ .with_stderr_contains("[..]Unable to update[..]")
+ .with_stderr_does_not_contain("[..]try enabling `git-fetch-with-cli`[..]")
+ .run();
+}
diff --git a/tests/testsuite/lto.rs b/tests/testsuite/lto.rs
index 4d77b2186e2..f5e2fb5bd68 100644
--- a/tests/testsuite/lto.rs
+++ b/tests/testsuite/lto.rs
@@ -3,6 +3,10 @@ use cargo_test_support::registry::Package;
#[cargo_test]
fn with_deps() {
+ if !cargo_test_support::is_nightly() {
+ return;
+ }
+
Package::new("bar", "0.0.1").publish();
let p = project()
@@ -22,5 +26,313 @@ fn with_deps() {
)
.file("src/main.rs", "extern crate bar; fn main() {}")
.build();
+ p.cargo("build -v --release")
+ .with_stderr_contains("[..]`rustc[..]--crate-name bar[..]-Clinker-plugin-lto[..]`")
+ .with_stderr_contains("[..]`rustc[..]--crate-name test[..]-C lto[..]`")
+ .run();
+}
+
+#[cargo_test]
+fn shared_deps() {
+ if !cargo_test_support::is_nightly() {
+ return;
+ }
+
+ Package::new("bar", "0.0.1").publish();
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "test"
+ version = "0.0.0"
+
+ [dependencies]
+ bar = "*"
+
+ [build-dependencies]
+ bar = "*"
+
+ [profile.release]
+ lto = true
+ "#,
+ )
+ .file("build.rs", "extern crate bar; fn main() {}")
+ .file("src/main.rs", "extern crate bar; fn main() {}")
+ .build();
+ p.cargo("build -v --release")
+ .with_stderr_contains("[..]`rustc[..]--crate-name test[..]-C lto[..]`")
+ .run();
+}
+
+#[cargo_test]
+fn build_dep_not_ltod() {
+ if !cargo_test_support::is_nightly() {
+ return;
+ }
+
+ Package::new("bar", "0.0.1").publish();
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "test"
+ version = "0.0.0"
+
+ [build-dependencies]
+ bar = "*"
+
+ [profile.release]
+ lto = true
+ "#,
+ )
+ .file("build.rs", "extern crate bar; fn main() {}")
+ .file("src/main.rs", "fn main() {}")
+ .build();
+ p.cargo("build -v --release")
+ .with_stderr_contains("[..]`rustc[..]--crate-name bar[..]-Cembed-bitcode=no[..]`")
+ .with_stderr_contains("[..]`rustc[..]--crate-name test[..]-C lto[..]`")
+ .run();
+}
+
+#[cargo_test]
+fn complicated() {
+ if !cargo_test_support::is_nightly() {
+ return;
+ }
+
+ Package::new("dep-shared", "0.0.1")
+ .file("src/lib.rs", "pub fn foo() {}")
+ .publish();
+ Package::new("dep-normal2", "0.0.1")
+ .file("src/lib.rs", "pub fn foo() {}")
+ .publish();
+ Package::new("dep-normal", "0.0.1")
+ .dep("dep-shared", "*")
+ .dep("dep-normal2", "*")
+ .file(
+ "src/lib.rs",
+ "
+ pub fn foo() {
+ dep_shared::foo();
+ dep_normal2::foo();
+ }
+ ",
+ )
+ .publish();
+ Package::new("dep-build2", "0.0.1")
+ .file("src/lib.rs", "pub fn foo() {}")
+ .publish();
+ Package::new("dep-build", "0.0.1")
+ .dep("dep-shared", "*")
+ .dep("dep-build2", "*")
+ .file(
+ "src/lib.rs",
+ "
+ pub fn foo() {
+ dep_shared::foo();
+ dep_build2::foo();
+ }
+ ",
+ )
+ .publish();
+ Package::new("dep-proc-macro2", "0.0.1")
+ .file("src/lib.rs", "pub fn foo() {}")
+ .publish();
+ Package::new("dep-proc-macro", "0.0.1")
+ .proc_macro(true)
+ .dep("dep-shared", "*")
+ .dep("dep-proc-macro2", "*")
+ .file(
+ "src/lib.rs",
+ "
+ extern crate proc_macro;
+ use proc_macro::TokenStream;
+
+ #[proc_macro_attribute]
+ pub fn foo(_: TokenStream, a: TokenStream) -> TokenStream {
+ dep_shared::foo();
+ dep_proc_macro2::foo();
+ a
+ }
+ ",
+ )
+ .publish();
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "test"
+ version = "0.0.0"
+
+ [lib]
+ crate-type = ['cdylib', 'staticlib']
+
+ [dependencies]
+ dep-normal = "*"
+ dep-proc-macro = "*"
+
+ [build-dependencies]
+ dep-build = "*"
+
+ [profile.release]
+ lto = true
+ "#,
+ )
+ .file("build.rs", "fn main() { dep_build::foo() }")
+ .file(
+ "src/main.rs",
+ "#[dep_proc_macro::foo] fn main() { dep_normal::foo() }",
+ )
+ .file(
+ "src/lib.rs",
+ "#[dep_proc_macro::foo] pub fn foo() { dep_normal::foo() }",
+ )
+ .build();
+ p.cargo("build -v --release")
+ // normal deps and their transitive dependencies do not need object
+ // code, so they should have linker-plugin-lto specified
+ .with_stderr_contains("[..]`rustc[..]--crate-name dep_normal2 [..]-Clinker-plugin-lto[..]`")
+ .with_stderr_contains("[..]`rustc[..]--crate-name dep_normal [..]-Clinker-plugin-lto[..]`")
+ // build dependencies and their transitive deps don't need any bitcode,
+ // so embedding should be turned off
+ .with_stderr_contains("[..]`rustc[..]--crate-name dep_build2 [..]-Cembed-bitcode=no[..]`")
+ .with_stderr_contains("[..]`rustc[..]--crate-name dep_build [..]-Cembed-bitcode=no[..]`")
+ .with_stderr_contains(
+ "[..]`rustc[..]--crate-name build_script_build [..]-Cembed-bitcode=no[..]`",
+ )
+ // proc macro deps are the same as build deps here
+ .with_stderr_contains(
+ "[..]`rustc[..]--crate-name dep_proc_macro2 [..]-Cembed-bitcode=no[..]`",
+ )
+ .with_stderr_contains(
+ "[..]`rustc[..]--crate-name dep_proc_macro [..]-Cembed-bitcode=no[..]`",
+ )
+ .with_stderr_contains("[..]`rustc[..]--crate-name test [..]--crate-type bin[..]-C lto[..]`")
+ .with_stderr_contains(
+ "[..]`rustc[..]--crate-name test [..]--crate-type cdylib[..]-C lto[..]`",
+ )
+ .with_stderr_contains("[..]`rustc[..]--crate-name dep_shared [..]`")
+ .with_stderr_does_not_contain("[..]--crate-name dep_shared[..]-C lto[..]")
+ .with_stderr_does_not_contain("[..]--crate-name dep_shared[..]-Clinker-plugin-lto[..]")
+ .with_stderr_does_not_contain("[..]--crate-name dep_shared[..]-Cembed-bitcode[..]")
+ .run();
+}
+
+#[cargo_test]
+fn off_in_manifest_works() {
+ if !cargo_test_support::is_nightly() {
+ return;
+ }
+
+ Package::new("bar", "0.0.1")
+ .file("src/lib.rs", "pub fn foo() {}")
+ .publish();
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "test"
+ version = "0.0.0"
+
+ [dependencies]
+ bar = "*"
+
+ [profile.release]
+ lto = "off"
+ "#,
+ )
+ .file("src/main.rs", "fn main() { bar::foo() }")
+ .build();
p.cargo("build -v --release").run();
}
+
+#[cargo_test]
+fn between_builds() {
+ if !cargo_test_support::is_nightly() {
+ return;
+ }
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "test"
+ version = "0.0.0"
+
+ [profile.release]
+ lto = true
+ "#,
+ )
+ .file("src/lib.rs", "pub fn foo() {}")
+ .file("src/main.rs", "fn main() { test::foo() }")
+ .build();
+ p.cargo("build -v --release --lib").run();
+ p.cargo("build -v --release").run();
+}
+
+#[cargo_test]
+fn test_all() {
+ if !cargo_test_support::is_nightly() {
+ return;
+ }
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+
+ [profile.release]
+ lto = true
+ "#,
+ )
+ .file("src/main.rs", "fn main() {}")
+ .file("tests/a.rs", "")
+ .file("tests/b.rs", "")
+ .build();
+ p.cargo("test --release -v")
+ .with_stderr_contains("[RUNNING] `rustc[..]--crate-name foo[..]-C lto[..]")
+ .run();
+}
+
+#[cargo_test]
+fn test_all_and_bench() {
+ if !cargo_test_support::is_nightly() {
+ return;
+ }
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+
+ [profile.release]
+ lto = true
+ [profile.bench]
+ lto = true
+ "#,
+ )
+ .file("src/main.rs", "fn main() {}")
+ .file("tests/a.rs", "")
+ .file("tests/b.rs", "")
+ .build();
+ p.cargo("test --release -v")
+ .with_stderr_contains("[RUNNING] `rustc[..]--crate-name a[..]-C lto[..]")
+ .with_stderr_contains("[RUNNING] `rustc[..]--crate-name b[..]-C lto[..]")
+ .with_stderr_contains("[RUNNING] `rustc[..]--crate-name foo[..]-C lto[..]")
+ .run();
+}
diff --git a/tests/testsuite/metabuild.rs b/tests/testsuite/metabuild.rs
index ece3c7aece8..77f4843aa3a 100644
--- a/tests/testsuite/metabuild.rs
+++ b/tests/testsuite/metabuild.rs
@@ -497,7 +497,7 @@ fn metabuild_build_plan() {
"compile_mode": "build",
"kind": null,
"deps": [0, 1],
- "outputs": ["[..]/target/debug/build/foo-[..]/metabuild_foo-[..][EXE]"],
+ "outputs": "{...}",
"links": "{...}",
"program": "rustc",
"args": "{...}",
@@ -686,9 +686,7 @@ fn metabuild_json_artifact() {
{
"executable": null,
"features": [],
- "filenames": [
- "[..]/foo/target/debug/build/foo-[..]/metabuild-foo[EXE]"
- ],
+ "filenames": "{...}",
"fresh": false,
"package_id": "foo [..]",
"profile": "{...}",
diff --git a/tests/testsuite/multitarget.rs b/tests/testsuite/multitarget.rs
index 1235642cb56..a72203c5779 100644
--- a/tests/testsuite/multitarget.rs
+++ b/tests/testsuite/multitarget.rs
@@ -35,7 +35,7 @@ fn simple_build() {
.masquerade_as_nightly_cargo()
.run();
- assert!(p.target_bin(&t1, "foo").is_file());
+ assert!(p.target_bin(t1, "foo").is_file());
assert!(p.target_bin(&t2, "foo").is_file());
}
diff --git a/tests/testsuite/out_dir.rs b/tests/testsuite/out_dir.rs
index 15b26f61980..91365137c9a 100644
--- a/tests/testsuite/out_dir.rs
+++ b/tests/testsuite/out_dir.rs
@@ -90,8 +90,8 @@ fn dynamic_library_with_debug() {
check_dir_contents(
&p.root().join("out"),
&["libfoo.so"],
- &["libfoo.dylib"],
- &["foo.dll", "foo.dll.lib"],
+ &["libfoo.dylib", "libfoo.dylib.dSYM"],
+ &["foo.dll", "foo.dll.exp", "foo.dll.lib", "foo.pdb"],
&["foo.dll", "libfoo.dll.a"],
);
}
diff --git a/tests/testsuite/owner.rs b/tests/testsuite/owner.rs
index 8f3f87260ed..298f08dc83f 100644
--- a/tests/testsuite/owner.rs
+++ b/tests/testsuite/owner.rs
@@ -23,6 +23,10 @@ fn simple_list() {
"id": 70,
"login": "github:rust-lang:core",
"name": "Core"
+ },
+ {
+ "id": 123,
+ "login": "octocat"
}
]
}"#;
@@ -43,7 +47,14 @@ fn simple_list() {
.file("src/main.rs", "fn main() {}")
.build();
- p.cargo("owner -l --token sekrit").run();
+ p.cargo("owner -l --token sekrit")
+ .with_stdout(
+ "\
+github:rust-lang:core (Core)
+octocat
+",
+ )
+ .run();
}
#[cargo_test]
diff --git a/tests/testsuite/search.rs b/tests/testsuite/search.rs
index 75ef3985d97..4b4eb8a01f8 100644
--- a/tests/testsuite/search.rs
+++ b/tests/testsuite/search.rs
@@ -35,9 +35,45 @@ fn write_crates(dest: &Path) {
"repository": "https://github.com/nick29581/libhoare",
"updated_at": "2014-11-20T21:49:21Z",
"versions": null
- }],
+ },
+ {
+ "id": "postgres",
+ "name": "postgres",
+ "updated_at": "2020-05-01T23:17:54.335921+00:00",
+ "versions": null,
+ "keywords": null,
+ "categories": null,
+ "badges": [
+ {
+ "badge_type": "circle-ci",
+ "attributes": {
+ "repository": "sfackler/rust-postgres",
+ "branch": null
+ }
+ }
+ ],
+ "created_at": "2014-11-24T02:34:44.756689+00:00",
+ "downloads": 535491,
+ "recent_downloads": 88321,
+ "max_version": "0.17.3",
+ "newest_version": "0.17.3",
+ "description": "A native, synchronous PostgreSQL client",
+ "homepage": null,
+ "documentation": null,
+ "repository": "https://github.com/sfackler/rust-postgres",
+ "links": {
+ "version_downloads": "/api/v1/crates/postgres/downloads",
+ "versions": "/api/v1/crates/postgres/versions",
+ "owners": "/api/v1/crates/postgres/owners",
+ "owner_team": "/api/v1/crates/postgres/owner_team",
+ "owner_user": "/api/v1/crates/postgres/owner_user",
+ "reverse_dependencies": "/api/v1/crates/postgres/reverse_dependencies"
+ },
+ "exact_match": true
+ }
+ ],
"meta": {
- "total": 1
+ "total": 2
}
}"#;
@@ -56,6 +92,11 @@ fn write_crates(dest: &Path) {
}
}
+const SEARCH_RESULTS: &str = "\
+hoare = \"0.1.1\" # Design by contract style assertions for Rust
+postgres = \"0.17.3\" # A native, synchronous PostgreSQL client
+";
+
fn setup() {
let cargo_home = paths::root().join(".cargo");
fs::create_dir_all(cargo_home).unwrap();
@@ -114,7 +155,7 @@ fn not_update() {
drop(lock);
cargo_process("search postgres")
- .with_stdout_contains("hoare = \"0.1.1\" # Design by contract style assertions for Rust")
+ .with_stdout_contains(SEARCH_RESULTS)
.with_stderr("") // without "Updating ... index"
.run();
}
@@ -125,7 +166,7 @@ fn replace_default() {
set_cargo_config();
cargo_process("search postgres")
- .with_stdout_contains("hoare = \"0.1.1\" # Design by contract style assertions for Rust")
+ .with_stdout_contains(SEARCH_RESULTS)
.with_stderr_contains("[..]Updating [..] index")
.run();
}
@@ -136,7 +177,7 @@ fn simple() {
cargo_process("search postgres --index")
.arg(registry_url().to_string())
- .with_stdout_contains("hoare = \"0.1.1\" # Design by contract style assertions for Rust")
+ .with_stdout_contains(SEARCH_RESULTS)
.run();
}
@@ -162,7 +203,7 @@ about this warning.
[UPDATING] `[CWD]/registry` index
",
)
- .with_stdout_contains("hoare = \"0.1.1\" # Design by contract style assertions for Rust")
+ .with_stdout_contains(SEARCH_RESULTS)
.run();
}
@@ -190,7 +231,7 @@ about this warning.
[UPDATING] `[CWD]/registry` index
",
)
- .with_stdout_contains("hoare = \"0.1.1\" # Design by contract style assertions for Rust")
+ .with_stdout_contains(SEARCH_RESULTS)
.run();
}
@@ -200,7 +241,7 @@ fn multiple_query_params() {
cargo_process("search postgres sql --index")
.arg(registry_url().to_string())
- .with_stdout_contains("hoare = \"0.1.1\" # Design by contract style assertions for Rust")
+ .with_stdout_contains(SEARCH_RESULTS)
.run();
}
diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs
index 7f1561e3372..68fb5bc8182 100644
--- a/tests/testsuite/test.rs
+++ b/tests/testsuite/test.rs
@@ -3360,7 +3360,7 @@ fn json_artifact_includes_test_flag() {
"name":"foo",
"src_path":"[..]lib.rs"
},
- "filenames":["[..]/foo-[..]"],
+ "filenames":"{...}",
"fresh": false
}
diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs
index 0dfb43b6d0a..42ba045a6ab 100644
--- a/tests/testsuite/workspaces.rs
+++ b/tests/testsuite/workspaces.rs
@@ -2117,7 +2117,7 @@ fn ws_err_unused() {
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
Caused by:
- virtual manifests do not specify {}
+ this virtual manifest specifies a {} section, which is not allowed
",
key
))