diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index 5b396c410da..dee4520d901 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -217,6 +217,7 @@ static MIN_LITERAL_REDACTIONS: &[(&str, &str)] = &[ "[NOT_FOUND]", "The system cannot find the path specified. (os error 3)", ), + ("[NOT_FOUND]", "Access is denied. (os error 5)"), ("[NOT_FOUND]", "program not found"), // Unix message for exit status ("[EXIT_STATUS]", "exit status"), diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 91179535acb..703fe3b4ebe 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -1,13 +1,12 @@ //! Tests for the `cargo package` command. -#![allow(deprecated)] - use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::prelude::*; use cargo_test_support::publish::validate_crate_contents; use cargo_test_support::registry::{self, Package}; use cargo_test_support::{ - basic_manifest, cargo_process, git, path2url, paths, project, rustc_host, symlink_supported, t, - ProjectBuilder, + basic_manifest, cargo_process, git, path2url, paths, project, rustc_host, str, + symlink_supported, t, ProjectBuilder, }; use flate2::read::GzDecoder; use std::fs::{self, read_to_string, File}; @@ -35,41 +34,38 @@ fn simple() { .build(); p.cargo("package") - .with_stderr( - "\ -[WARNING] manifest has no documentation[..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package") - .with_stderr( - "\ -[WARNING] manifest has no documentation[..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -85,18 +81,16 @@ See [..] fn metadata_warning() { let p = project().file("src/main.rs", "fn main() {}").build(); p.cargo("package") - .with_stderr( - "\ -warning: manifest has no description, license, license-file, documentation, \ -homepage or repository. + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let p = project() @@ -114,17 +108,16 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for .file("src/main.rs", "fn main() {}") .build(); p.cargo("package") - .with_stderr( - "\ -warning: manifest has no description, documentation, homepage or repository. + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let p = project() @@ -144,15 +137,14 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for .file("src/main.rs", "fn main() {}") .build(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -170,19 +162,18 @@ fn package_verbose() { println!("package main repo"); cargo_process("package -v --no-verify") .cwd(repo.root()) - .with_stderr( - "\ -[WARNING] manifest has no description[..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[PACKAGING] foo v0.0.1 ([..]) +[PACKAGING] foo v0.0.1 ([ROOT]/all) [ARCHIVING] .cargo_vcs_info.json [ARCHIVING] Cargo.lock [ARCHIVING] Cargo.toml [ARCHIVING] Cargo.toml.orig [ARCHIVING] src/main.rs -[PACKAGED] 5 files, [..] ([..] compressed) -", - ) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); let f = File::open(&repo.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -212,18 +203,17 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for println!("package sub-repo"); cargo_process("package -v --no-verify") .cwd(repo.root().join("a/a")) - .with_stderr( - "\ -[WARNING] manifest has no description[..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[PACKAGING] a v0.0.1 ([..]) +[PACKAGING] a v0.0.1 ([ROOT]/all/a/a) [ARCHIVING] .cargo_vcs_info.json [ARCHIVING] Cargo.toml [ARCHIVING] Cargo.toml.orig [ARCHIVING] src/lib.rs -[PACKAGED] 4 files, [..] ([..] compressed) -", - ) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); let f = File::open(&repo.root().join("a/a/target/package/a-0.0.1.crate")).unwrap(); @@ -255,17 +245,16 @@ fn package_verification() { let p = project().file("src/main.rs", "fn main() {}").build(); p.cargo("build").run(); p.cargo("package") - .with_stderr( - "\ -[WARNING] manifest has no description[..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -300,12 +289,10 @@ fn vcs_file_collision() { p.cargo("package") .arg("--no-verify") .with_status(101) - .with_stderr( - "\ -[ERROR] invalid inclusion of reserved file name .cargo_vcs_info.json \ -in package source -", - ) + .with_stderr_data(str![[r#" +[ERROR] invalid inclusion of reserved file name .cargo_vcs_info.json in package source + +"#]]) .run(); } @@ -340,12 +327,10 @@ fn orig_file_collision() { p.cargo("package") .arg("--no-verify") .with_status(101) - .with_stderr( - "\ -[ERROR] invalid inclusion of reserved file name Cargo.toml.orig \ -in package source -", - ) + .with_stderr_data(str![[r#" +[ERROR] invalid inclusion of reserved file name Cargo.toml.orig in package source + +"#]]) .run(); } @@ -374,16 +359,15 @@ fn path_dependency_no_version() { p.cargo("package") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [WARNING] manifest has no documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [ERROR] all dependencies must have a version specified when packaging. -dependency `bar` does not specify a version\n\ +dependency `bar` does not specify a version Note: The packaged dependency will use the version from crates.io, the `path` specification will be removed from the dependency declaration. -", - ) + +"#]]) .run(); } @@ -412,16 +396,15 @@ fn git_dependency_no_version() { p.cargo("package") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [WARNING] manifest has no documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [ERROR] all dependencies must have a version specified when packaging. dependency `foo` does not specify a version Note: The packaged dependency will use the version from crates.io, the `git` specification will be removed from the dependency declaration. -", - ) + +"#]]) .run(); } @@ -497,12 +480,11 @@ fn exclude() { cargo_process("package --no-verify -v") .cwd(repo.root()) - .with_stdout("") - .with_stderr( - "\ -[WARNING] manifest has no description[..] + .with_stdout_data("") + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[PACKAGING] foo v0.0.1 ([..]) +[PACKAGING] foo v0.0.1 ([ROOT]/exclude) [ARCHIVING] .cargo_vcs_info.json [ARCHIVING] Cargo.lock [ARCHIVING] Cargo.toml @@ -518,17 +500,16 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for [ARCHIVING] some_dir/file_deep_4 [ARCHIVING] some_dir/file_deep_5 [ARCHIVING] src/main.rs -[PACKAGED] 15 files, [..] ([..] compressed) -", - ) +[PACKAGED] 15 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); assert!(repo.root().join("target/package/foo-0.0.1.crate").is_file()); cargo_process("package -l") .cwd(repo.root()) - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.lock Cargo.toml @@ -544,8 +525,8 @@ some_dir/file_deep_3 some_dir/file_deep_4 some_dir/file_deep_5 src/main.rs -", - ) + +"#]]) .run(); } @@ -574,12 +555,11 @@ fn include() { cargo_process("package --no-verify -v") .cwd(repo.root()) - .with_stderr( - "\ -[WARNING] manifest has no description[..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [WARNING] both package.include and package.exclude are specified; the exclude list will be ignored -[PACKAGING] foo v0.0.1 ([..]) +[PACKAGING] foo v0.0.1 ([ROOT]/include) [ARCHIVING] .cargo_vcs_info.json [ARCHIVING] .dotfile [ARCHIVING] Cargo.lock @@ -587,9 +567,9 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for [ARCHIVING] Cargo.toml.orig [ARCHIVING] foo.txt [ARCHIVING] src/main.rs -[PACKAGED] 7 files, [..] ([..] compressed) -", - ) +[PACKAGED] 7 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); } @@ -642,10 +622,15 @@ fn package_git_submodule() { project .cargo("package --no-verify -v") - .with_stderr_contains("[ARCHIVING] bar/Makefile") + .with_stderr_data(str![[r#" +... +[ARCHIVING] bar/Makefile +... +"#]]) .run(); } +#[allow(deprecated)] #[cargo_test] /// Tests if a symlink to a git submodule is properly handled. /// @@ -701,15 +686,14 @@ fn no_duplicates_from_modified_tracked_files() { p.change_file("src/main.rs", r#"fn main() { println!("A change!"); }"#); p.cargo("build").run(); p.cargo("package --list --allow-dirty") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); } @@ -738,37 +722,34 @@ fn ignore_nested() { .build(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -791,13 +772,12 @@ fn package_weird_characters() { p.cargo("package") .with_status(101) - .with_stderr( - "\ -warning: [..] -See [..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [ERROR] cannot package a filename with a special character `:`: src/:foo -", - ) + +"#]]) .run(); } @@ -814,17 +794,16 @@ fn repackage_on_source_change() { // Check that cargo rebuilds the tarball p.cargo("package") - .with_stderr( - "\ -[WARNING] [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 5 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Check that the tarball contains the added file @@ -880,17 +859,17 @@ fn broken_symlink() { p.cargo("package -v") .with_status(101) - .with_stderr_contains( - "\ + .with_stderr_data(str![[r#" +... [ERROR] failed to prepare local package for uploading Caused by: - failed to open for archiving: `[..]foo.rs` + failed to open for archiving: `[ROOT]/foo/src/foo.rs` Caused by: - [..] -", - ) + [NOT_FOUND] + +"#]]) .run(); } @@ -933,14 +912,13 @@ fn broken_but_excluded_symlink() { p.cargo("package -v --list") // `src/foo.rs` is excluded. - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); } @@ -962,17 +940,16 @@ fn gitignore_symlink_dir() { }); p.cargo("package -l --no-metadata") - .with_stderr("") - .with_stdout( - "\ + .with_stderr_data("") + .with_stdout_data(str![[r#" .cargo_vcs_info.json .gitignore Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); } @@ -995,31 +972,29 @@ fn gitignore_symlink_dir_dirty() { p.symlink("src", "src4"); p.cargo("package -l --no-metadata") - .with_stderr("") - .with_stdout( - "\ + .with_stderr_data("") + .with_stdout_data(str![[r#" .cargo_vcs_info.json .gitignore Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package -l --no-metadata --allow-dirty") - .with_stderr("") - .with_stdout( - "\ + .with_stderr_data("") + .with_stdout_data(str![[r#" .cargo_vcs_info.json .gitignore Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); } @@ -1039,7 +1014,11 @@ fn package_symlink_to_dir() { .symlink_dir("bla", "foo") .build() .cargo("package -v") - .with_stderr_contains("[ARCHIVING] foo/Makefile") + .with_stderr_data(str![[r#" +... +[ARCHIVING] foo/Makefile +... +"#]]) .run(); } @@ -1058,9 +1037,11 @@ fn filesystem_loop() { .symlink_dir("a/b", "a/b/c/d/foo") .build() .cargo("package -v") - .with_stderr_contains( - "[WARNING] File system loop found: [..]/a/b/c/d/foo points to an ancestor [..]/a/b", - ) + .with_stderr_data(str![[r#" +... +[WARNING] File system loop found: [ROOT]/foo/a/b/c/d/foo points to an ancestor [ROOT]/foo/a/b +... +"#]]) .run(); } @@ -1106,16 +1087,14 @@ fn do_not_package_if_repository_is_dirty() { p.cargo("package") .with_status(101) - .with_stderr( - "\ -error: 1 files in the working directory contain changes that were not yet \ -committed into git: + .with_stderr_data(str![[r#" +[ERROR] 1 files in the working directory contain changes that were not yet committed into git: Cargo.toml to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag -", - ) + +"#]]) .run(); } @@ -1144,15 +1123,14 @@ fn dirty_ignored() { p.change_file("src/build/mod.rs", ""); p.cargo("package --list") .with_status(101) - .with_stderr( - "\ -error: 1 files in the working directory contain changes that were not yet committed into git: + .with_stderr_data(str![[r#" +[ERROR] 1 files in the working directory contain changes that were not yet committed into git: src/build/mod.rs to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag -", - ) + +"#]]) .run(); // Add the ignored file and make sure it is included. let mut index = t!(repo.index()); @@ -1160,16 +1138,15 @@ to proceed despite this and include the uncommitted changes, pass the `--allow-d t!(index.write()); git::commit(&repo); p.cargo("package --list") - .with_stderr("") - .with_stdout( - "\ + .with_stderr_data("") + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.toml Cargo.toml.orig src/build/mod.rs src/lib.rs -", - ) + +"#]]) .run(); } @@ -1222,15 +1199,14 @@ fn issue_13695_allow_dirty_vcs_info() { // Listing provides a consistent result. p.cargo("package --list --allow-dirty") - .with_stderr("") - .with_stdout( - "\ + .with_stderr_data("") + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.toml Cargo.toml.orig src/lib.rs -", - ) + +"#]]) .run(); } @@ -1573,12 +1549,13 @@ fn test_edition() { .build(); p.cargo("check -v") - .with_stderr_contains( - "\ -[CHECKING] foo v0.0.1 ([..]) -[RUNNING] `rustc [..]--edition=2018 [..] -", - ) + .with_stderr_data(str![[r#" +... +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc [..]--edition=2018 [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1622,18 +1599,16 @@ fn test_edition_malformed() { p.cargo("check -v") .with_status(101) - .with_stderr( - "\ -error: failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: failed to parse the `edition` key Caused by: supported edition values are `2015`, `2018`, `2021`, or `2024`, but `chicken` is unknown -" - .to_string(), - ) + +"#]]) .run(); } @@ -1654,18 +1629,16 @@ fn test_edition_from_the_future() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -error: failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: failed to parse the `edition` key Caused by: this version of Cargo is older than the `2038` edition, and only supports `2015`, `2018`, `2021`, and `2024` editions. -" - .to_string(), - ) + +"#]]) .run(); } @@ -1695,21 +1668,21 @@ fn do_not_package_if_src_was_modified() { p.cargo("package") .with_status(101) - .with_stderr_contains( - "\ -error: failed to verify package tarball + .with_stderr_data(str![[r#" +... +[ERROR] failed to verify package tarball Caused by: - Source directory was modified by build.rs during cargo publish. \ - Build scripts should not modify anything outside of OUT_DIR. - Changed: [CWD]/target/package/foo-0.0.1/bar.txt - Added: [CWD]/target/package/foo-0.0.1/new-dir - [CWD]/target/package/foo-0.0.1/src/generated.txt - Removed: [CWD]/target/package/foo-0.0.1/dir - [CWD]/target/package/foo-0.0.1/dir/foo.txt - - To proceed despite this, pass the `--no-verify` flag.", - ) + Source directory was modified by build.rs during cargo publish. Build scripts should not modify anything outside of OUT_DIR. + Changed: [ROOT]/foo/target/package/foo-0.0.1/bar.txt + Added: [ROOT]/foo/target/package/foo-0.0.1/new-dir + [ROOT]/foo/target/package/foo-0.0.1/src/generated.txt + Removed: [ROOT]/foo/target/package/foo-0.0.1/dir + [ROOT]/foo/target/package/foo-0.0.1/dir/foo.txt + + To proceed despite this, pass the `--no-verify` flag. + +"#]]) .run(); p.cargo("package --no-verify").run(); @@ -1803,7 +1776,11 @@ fn package_no_default_features() { .build(); p.cargo("package --no-default-features") - .with_stderr_contains("error: This crate requires `required` feature!") + .with_stderr_data(str![[r#" +... +[ERROR] This crate requires `required` feature! +... +"#]]) .with_status(101) .run(); } @@ -1825,7 +1802,12 @@ fn include_cargo_toml_implicit() { .build(); p.cargo("package --list") - .with_stdout("Cargo.toml\nCargo.toml.orig\nsrc/lib.rs\n") + .with_stdout_data(str![[r#" +Cargo.toml +Cargo.toml.orig +src/lib.rs + +"#]]) .run(); } @@ -1856,8 +1838,8 @@ fn include_exclude_test(include: &str, exclude: &str, files: &[&str], expected: let p = pb.build(); p.cargo("package --list") - .with_stderr("") - .with_stdout(expected) + .with_stderr_data("") + .with_stdout_data(expected) .run(); p.root().rm_rf(); } @@ -2072,12 +2054,11 @@ fn empty_readme_path() { p.cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ -[ERROR] readme `` does not appear to exist (relative to `[..]/foo`). -Please update the readme setting in the manifest at `[..]/foo/Cargo.toml`. -", - ) + .with_stderr_data(str![[r#" +[ERROR] readme `` does not appear to exist (relative to `[ROOT]/foo`). +Please update the readme setting in the manifest at `[ROOT]/foo/Cargo.toml`. + +"#]]) .run(); } @@ -2103,12 +2084,11 @@ fn invalid_readme_path() { p.cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ -[ERROR] readme `DOES-NOT-EXIST` does not appear to exist (relative to `[..]/foo`). -Please update the readme setting in the manifest at `[..]/foo/Cargo.toml`. -", - ) + .with_stderr_data(str![[r#" +[ERROR] readme `DOES-NOT-EXIST` does not appear to exist (relative to `[ROOT]/foo`). +Please update the readme setting in the manifest at `[ROOT]/foo/Cargo.toml`. + +"#]]) .run(); } @@ -2134,14 +2114,13 @@ fn readme_or_license_file_is_dir() { p.cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ -[ERROR] license-file `./src` does not appear to exist (relative to `[..]/foo`). -Please update the license-file setting in the manifest at `[..]/foo/Cargo.toml`. -readme `./src` does not appear to exist (relative to `[..]/foo`). -Please update the readme setting in the manifest at `[..]/foo/Cargo.toml`. -", - ) + .with_stderr_data(str![[r#" +[ERROR] license-file `./src` does not appear to exist (relative to `[ROOT]/foo`). +Please update the license-file setting in the manifest at `[ROOT]/foo/Cargo.toml`. +readme `./src` does not appear to exist (relative to `[ROOT]/foo`). +Please update the readme setting in the manifest at `[ROOT]/foo/Cargo.toml`. + +"#]]) .run(); } @@ -2166,14 +2145,13 @@ fn empty_license_file_path() { p.cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [WARNING] manifest has no license or license-file. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[ERROR] license-file `` does not appear to exist (relative to `[..]/foo`). -Please update the license-file setting in the manifest at `[..]/foo/Cargo.toml`. -", - ) +[ERROR] license-file `` does not appear to exist (relative to `[ROOT]/foo`). +Please update the license-file setting in the manifest at `[ROOT]/foo/Cargo.toml`. + +"#]]) .run(); } @@ -2198,12 +2176,11 @@ fn invalid_license_file_path() { p.cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ -[ERROR] license-file `does-not-exist` does not appear to exist (relative to `[..]/foo`). -Please update the license-file setting in the manifest at `[..]/foo/Cargo.toml`. -", - ) + .with_stderr_data(str![[r#" +[ERROR] license-file `does-not-exist` does not appear to exist (relative to `[ROOT]/foo`). +Please update the license-file setting in the manifest at `[ROOT]/foo/Cargo.toml`. + +"#]]) .run(); } @@ -2229,30 +2206,28 @@ fn license_file_implicit_include() { }); p.cargo("package --list") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.toml Cargo.toml.orig src/lib.rs subdir/LICENSE -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data("") .run(); p.cargo("package --no-verify -v") - .with_stderr( - "\ -[PACKAGING] foo v1.0.0 [..] + .with_stderr_data(str![[r#" +[PACKAGING] foo v1.0.0 ([ROOT]/foo) [ARCHIVING] .cargo_vcs_info.json [ARCHIVING] Cargo.toml [ARCHIVING] Cargo.toml.orig [ARCHIVING] src/lib.rs [ARCHIVING] subdir/LICENSE -[PACKAGED] 5 files, [..] ([..] compressed) -", - ) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-1.0.0.crate")).unwrap(); validate_crate_contents( @@ -2290,27 +2265,25 @@ fn relative_license_included() { .build(); p.cargo("package --list") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.toml Cargo.toml.orig LICENSE src/lib.rs -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data("") .run(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v1.0.0 [..] -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v1.0.0 [..] -[COMPILING] foo v1.0.0 [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v1.0.0 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v1.0.0 ([ROOT]/foo) +[COMPILING] foo v1.0.0 ([ROOT]/foo/target/package/foo-1.0.0) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-1.0.0.crate")).unwrap(); validate_crate_contents( @@ -2349,29 +2322,28 @@ fn relative_license_include_collision() { .build(); p.cargo("package --list") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.toml Cargo.toml.orig LICENSE src/lib.rs -", - ) - .with_stderr("[WARNING] license-file `../LICENSE` appears to be [..]") - .run(); - p.cargo("package") - .with_stderr( - "\ -[WARNING] license-file `../LICENSE` appears to be [..] -[PACKAGING] foo v1.0.0 [..] -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v1.0.0 [..] -[COMPILING] foo v1.0.0 [..] -[FINISHED] [..] -", - ) +"#]]) + .with_stderr_data(str![[r#" +[WARNING] license-file `../LICENSE` appears to be a path outside of the package, but there is already a file named `LICENSE` in the root of the package. The archived crate will contain the copy in the root of the package. Update the license-file to point to the path relative to the root of the package to remove this warning. + +"#]]) .run(); + + p.cargo("package").with_stderr_data(str![[r#" +[WARNING] license-file `../LICENSE` appears to be a path outside of the package, but there is already a file named `LICENSE` in the root of the package. The archived crate will contain the copy in the root of the package. Update the license-file to point to the path relative to the root of the package to remove this warning. +[PACKAGING] foo v1.0.0 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v1.0.0 ([ROOT]/foo) +[COMPILING] foo v1.0.0 ([ROOT]/foo/target/package/foo-1.0.0) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); let f = File::open(&p.root().join("target/package/foo-1.0.0.crate")).unwrap(); validate_crate_contents( f, @@ -2408,16 +2380,18 @@ fn package_restricted_windows() { p.cargo("package") // use unordered here because the order of the warning is different on each platform. - .with_stderr_unordered( - "\ -[WARNING] file src/aux/mod.rs is a reserved Windows filename, it will not work on Windows platforms + .with_stderr_data( + str![[r#" [WARNING] file src/con.rs is a reserved Windows filename, it will not work on Windows platforms -[PACKAGING] foo [..] -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] foo [..] -[COMPILING] foo [..] -[FINISHED] [..] -", +[WARNING] file src/aux/mod.rs is a reserved Windows filename, it will not work on Windows platforms +[PACKAGING] foo v0.1.0 ([ROOT]/foo) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.1.0 ([ROOT]/foo) +[COMPILING] foo v0.1.0 ([ROOT]/foo/target/package/foo-0.1.0) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -2438,43 +2412,40 @@ fn finds_git_in_parent() { p.change_file("ignoreme", ""); p.change_file("ignoreme2", ""); p.cargo("package --list --allow-dirty") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.toml Cargo.toml.orig ignoreme ignoreme2 src/lib.rs -", - ) + +"#]]) .run(); p.change_file(".gitignore", "ignoreme"); p.cargo("package --list --allow-dirty") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json .gitignore Cargo.toml Cargo.toml.orig ignoreme2 src/lib.rs -", - ) + +"#]]) .run(); fs::write(repo_path.join(".gitignore"), "ignoreme2").unwrap(); p.cargo("package --list --allow-dirty") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json .gitignore Cargo.toml Cargo.toml.orig src/lib.rs -", - ) + +"#]]) .run(); } @@ -2512,28 +2483,32 @@ fn reserved_windows_name() { .build(); p.cargo("package") .with_status(101) - .with_stderr_contains( - "\ -error: failed to verify package tarball + .with_stderr_data(str![[r#" +... +[ERROR] failed to verify package tarball Caused by: - failed to download replaced source registry `[..]` + failed to download replaced source registry `crates-io` Caused by: - failed to unpack package `[..] `[..]`)` + failed to unpack package `bar v1.0.0 (registry `dummy-registry`)` Caused by: - failed to unpack entry at `[..]aux.rs` + failed to unpack entry at `bar-1.0.0/src/aux.rs` Caused by: - `[..]aux.rs` appears to contain a reserved Windows path, it cannot be extracted on Windows + `bar-1.0.0/src/aux.rs` appears to contain a reserved Windows path, it cannot be extracted on Windows Caused by: - failed to unpack `[..]aux.rs` + failed to unpack `[ROOT]/home/.cargo/registry/src/-[HASH]/bar-1.0.0/src/aux.rs` Caused by: - failed to unpack `[..]aux.rs` into `[..]aux.rs`", - ) + failed to unpack `bar-1.0.0/src/aux.rs` into `[ROOT]/home/.cargo/registry/src/-[HASH]/bar-1.0.0/src/aux.rs` + +Caused by: + [NOT_FOUND] + +"#]]) .run(); } @@ -2566,26 +2541,24 @@ fn list_with_path_and_lock() { .build(); p.cargo("package --list") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] all dependencies must have a version specified when packaging. dependency `bar` does not specify a version Note: The packaged dependency will use the version from crates.io, the `path` specification will be removed from the dependency declaration. -", - ) + +"#]]) .run(); } @@ -2648,18 +2621,14 @@ fn long_file_names() { .build(); p.cargo("package").run(); - p.cargo("package --list") - .with_stdout(&format!( - "\ -{} + p.cargo("package --list").with_stdout_data(str![[r#" +012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - long_name - )) - .run(); + +"#]]).run(); } #[cargo_test] @@ -2729,30 +2698,28 @@ fn deleted_git_working_tree() { }); p.root().join("src/lib.rs").rm_rf(); p.cargo("package --allow-dirty --list") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package --allow-dirty").run(); let mut index = t!(repo.index()); t!(index.remove(Path::new("src/lib.rs"), 0)); t!(index.write()); p.cargo("package --allow-dirty --list") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package --allow-dirty").run(); } @@ -2798,11 +2765,10 @@ fn package_in_workspace_not_found() { p.cargo("package -p doesnt-exist") .with_status(101) - .with_stderr_contains( - "\ + .with_stderr_data(str![[r#" [ERROR] package ID specification `doesnt-exist` did not match any packages -", - ) + +"#]]) .run(); } @@ -2842,24 +2808,23 @@ fn in_workspace() { .build(); p.cargo("package --workspace") - .with_stderr( - "\ -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] bar v0.0.1 ([CWD]/bar) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] bar v0.0.1 ([CWD]/bar) -[COMPILING] bar v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] bar v0.0.1 ([ROOT]/foo/bar) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] bar v0.0.1 ([ROOT]/foo/bar) +[COMPILING] bar v0.0.1 ([ROOT]/foo/target/package/bar-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); @@ -2897,15 +2862,14 @@ fn workspace_noconflict_readme() { .build(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] bar v0.0.1 ([CWD]/bar) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] bar v0.0.1 ([CWD]/bar) -[COMPILING] bar v0.0.1 ([CWD]/[..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] bar v0.0.1 ([ROOT]/foo/bar) +[PACKAGED] 6 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] bar v0.0.1 ([ROOT]/foo/bar) +[COMPILING] bar v0.0.1 ([ROOT]/foo/target/package/bar-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2939,18 +2903,15 @@ fn workspace_conflict_readme() { .file("bar/README.md", "# workspace member: Bar") .build(); - p.cargo("package") - .with_stderr( - "\ -warning: readme `../README.md` appears to be a path outside of the package, but there is already a file named `README.md` in the root of the package. The archived crate will contain the copy in the root of the package. Update the readme to point to the path relative to the root of the package to remove this warning. -[PACKAGING] bar v0.0.1 ([CWD]/bar) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] bar v0.0.1 ([CWD]/bar) -[COMPILING] bar v0.0.1 ([CWD]/[..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) - .run(); + p.cargo("package").with_stderr_data(str![[r#" +[WARNING] readme `../README.md` appears to be a path outside of the package, but there is already a file named `README.md` in the root of the package. The archived crate will contain the copy in the root of the package. Update the readme to point to the path relative to the root of the package to remove this warning. +[PACKAGING] bar v0.0.1 ([ROOT]/foo/bar) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] bar v0.0.1 ([ROOT]/foo/bar) +[COMPILING] bar v0.0.1 ([ROOT]/foo/target/package/bar-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -3133,25 +3094,23 @@ version = "0.0.1" assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] 4 files[..] -[VERIFYING] foo v0.0.1 [..] -[COMPILING] foo v0.0.1 [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -3238,26 +3197,24 @@ version = "0.0.1" let output = p.cargo("package").exec_with_output().unwrap(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig src/bar.txt src/main.rs -", - ) + +"#]]) .run(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] 5 files, [..] -[VERIFYING] foo v0.0.1 [..] -[COMPILING] foo v0.0.1 [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -3358,8 +3315,7 @@ version = "0.0.1" let output = p.cargo("package").exec_with_output().unwrap(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig @@ -3367,19 +3323,18 @@ bla/bar.txt foo/bar.txt src/main.rs src/main.rs.bak -", - ) + +"#]]) .run(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] 7 files, [..] -[VERIFYING] foo v0.0.1 [..] -[COMPILING] foo v0.0.1 [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 7 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -3441,28 +3396,24 @@ fn normalize_case() { ) .unwrap(); - p.cargo("package") - .with_stderr( - "\ -[WARNING] manifest has no documentation[..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) + p.cargo("package").with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [WARNING] ignoring `package.build` as `build.rs` is not included in the published package [WARNING] ignoring binary `foo` as `src/main.rs` is not included in the published package [WARNING] ignoring example `ExampleFoo` as `examples/ExampleFoo.rs` is not included in the published package [WARNING] ignoring test `ExplicitPath` as `tests/ExplicitPath.rs` is not included in the published package [WARNING] ignoring test `explicitpath` as `tests/explicitpath.rs` is not included in the published package -[PACKAGED] 8 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) - .run(); +[PACKAGED] 8 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Build.rs Cargo.lock Cargo.toml @@ -3471,27 +3422,24 @@ Examples/ExampleFoo.rs Tests/ExplicitPath.rs src/Main.rs src/lib.rs -", - ) + +"#]]) .run(); - p.cargo("package") - .with_stderr( - "\ -[WARNING] manifest has no documentation[..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) + p.cargo("package").with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [WARNING] ignoring `package.build` as `build.rs` is not included in the published package [WARNING] ignoring binary `foo` as `src/main.rs` is not included in the published package [WARNING] ignoring example `ExampleFoo` as `examples/ExampleFoo.rs` is not included in the published package [WARNING] ignoring test `ExplicitPath` as `tests/ExplicitPath.rs` is not included in the published package [WARNING] ignoring test `explicitpath` as `tests/explicitpath.rs` is not included in the published package -[PACKAGED] 8 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) - .run(); +[PACKAGED] 8 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); validate_crate_contents( @@ -3557,41 +3505,38 @@ fn mixed_case() { .build(); p.cargo("package") - .with_stderr( - "\ -[WARNING] manifest has no documentation[..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package") - .with_stderr( - "\ -[WARNING] manifest has no documentation[..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -3619,17 +3564,16 @@ fn versionless_package() { .build(); p.cargo("package") - .with_stderr( - "\ -warning: manifest has no license, license-file, documentation, homepage or repository. + .with_stderr_data(str![[r#" +[WARNING] manifest has no license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[PACKAGING] foo v0.0.0 ([CWD]) -[PACKAGED] 4 files, [..]B ([..]B compressed) -[VERIFYING] foo v0.0.0 ([CWD]) -[COMPILING] foo v0.0.0 ([CWD]/target/package/foo-0.0.0) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[PACKAGING] foo v0.0.0 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.0 ([ROOT]/foo) +[COMPILING] foo v0.0.0 ([ROOT]/foo/target/package/foo-0.0.0) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.0.crate")).unwrap(); @@ -3650,8 +3594,7 @@ fn include_files_called_target_project() { .build(); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig @@ -3660,8 +3603,8 @@ data/target derp/not_target/foo.txt derp/target/foo.txt src/main.rs -", - ) + +"#]]) .run(); } @@ -3674,8 +3617,7 @@ fn include_files_called_target_git() { _ = fs::create_dir(p.build_dir()).unwrap(); _ = fs::write(p.build_dir().join("foo.txt"), "").unwrap(); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.lock Cargo.toml @@ -3685,16 +3627,15 @@ data/target derp/not_target/foo.txt derp/target/foo.txt src/main.rs -", - ) + +"#]]) .run(); // if target is committed, it should be included. git::add(&repo); git::commit(&repo); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.lock Cargo.toml @@ -3705,8 +3646,8 @@ derp/not_target/foo.txt derp/target/foo.txt src/main.rs target/foo.txt -", - ) + +"#]]) .run(); // Untracked files shouldn't be included, if they are also ignored. @@ -3715,8 +3656,7 @@ target/foo.txt git::commit(&repo); _ = fs::write(p.build_dir().join("untracked.txt"), "").unwrap(); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json .gitignore Cargo.lock @@ -3728,8 +3668,8 @@ derp/not_target/foo.txt derp/target/foo.txt src/main.rs target/foo.txt -", - ) + +"#]]) .run(); } @@ -3776,13 +3716,14 @@ fn build_script_outside_pkg_root() { // custom_build.rs does not exist p.cargo("package -l") .with_status(101) - .with_stderr("\ -warning: manifest has no documentation, homepage or repository. + .with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -error: the source file of build script doesn't appear to exist. +[ERROR] the source file of build script doesn't appear to exist. This may cause issue during packaging, as modules resolution and resources included via macros are often relative to the path of source files. -Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and point to a path inside the root of the package. -") +Please update the `build` setting in the manifest at `[ROOT]/foo/Cargo.toml` and point to a path inside the root of the package. + +"#]]) .run(); // custom_build.rs outside the package root @@ -3791,15 +3732,15 @@ Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and poin _ = fs::write(&custom_build_root.join("custom_build.rs"), "fn main() {}"); p.cargo("package -l") .with_status(101) - .with_stderr(&format!( - "\ -warning: manifest has no documentation, homepage or repository. + .with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -error: the source file of build script doesn't appear to be a path inside of the package. -It is at `{}/t_custom_build/custom_build.rs`, whereas the root the package is `[CWD]`. +[ERROR] the source file of build script doesn't appear to be a path inside of the package. +It is at `[ROOT]/t_custom_build/custom_build.rs`, whereas the root the package is `[ROOT]/foo`. This may cause issue during packaging, as modules resolution and resources included via macros are often relative to the path of source files. -Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and point to a path inside the root of the package. -", paths::root().display())) +Please update the `build` setting in the manifest at `[ROOT]/foo/Cargo.toml` and point to a path inside the root of the package. + +"#]]) .run(); } @@ -3825,14 +3766,13 @@ fn symlink_manifest_path() { cargo_process("package --no-verify --manifest-path") .arg(foo_symlink.join("Cargo.toml")) - .with_stderr( - "\ -warning: manifest has no description, license, license-file, documentation, homepage or repository. + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. -[PACKAGING] foo v1.0.0 ([..]foo-symlink) -[PACKAGED] 6 files[..] -", - ) +[PACKAGING] foo v1.0.0 ([ROOT]/foo-symlink) +[PACKAGED] 6 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run() } @@ -3885,16 +3825,15 @@ fn normalize_paths() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 11 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 11 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -3988,16 +3927,15 @@ fn discovery_inferred_build_rs_included() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4067,17 +4005,16 @@ fn discovery_inferred_build_rs_excluded() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [WARNING] ignoring `package.build` as `build.rs` is not included in the published package -[PACKAGED] 3 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4145,16 +4082,15 @@ fn discovery_explicit_build_rs_included() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4225,17 +4161,16 @@ fn discovery_explicit_build_rs_excluded() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [WARNING] ignoring `package.build` as `build.rs` is not included in the published package -[PACKAGED] 3 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4302,16 +4237,15 @@ fn discovery_inferred_lib_included() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 5 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4391,17 +4325,16 @@ fn discovery_inferred_lib_excluded() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [WARNING] ignoring library `foo` as `src/lib.rs` is not included in the published package -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4471,16 +4404,15 @@ fn discovery_explicit_lib_included() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 5 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4563,17 +4495,16 @@ fn discovery_explicit_lib_excluded() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [WARNING] ignoring library `foo` as `src/lib.rs` is not included in the published package -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4643,16 +4574,15 @@ fn discovery_inferred_other_included() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 8 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 8 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4753,20 +4683,19 @@ fn discovery_inferred_other_excluded() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [WARNING] ignoring binary `foo` as `src/bin/foo/main.rs` is not included in the published package [WARNING] ignoring example `example_foo` as `examples/example_foo.rs` is not included in the published package [WARNING] ignoring test `test_foo` as `tests/test_foo.rs` is not included in the published package [WARNING] ignoring benchmark `bench_foo` as `benches/bench_foo.rs` is not included in the published package -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4848,16 +4777,15 @@ fn discovery_explicit_other_included() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 8 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 8 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -4970,20 +4898,19 @@ fn discovery_explicit_other_excluded() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [WARNING] ignoring binary `foo` as `src/bin/foo/main.rs` is not included in the published package [WARNING] ignoring example `example_foo` as `examples/example_foo.rs` is not included in the published package [WARNING] ignoring test `test_foo` as `tests/test_foo.rs` is not included in the published package [WARNING] ignoring benchmark `bench_foo` as `benches/bench_foo.rs` is not included in the published package -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -5063,16 +4990,15 @@ fn deterministic_build_targets() { .build(); p.cargo("package") - .with_stdout("") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 10 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stdout_data("") + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 10 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); diff --git a/tests/testsuite/package_features.rs b/tests/testsuite/package_features.rs index 78fe68dfd41..139d16da4c0 100644 --- a/tests/testsuite/package_features.rs +++ b/tests/testsuite/package_features.rs @@ -1,10 +1,9 @@ //! Tests for feature selection on the command-line. -#![allow(deprecated)] - use super::features2::switch_to_resolver_2; +use cargo_test_support::prelude::*; use cargo_test_support::registry::{Dependency, Package}; -use cargo_test_support::{basic_manifest, project}; +use cargo_test_support::{basic_manifest, project, str}; use std::fmt::Write; #[cargo_test] @@ -58,37 +57,49 @@ fn virtual_no_default_features() { .build(); p.cargo("check --no-default-features") - .with_stderr_unordered( - "\ -[UPDATING] [..] + .with_stderr_data( + str![[r#" +[UPDATING] `dummy-registry` index [LOCKING] 3 packages to latest compatible versions -[CHECKING] a v0.1.0 [..] -[CHECKING] b v0.1.0 [..] -[FINISHED] [..] -", +[CHECKING] a v0.1.0 ([ROOT]/foo/a) +[CHECKING] b v0.1.0 ([ROOT]/foo/b) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); p.cargo("check --features foo") .with_status(101) - .with_stderr( - "[ERROR] none of the selected packages contains these features: foo, did you mean: f1?", - ) + .with_stderr_data(str![[r#" +[ERROR] none of the selected packages contains these features: foo, did you mean: f1? + +"#]]) .run(); p.cargo("check --features a/dep1,b/f1,b/f2,f2") .with_status(101) - .with_stderr("[ERROR] none of the selected packages contains these features: b/f2, f2, did you mean: f1?") + .with_stderr_data(str![[r#" +[ERROR] none of the selected packages contains these features: b/f2, f2, did you mean: f1? + +"#]]) .run(); p.cargo("check --features a/dep,b/f1,b/f2,f2") .with_status(101) - .with_stderr("[ERROR] none of the selected packages contains these features: a/dep, b/f2, f2, did you mean: a/dep1, f1?") + .with_stderr_data(str![[r#" +[ERROR] none of the selected packages contains these features: a/dep, b/f2, f2, did you mean: a/dep1, f1? + +"#]]) .run(); p.cargo("check --features a/dep,a/dep1") .with_status(101) - .with_stderr("[ERROR] none of the selected packages contains these features: a/dep, did you mean: b/f1?") + .with_stderr_data(str![[r#" +[ERROR] none of the selected packages contains these features: a/dep, did you mean: b/f1? + +"#]]) .run(); } @@ -112,9 +123,10 @@ fn virtual_typo_member_feature() { .build() .cargo("check --features a/deny-warning") .with_status(101) - .with_stderr( - "[ERROR] none of the selected packages contains these features: a/deny-warning, did you mean: a/deny-warnings?", - ) + .with_stderr_data(str![[r#" +[ERROR] none of the selected packages contains these features: a/deny-warning, did you mean: a/deny-warnings? + +"#]]) .run(); } @@ -153,13 +165,15 @@ fn virtual_features() { .build(); p.cargo("check --features f1") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 2 packages to latest compatible versions -[CHECKING] a [..] -[CHECKING] b [..] -[FINISHED] [..] -", +[CHECKING] a v0.1.0 ([ROOT]/foo/a) +[CHECKING] b v0.1.0 ([ROOT]/foo/b) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -222,13 +236,15 @@ fn virtual_with_specific() { .build(); p.cargo("check -p a -p b --features f1,f2,f3") - .with_stderr_unordered( - "\ -[CHECKING] a [..] -[CHECKING] b [..] -[FINISHED] [..] + .with_stderr_data( + str![[r#" [LOCKING] 2 packages to latest compatible versions -", +[CHECKING] a v0.1.0 ([ROOT]/foo/a) +[CHECKING] b v0.1.0 ([ROOT]/foo/b) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -295,28 +311,48 @@ fn other_member_from_current() { // Old behavior. p.cargo("run -p bar --features f1") - .with_stdout("f3f4") + .with_stdout_data(str![[r#" +f3f4 + +"#]]) .run(); p.cargo("run -p bar --features f1,f2") .with_status(101) - .with_stderr("[ERROR] Package `foo[..]` does not have the feature `f2`") + .with_stderr_data(str![[r#" +[ERROR] Package `foo v0.1.0 ([ROOT]/foo)` does not have the feature `f2` + +"#]]) .run(); p.cargo("run -p bar --features bar/f1") - .with_stdout("f1f3") + .with_stdout_data(str![[r#" +f1f3 + +"#]]) .run(); // New behavior. switch_to_resolver_2(&p); - p.cargo("run -p bar --features f1").with_stdout("f1").run(); + p.cargo("run -p bar --features f1") + .with_stdout_data(str![[r#" +f1 + +"#]]) + .run(); p.cargo("run -p bar --features f1,f2") - .with_stdout("f1f2") + .with_stdout_data(str![[r#" +f1f2 + +"#]]) .run(); p.cargo("run -p bar --features bar/f1") - .with_stdout("f1") + .with_stdout_data(str![[r#" +f1 + +"#]]) .run(); } @@ -349,20 +385,30 @@ fn feature_default_resolver() { p.cargo("check --features testt") .with_status(101) - .with_stderr("[ERROR] Package `a[..]` does not have the feature `testt`") + .with_stderr_data(str![[r#" +[ERROR] Package `a v0.1.0 ([ROOT]/foo)` does not have the feature `testt` + +"#]]) .run(); p.cargo("run --features test") .with_status(0) - .with_stdout("feature set") + .with_stdout_data(str![[r#" +feature set + +"#]]) .run(); p.cargo("run --features a/test") .with_status(101) - .with_stderr("[ERROR] package `a[..]` does not have a dependency named `a`") + .with_stderr_data(str![[r#" +[ERROR] package `a v0.1.0 ([ROOT]/foo)` does not have a dependency named `a` + +"#]]) .run(); } +#[allow(deprecated)] #[cargo_test] fn virtual_member_slash() { // member slash feature syntax @@ -427,35 +473,56 @@ fn virtual_member_slash() { p.cargo("check -p a") .with_status(101) - .with_stderr_contains("[..]f1 is set[..]") + .with_stderr_data(str![[r#" +... +[ERROR] f1 is set +... +"#]]) .with_stderr_does_not_contain("[..]f2 is set[..]") .with_stderr_does_not_contain("[..]b is set[..]") .run(); p.cargo("check -p a --features a/f1") .with_status(101) - .with_stderr_contains("[..]f1 is set[..]") + .with_stderr_data(str![[r#" +... +[ERROR] f1 is set +... +"#]]) .with_stderr_does_not_contain("[..]f2 is set[..]") .with_stderr_does_not_contain("[..]b is set[..]") .run(); p.cargo("check -p a --features a/f2") .with_status(101) - .with_stderr_contains("[..]f1 is set[..]") - .with_stderr_contains("[..]f2 is set[..]") + .with_stderr_data(str![[r#" +... +[ERROR] f1 is set +... +[ERROR] f2 is set +... +"#]]) .with_stderr_does_not_contain("[..]b is set[..]") .run(); p.cargo("check -p a --features b/bfeat") .with_status(101) - .with_stderr_contains("[..]bfeat is set[..]") + .with_stderr_data(str![[r#" +... +[ERROR] bfeat is set +... +"#]]) .run(); p.cargo("check -p a --no-default-features").run(); p.cargo("check -p a --no-default-features --features b") .with_status(101) - .with_stderr_contains("[..]b is set[..]") + .with_stderr_data(str![[r#" +... +[ERROR] b is set +... +"#]]) .run(); } @@ -485,30 +552,38 @@ fn non_member() { p.cargo("check -p dep --features f1") .with_status(101) - .with_stderr("[ERROR] cannot specify features for packages outside of workspace") + .with_stderr_data(str![[r#" +[ERROR] cannot specify features for packages outside of workspace + +"#]]) .run(); p.cargo("check -p dep --all-features") .with_status(101) - .with_stderr("[ERROR] cannot specify features for packages outside of workspace") + .with_stderr_data(str![[r#" +[ERROR] cannot specify features for packages outside of workspace + +"#]]) .run(); p.cargo("check -p dep --no-default-features") .with_status(101) - .with_stderr("[ERROR] cannot specify features for packages outside of workspace") + .with_stderr_data(str![[r#" +[ERROR] cannot specify features for packages outside of workspace + +"#]]) .run(); p.cargo("check -p dep") - .with_stderr( - "\ -[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest compatible versions -[DOWNLOADING] [..] -[DOWNLOADED] [..] -[CHECKING] dep [..] -[FINISHED] [..] -", - ) +[DOWNLOADING] crates ... +[DOWNLOADED] dep v1.0.0 (registry `dummy-registry`) +[CHECKING] dep v1.0.0 +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -551,13 +626,19 @@ fn resolver1_member_features() { p.cargo("run -p member1 --features member1/m1-feature") .cwd("member2") - .with_stdout("m1-feature set") + .with_stdout_data(str![[r#" +m1-feature set + +"#]]) .run(); p.cargo("check -p member1 --features member1/m2-feature") .cwd("member2") .with_status(101) - .with_stderr("[ERROR] Package `member1[..]` does not have the feature `m2-feature`") + .with_stderr_data(str![[r#" +[ERROR] Package `member1 v0.1.0 ([ROOT]/foo/member1)` does not have the feature `m2-feature` + +"#]]) .run(); } @@ -600,35 +681,32 @@ fn non_member_feature() { ///////////////////////// V1 non-optional eprintln!("V1 non-optional"); p.cargo("check -p bar") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [CHECKING] bar v1.0.0 -[FINISHED] [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // TODO: This should not be allowed (future warning?) p.cargo("check --features bar/jazz") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [DOWNLOADING] crates ... -[DOWNLOADED] jazz v1.0.0 [..] +[DOWNLOADED] jazz v1.0.0 (registry `dummy-registry`) [CHECKING] jazz v1.0.0 [CHECKING] bar v1.0.0 -[CHECKING] foo v0.1.0 [..] -[FINISHED] [..] -", - ) +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // TODO: This should not be allowed (future warning?) p.cargo("check -p bar --features bar/jazz -v") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [FRESH] jazz v1.0.0 [FRESH] bar v1.0.0 -[FINISHED] [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); ///////////////////////// V1 optional @@ -639,33 +717,30 @@ fn non_member_feature() { // practice, so I'm not going to put much effort into improving it. p.cargo("check -p bar") .with_status(101) - .with_stderr( - "\ -error: package ID specification `bar` did not match any packages + .with_stderr_data(str![[r#" +[ERROR] package ID specification `bar` did not match any packages -Did you mean `foo`? -", - ) + Did you mean `foo`? + +"#]]) .run(); p.cargo("check -p bar --features bar -v") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [FRESH] bar v1.0.0 -[FINISHED] [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // TODO: This should not be allowed (future warning?) p.cargo("check -p bar --features bar/jazz -v") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [FRESH] jazz v1.0.0 [FRESH] bar v1.0.0 -[FINISHED] [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); ///////////////////////// V2 non-optional @@ -673,26 +748,27 @@ error: package ID specification `bar` did not match any packages p.change_file("Cargo.toml", &make_toml("2", false)); // TODO: This should not be allowed (future warning?) p.cargo("check --features bar/jazz -v") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [FRESH] jazz v1.0.0 [FRESH] bar v1.0.0 -[FRESH] foo v0.1.0 [..] -[FINISHED] [..] -", - ) +[FRESH] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("check -p bar -v") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [FRESH] bar v1.0.0 -[FINISHED] [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("check -p bar --features bar/jazz") .with_status(101) - .with_stderr("error: cannot specify features for packages outside of workspace") + .with_stderr_data(str![[r#" +[ERROR] cannot specify features for packages outside of workspace + +"#]]) .run(); ///////////////////////// V2 optional @@ -700,25 +776,33 @@ error: package ID specification `bar` did not match any packages p.change_file("Cargo.toml", &make_toml("2", true)); p.cargo("check -p bar") .with_status(101) - .with_stderr( - "\ -error: package ID specification `bar` did not match any packages + .with_stderr_data(str![[r#" +[ERROR] package ID specification `bar` did not match any packages -Did you mean `foo`? -", - ) + Did you mean `foo`? + +"#]]) .run(); // New --features behavior does not look at cwd. p.cargo("check -p bar --features bar") .with_status(101) - .with_stderr("error: cannot specify features for packages outside of workspace") + .with_stderr_data(str![[r#" +[ERROR] cannot specify features for packages outside of workspace + +"#]]) .run(); p.cargo("check -p bar --features bar/jazz") .with_status(101) - .with_stderr("error: cannot specify features for packages outside of workspace") + .with_stderr_data(str![[r#" +[ERROR] cannot specify features for packages outside of workspace + +"#]]) .run(); p.cargo("check -p bar --features foo/bar") .with_status(101) - .with_stderr("error: cannot specify features for packages outside of workspace") + .with_stderr_data(str![[r#" +[ERROR] cannot specify features for packages outside of workspace + +"#]]) .run(); } diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index b198e4850c0..08756997b39 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -1,11 +1,9 @@ //! Tests for the `cargo publish` command. -#![allow(deprecated)] - use cargo_test_support::git::{self, repo}; use cargo_test_support::paths; use cargo_test_support::registry::{self, Package, RegistryBuilder, Response}; -use cargo_test_support::{basic_manifest, project, publish}; +use cargo_test_support::{basic_manifest, project, publish, str}; use std::fs; use std::sync::{Arc, Mutex}; @@ -112,20 +110,19 @@ fn simple() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` [NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] foo v0.0.1 at registry `crates-io` -", - ) + +"#]]) .run(); validate_upload_foo(); @@ -157,20 +154,19 @@ fn simple_publish_with_http() { .build(); p.cargo("publish --no-verify --token sekrit --registry dummy-registry") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `dummy-registry` [NOTE] waiting for `foo v0.0.1` to be available at registry `dummy-registry`. You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] foo v0.0.1 at registry `dummy-registry` -", - ) + +"#]]) .run(); } @@ -201,20 +197,19 @@ fn simple_publish_with_asymmetric() { p.cargo("publish --no-verify -Zasymmetric-token --registry dummy-registry") .masquerade_as_nightly_cargo(&["asymmetric-token"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `dummy-registry` [NOTE] waiting for `foo v0.0.1` to be available at registry `dummy-registry`. You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] foo v0.0.1 at registry `dummy-registry` -", - ) + +"#]]) .run(); } @@ -246,30 +241,31 @@ fn old_token_location() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr_contains( - "[ERROR] no token found, \ - please run `cargo login`", - ) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[ERROR] no token found, please run `cargo login` +or use environment variable CARGO_REGISTRY_TOKEN + +"#]]) .run(); fs::write(&credentials, format!(r#"token = "{}""#, registry.token())).unwrap(); p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); // Skip `validate_upload_foo` as we just cared we got far enough for verify the token behavior. @@ -302,20 +298,19 @@ fn simple_with_index() { .arg(registry.token()) .arg("--index") .arg(registry.index_url().as_str()) - .with_stderr( - "\ -[..] -[..] -[..] -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] `[ROOT]/registry` index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `[ROOT]/registry` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `[ROOT]/registry`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `[ROOT]/registry` + +"#]]) .run(); // Skip `validate_upload_foo` as we just cared we got far enough for verify the VCS behavior. @@ -349,15 +344,14 @@ fn git_deps() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] index + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [ERROR] all dependencies must have a version specified when publishing. dependency `foo` does not specify a version Note: The published dependency will use the version from crates.io, the `git` specification will be removed from the dependency declaration. -", - ) + +"#]]) .run(); } @@ -390,15 +384,14 @@ fn path_dependency_no_version() { p.cargo("publish") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] index + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [ERROR] all dependencies must have a version specified when publishing. dependency `bar` does not specify a version Note: The published dependency will use the version from crates.io, the `path` specification will be removed from the dependency declaration. -", - ) + +"#]]) .run(); } @@ -427,12 +420,11 @@ fn unpublishable_crate() { p.cargo("publish --index") .arg(registry.index_url().as_str()) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] `foo` cannot be published. `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish. -", - ) + +"#]]) .run(); } @@ -465,17 +457,15 @@ fn dont_publish_dirty() { p.cargo("publish") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -error: 1 files in the working directory contain changes that were not yet \ -committed into git: +[ERROR] 1 files in the working directory contain changes that were not yet committed into git: bar to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag -", - ) + +"#]]) .run(); } @@ -507,21 +497,20 @@ fn publish_clean() { p.cargo("publish") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. You may press ctrl-c to skip waiting; the crate should be available shortly. -[PUBLISHED] foo v0.0.1 [..] -", - ) +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); // Skip `validate_upload_foo_clean` as we just cared we got far enough for verify the VCS behavior. @@ -557,21 +546,20 @@ fn publish_in_sub_repo() { p.cargo("publish") .replace_crates_io(registry.index_url()) .cwd("bar") - .with_stderr( - "\ -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[PACKAGING] foo v0.0.1 ([ROOT]/foo/bar) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.1 ([ROOT]/foo/bar/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo/bar) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); // Skip `validate_upload_foo_clean` as we just cared we got far enough for verify the VCS behavior. @@ -607,21 +595,20 @@ fn publish_when_ignored() { p.cargo("publish") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 6 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); // Skip `validate_upload` as we just cared we got far enough for verify the VCS behavior. @@ -656,21 +643,20 @@ fn ignore_when_crate_ignored() { p.cargo("publish") .replace_crates_io(registry.index_url()) .cwd("bar") - .with_stderr( - "\ -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[PACKAGING] foo v0.0.1 ([ROOT]/foo/bar) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.1 ([ROOT]/foo/bar/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo/bar) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); // Skip `validate_upload` as we just cared we got far enough for verify the VCS behavior. @@ -704,10 +690,11 @@ fn new_crate_rejected() { p.cargo("publish") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr_contains( - "[ERROR] 3 files in the working directory contain \ - changes that were not yet committed into git:", - ) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[ERROR] 3 files in the working directory contain changes that were not yet committed into git: +... +"#]]) .run(); } @@ -734,20 +721,19 @@ fn dry_run() { p.cargo("publish --dry-run --index") .arg(registry.index_url().as_str()) - .with_stderr( - "\ -[UPDATING] `[..]` index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] `[ROOT]/registry` index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [WARNING] aborting upload due to dry run -", - ) + +"#]]) .run(); // Ensure the API request wasn't actually made @@ -780,12 +766,11 @@ fn registry_not_in_publish_list() { .arg("--registry") .arg("alternative") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] `foo` cannot be published. The registry `alternative` is not listed in the `package.publish` value in Cargo.toml. -", - ) + +"#]]) .run(); } @@ -810,12 +795,11 @@ fn publish_empty_list() { p.cargo("publish --registry alternative") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] `foo` cannot be published. `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish. -", - ) + +"#]]) .run(); } @@ -850,21 +834,20 @@ fn publish_allowed_registry() { .build(); p.cargo("publish --registry alternative") - .with_stderr( - "\ -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `alternative` [NOTE] waiting for `foo v0.0.1` to be available at registry `alternative`. -You may press ctrl-c [..] +You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] foo v0.0.1 at registry `alternative` -", - ) + +"#]]) .run(); publish::validate_alt_upload( @@ -911,22 +894,21 @@ fn publish_implicitly_to_only_allowed_registry() { .build(); p.cargo("publish") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [NOTE] found `alternative` as only allowed registry. Publishing to it automatically. [UPDATING] `alternative` index -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `alternative` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `alternative`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `alternative` + +"#]]) .run(); publish::validate_alt_upload( @@ -976,12 +958,11 @@ fn publish_failed_with_index_and_only_allowed_registry() { .arg("--index") .arg(registry.index_url().as_str()) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [NOTE] found `alternative` as only allowed registry. Publishing to it automatically. [ERROR] command-line argument --index requires --token to be specified -", - ) + +"#]]) .run(); } @@ -1011,12 +992,11 @@ fn publish_fail_with_no_registry_specified() { p.cargo("publish") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] `foo` cannot be published. The registry `crates-io` is not listed in the `package.publish` value in Cargo.toml. -", - ) + +"#]]) .run(); } @@ -1041,12 +1021,11 @@ fn block_publish_no_registry() { p.cargo("publish --registry alternative") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] `foo` cannot be published. `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish. -", - ) + +"#]]) .run(); } @@ -1075,33 +1054,31 @@ fn publish_with_crates_io_explicit() { p.cargo("publish --registry alternative") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] `foo` cannot be published. The registry `alternative` is not listed in the `package.publish` value in Cargo.toml. -", - ) + +"#]]) .run(); p.cargo("publish") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[UPDATING] [..] -[WARNING] [..] -[..] -[PACKAGING] [..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); } @@ -1137,23 +1114,22 @@ fn publish_with_select_features() { p.cargo("publish --features required") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[..] -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); } @@ -1189,23 +1165,22 @@ fn publish_with_all_features() { p.cargo("publish --all-features") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[..] -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); } @@ -1242,7 +1217,11 @@ fn publish_with_no_default_features() { p.cargo("publish --no-default-features") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr_contains("error: This crate requires `required` feature!") + .with_stderr_data(str![[r#" +... +[ERROR] This crate requires `required` feature! +... +"#]]) .run(); } @@ -1286,7 +1265,11 @@ fn publish_with_patch() { p.cargo("publish") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr_contains("[..]newfunc[..]") + .with_stderr_data(str![[r#" +... +error[E0425]: cannot find function `newfunc` in crate `bar` +... +"#]]) .run(); // Remove the usage of new functionality and try again. @@ -1294,25 +1277,24 @@ fn publish_with_patch() { p.cargo("publish") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[..] -[..] -[..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [UPDATING] crates.io index -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] bar v1.0.0 +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); publish::validate_upload( @@ -1353,6 +1335,7 @@ You may press ctrl-c [..] ); } +#[allow(deprecated)] #[cargo_test] fn publish_checks_for_token_before_verify() { let registry = registry::RegistryBuilder::new() @@ -1379,27 +1362,31 @@ fn publish_checks_for_token_before_verify() { p.cargo("publish") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr_contains("[ERROR] no token found, please run `cargo login`") + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[ERROR] no token found, please run `cargo login` +or use environment variable CARGO_REGISTRY_TOKEN + +"#]]) .with_stderr_does_not_contain("[VERIFYING] foo v0.0.1 ([CWD])") .run(); // Assert package verified successfully on dry run p.cargo("publish --dry-run") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[..] -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [WARNING] aborting upload due to dry run -", - ) + +"#]]) .run(); } @@ -1421,12 +1408,11 @@ fn publish_with_bad_source() { p.cargo("publish") .with_status(101) - .with_stderr( - "\ -[ERROR] crates-io is replaced with non-remote-registry source registry `[..]/foo/registry`; + .with_stderr_data(str![[r#" +[ERROR] crates-io is replaced with non-remote-registry source registry `[ROOT]/foo/registry`; include `--registry crates-io` to use crates.io -", - ) + +"#]]) .run(); p.change_file( @@ -1442,12 +1428,11 @@ include `--registry crates-io` to use crates.io p.cargo("publish") .with_status(101) - .with_stderr( - "\ -[ERROR] crates-io is replaced with non-remote-registry source dir [..]/foo/vendor; + .with_stderr_data(str![[r#" +[ERROR] crates-io is replaced with non-remote-registry source dir [ROOT]/foo/vendor; include `--registry crates-io` to use crates.io -", - ) + +"#]]) .run(); } @@ -1495,25 +1480,29 @@ fn publish_git_with_version() { ) .build(); - p.cargo("run").with_stdout("2").run(); + p.cargo("run") + .with_stdout_data(str![[r#" +2 + +"#]]) + .run(); p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[..] -[..] -[..] -[..] -[..] -[UPLOADING] foo v0.1.0 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.1.0 ([ROOT]/foo) +[UPDATING] crates.io index +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.1.0 ([ROOT]/foo) [UPLOADED] foo v0.1.0 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.1.0 [..] -", - ) +[NOTE] waiting for `foo v0.1.0` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.1.0 at registry `crates-io` + +"#]]) .run(); publish::validate_upload_with_contents( @@ -1636,18 +1625,17 @@ fn publish_dev_dep_no_version() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[UPDATING] [..] -[PACKAGING] foo v0.1.0 [..] -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.1.0 [..] -[UPLOADED] foo v0.1.0 [..] -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.1.0 [..] -", - ) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[PACKAGING] foo v0.1.0 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.1.0 ([ROOT]/foo) +[UPLOADED] foo v0.1.0 to registry `crates-io` +[NOTE] waiting for `foo v0.1.0` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.1.0 at registry `crates-io` + +"#]]) .run(); publish::validate_upload_with_contents( @@ -1806,19 +1794,18 @@ fn publish_with_feature_point_diff_kinds_dep() { p.cargo("publish --no-verify") .env("RUSTFLAGS", "--cfg unix") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[UPDATING] [..] -[PACKAGING] foo v0.1.0 [..] -[UPDATING] [..] -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.1.0 [..] -[UPLOADED] foo v0.1.0 [..] -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.1.0 [..] -", - ) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[PACKAGING] foo v0.1.0 ([ROOT]/foo) +[UPDATING] crates.io index +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.1.0 ([ROOT]/foo) +[UPLOADED] foo v0.1.0 to registry `crates-io` +[NOTE] waiting for `foo v0.1.0` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.1.0 at registry `crates-io` + +"#]]) .run(); publish::validate_upload_with_contents( @@ -2044,7 +2031,11 @@ fn credentials_ambiguous_filename() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr_contains("[..]Unauthorized message from server[..]") + .with_stderr_data(str![[r#" +... + Unauthorized message from server. + +"#]]) .run(); // Favor `credentials` if exists. @@ -2053,21 +2044,20 @@ fn credentials_ambiguous_filename() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[WARNING] both `[..]/credentials` and `[..]/credentials.toml` exist. Using `[..]/credentials` -[..] -[..] -[..] -[..] -[UPLOADING] foo v0.0.1 [..] -[UPLOADED] foo v0.0.1 [..] -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] both `[ROOT]/home/.cargo/credentials` and `[ROOT]/home/.cargo/credentials.toml` exist. Using `[ROOT]/home/.cargo/credentials` +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) +[UPLOADED] foo v0.0.1 to registry `crates-io` +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); } @@ -2100,11 +2090,10 @@ fn index_requires_token() { p.cargo("publish --no-verify --index") .arg(registry.index_url().as_str()) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] command-line argument --index requires --token to be specified -", - ) + +"#]]) .run(); } @@ -2130,12 +2119,11 @@ fn cratesio_source_replacement() { p.cargo("publish --no-verify") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] crates-io is replaced with remote registry dummy-registry; include `--registry dummy-registry` or `--registry crates-io` -", - ) + +"#]]) .run(); } @@ -2173,18 +2161,17 @@ fn api_error_json() { p.cargo("publish --no-verify --registry alternative") .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [ERROR] failed to publish to registry at http://127.0.0.1:[..]/ Caused by: the remote server responded with an error (status 403 Forbidden): you must be logged in -", - ) + +"#]]) .run(); } @@ -2222,18 +2209,17 @@ fn api_error_200() { p.cargo("publish --no-verify --registry alternative") .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [ERROR] failed to publish to registry at http://127.0.0.1:[..]/ Caused by: - the remote server responded with an error: max upload size is 123 -", - ) + the remote server responded with an [ERROR] max upload size is 123 + +"#]]) .run(); } @@ -2271,25 +2257,24 @@ fn api_error_code() { p.cargo("publish --no-verify --registry alternative") .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [ERROR] failed to publish to registry at http://127.0.0.1:[..]/ Caused by: failed to get a 200 OK response, got 400 headers: - HTTP/1.1 400 - Content-Length: 7 - Connection: close - + HTTP/1.1 400 + Content-Length: 7 + Connection: close + body: go away -", - ) + +"#]]) .run(); } @@ -2329,18 +2314,17 @@ fn api_curl_error() { // Server returned nothing (no headers, no data) (Empty reply from server) p.cargo("publish --no-verify --registry alternative") .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [ERROR] failed to publish to registry at http://127.0.0.1:[..]/ Caused by: - [52] [..] -", - ) + [52] Server returned nothing (no headers, no data) (Empty reply from server) + +"#]]) .run(); } @@ -2378,21 +2362,20 @@ fn api_other_error() { p.cargo("publish --no-verify --registry alternative") .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [ERROR] failed to publish to registry at http://127.0.0.1:[..]/ Caused by: invalid response body from server Caused by: - invalid utf-8 sequence of [..] -", - ) + invalid utf-8 sequence of 1 bytes from index 0 + +"#]]) .run(); } @@ -2430,20 +2413,19 @@ fn in_package_workspace() { p.cargo("publish -p li --no-verify") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [WARNING] manifest has no documentation, homepage or repository. -See [..] -[PACKAGING] li v0.0.1 ([CWD]/li) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] li v0.0.1 ([CWD]/li) +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] li v0.0.1 ([ROOT]/foo/li) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] li v0.0.1 ([ROOT]/foo/li) [UPLOADED] li v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] li v0.0.1 [..] -", - ) +[NOTE] waiting for `li v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] li v0.0.1 at registry `crates-io` + +"#]]) .run(); validate_upload_li(); @@ -2498,9 +2480,10 @@ fn with_duplicate_spec_in_members() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "error: the `-p` argument must be specified to select a single package to publish", - ) + .with_stderr_data(str![[r#" +[ERROR] the `-p` argument must be specified to select a single package to publish + +"#]]) .run(); } @@ -2538,20 +2521,19 @@ fn in_package_workspace_with_members_with_features_old() { p.cargo("publish -p li --no-verify") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [WARNING] manifest has no documentation, homepage or repository. -See [..] -[PACKAGING] li v0.0.1 ([CWD]/li) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] li v0.0.1 ([CWD]/li) +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] li v0.0.1 ([ROOT]/foo/li) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] li v0.0.1 ([ROOT]/foo/li) [UPLOADED] li v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] li v0.0.1 [..] -", - ) +[NOTE] waiting for `li v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] li v0.0.1 at registry `crates-io` + +"#]]) .run(); validate_upload_li(); @@ -2588,9 +2570,10 @@ fn in_virtual_workspace() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "error: the `-p` argument must be specified in the root of a virtual workspace", - ) + .with_stderr_data(str![[r#" +[ERROR] the `-p` argument must be specified in the root of a virtual workspace + +"#]]) .run(); } @@ -2637,20 +2620,19 @@ fn in_virtual_workspace_with_p() { p.cargo("publish -p li --no-verify") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [WARNING] manifest has no documentation, homepage or repository. -See [..] -[PACKAGING] li v0.0.1 ([CWD]/li) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] li v0.0.1 ([CWD]/li) +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] li v0.0.1 ([ROOT]/foo/li) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] li v0.0.1 ([ROOT]/foo/li) [UPLOADED] li v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] li v0.0.1 [..] -", - ) +[NOTE] waiting for `li v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] li v0.0.1 at registry `crates-io` + +"#]]) .run(); } @@ -2689,13 +2671,12 @@ fn in_package_workspace_not_found() { p.cargo("publish -p li --no-verify") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ -error: package ID specification `li` did not match any packages + .with_stderr_data(str![[r#" +[ERROR] package ID specification `li` did not match any packages -Did you mean `foo`? -", - ) + Did you mean `foo`? + +"#]]) .run(); } @@ -2748,11 +2729,10 @@ fn in_package_workspace_found_multiple() { p.cargo("publish -p li* --no-verify") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ -error: the `-p` argument must be specified to select a single package to publish -", - ) + .with_stderr_data(str![[r#" +[ERROR] the `-p` argument must be specified to select a single package to publish + +"#]]) .run(); } @@ -2793,13 +2773,12 @@ fn publish_path_dependency_without_workspace() { p.cargo("publish -p bar --no-verify") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ -error: package ID specification `bar` did not match any packages + .with_stderr_data(str![[r#" +[ERROR] package ID specification `bar` did not match any packages -Did you mean `foo`? -", - ) + Did you mean `foo`? + +"#]]) .run(); } @@ -2825,23 +2804,22 @@ fn http_api_not_noop() { p.cargo("publish") .replace_crates_io(registry.index_url()) - .with_stderr( - "\ -[..] -[..] -[..] -[..] -[PACKAGED] [..] -[VERIFYING] foo v0.0.1 ([CWD]) -[..] -[..] -[UPLOADING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.0.1 [..] -", - ) +[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.0.1 at registry `crates-io` + +"#]]) .run(); let p = project() @@ -2907,20 +2885,19 @@ fn wait_for_first_publish() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(0) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] delay v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] delay v0.0.1 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] delay v0.0.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] delay v0.0.1 ([ROOT]/foo) [UPLOADED] delay v0.0.1 to registry `crates-io` [NOTE] waiting for `delay v0.0.1` to be available at registry `crates-io`. You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] delay v0.0.1 at registry `crates-io` -", - ) + +"#]]) .run(); // Verify the responder has been pinged @@ -3001,20 +2978,19 @@ fn wait_for_first_publish_underscore() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(0) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] delay_with_underscore v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] delay_with_underscore v0.0.1 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] delay_with_underscore v0.0.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] delay_with_underscore v0.0.1 ([ROOT]/foo) [UPLOADED] delay_with_underscore v0.0.1 to registry `crates-io` [NOTE] waiting for `delay_with_underscore v0.0.1` to be available at registry `crates-io`. You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] delay_with_underscore v0.0.1 at registry `crates-io` -", - ) + +"#]]) .run(); // Verify the repsponder has been pinged @@ -3102,20 +3078,19 @@ fn wait_for_subsequent_publish() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(0) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] delay v0.0.2 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] delay v0.0.2 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] delay v0.0.2 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] delay v0.0.2 ([ROOT]/foo) [UPLOADED] delay v0.0.2 to registry `crates-io` [NOTE] waiting for `delay v0.0.2` to be available at registry `crates-io`. You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] delay v0.0.2 at registry `crates-io` -", - ) + +"#]]) .run(); // Verify the responder has been pinged @@ -3173,16 +3148,15 @@ fn skip_wait_for_publish() { p.cargo("publish --no-verify -Zpublish-timeout") .replace_crates_io(registry.index_url()) .masquerade_as_nightly_cargo(&["publish-timeout"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 ([CWD]) -", - ) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) + +"#]]) .run(); } @@ -3221,21 +3195,20 @@ fn timeout_waiting_for_publish() { .replace_crates_io(registry.index_url()) .masquerade_as_nightly_cargo(&["publish-timeout"]) .with_status(0) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] delay v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] delay v0.0.1 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] delay v0.0.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] delay v0.0.1 ([ROOT]/foo) [UPLOADED] delay v0.0.1 to registry `crates-io` [NOTE] waiting for `delay v0.0.1` to be available at registry `crates-io`. You may press ctrl-c to skip waiting; the crate should be available shortly. -warning: timed out waiting for `delay v0.0.1` to be available in registry `crates-io` +[WARNING] timed out waiting for `delay v0.0.1` to be available in registry `crates-io` [NOTE] the registry may have a backlog that is delaying making the crate available. The crate should be available soon. -", - ) + +"#]]) .run(); } @@ -3271,20 +3244,19 @@ fn wait_for_git_publish() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_status(0) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] delay v0.0.2 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] delay v0.0.2 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] delay v0.0.2 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] delay v0.0.2 ([ROOT]/foo) [UPLOADED] delay v0.0.2 to registry `crates-io` [NOTE] waiting for `delay v0.0.2` to be available at registry `crates-io`. You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] delay v0.0.2 at registry `crates-io` -", - ) + +"#]]) .run(); let p = project() @@ -3331,19 +3303,18 @@ fn invalid_token() { p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .env("CARGO_REGISTRY_TOKEN", "\x16") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index [PACKAGING] foo v0.0.1 ([ROOT]/foo) -[PACKAGED] 4 files, [..] +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) [UPLOADING] foo v0.0.1 ([ROOT]/foo) -error: failed to publish to registry at http://127.0.0.1:[..]/ +[ERROR] failed to publish to registry at http://127.0.0.1:[..]/ Caused by: token contains invalid characters. Only printable ISO-8859-1 characters are allowed as it is sent in a HTTPS header. -", - ) + +"#]]) .with_status(101) .run(); } @@ -3368,12 +3339,11 @@ fn versionless_package() { p.cargo("publish") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ -error: `foo` cannot be published. + .with_stderr_data(str![[r#" +[ERROR] `foo` cannot be published. `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish. -", - ) + +"#]]) .run(); } @@ -3410,20 +3380,19 @@ target-dep = { version = "0.1.0", optional = true } p.cargo("publish --no-verify") .masquerade_as_nightly_cargo(&["edition2024"]) .replace_crates_io(registry.index_url()) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[UPLOADING] foo v0.0.1 ([CWD]) +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.0.1 ([ROOT]/foo) [UPLOADED] foo v0.0.1 to registry `crates-io` [NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`. You may press ctrl-c to skip waiting; the crate should be available shortly. [PUBLISHED] foo v0.0.1 at registry `crates-io` -", - ) + +"#]]) .run(); validate_upload_foo(); diff --git a/tests/testsuite/publish_lockfile.rs b/tests/testsuite/publish_lockfile.rs index 408ba30d750..8bbfc798f7c 100644 --- a/tests/testsuite/publish_lockfile.rs +++ b/tests/testsuite/publish_lockfile.rs @@ -1,12 +1,11 @@ //! Tests for including `Cargo.lock` when publishing/packaging. -#![allow(deprecated)] - use std::fs::File; +use cargo_test_support::prelude::*; use cargo_test_support::registry::Package; use cargo_test_support::{ - basic_manifest, cargo_process, git, paths, project, publish::validate_crate_contents, + basic_manifest, cargo_process, git, paths, project, publish::validate_crate_contents, str, }; fn pl_manifest(name: &str, version: &str, extra: &str) -> String { @@ -53,17 +52,16 @@ fn removed() { p.cargo("package") .masquerade_as_nightly_cargo(&["publish-lockfile"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at [..] + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: the cargo feature `publish-lockfile` has been removed in the 1.37 release Remove the feature from Cargo.toml to remove this error. - See https://doc.rust-lang.org/[..]cargo/reference/unstable.html#publish-lockfile [..] -", - ) + See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#publish-lockfile for more information about using this feature. + +"#]]) .run(); } @@ -75,37 +73,34 @@ fn package_lockfile() { .build(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] [..] files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([CWD]) -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("package") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 [..] -[PACKAGED] 4 files, [..] -[VERIFYING] foo v0.0.1 [..] -[COMPILING] foo v0.0.1 [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -126,33 +121,31 @@ fn package_lockfile_git_repo() { .build(); cargo_process("package -l") .cwd(g.root()) - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); cargo_process("package -v") .cwd(g.root()) - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([..]) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [ARCHIVING] .cargo_vcs_info.json [ARCHIVING] Cargo.lock [ARCHIVING] Cargo.toml [ARCHIVING] Cargo.toml.orig [ARCHIVING] src/main.rs -[PACKAGED] 5 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([..]) -[COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -238,20 +231,19 @@ fn note_resolve_changes() { Package::new("updated", "1.0.1").publish(); p.cargo("package --no-verify -v --allow-dirty") - .with_stderr_unordered( - "\ -[PACKAGING] foo v0.0.1 ([..]) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [ARCHIVING] Cargo.lock +[UPDATING] `dummy-registry` index +[NOTE] package `multi v0.1.0` added to the packaged Cargo.lock file, was originally sourced from `[ROOT]/foo/multi` +[NOTE] package `patched v1.0.0` added to the packaged Cargo.lock file, was originally sourced from `[ROOT]/foo/patched` [ARCHIVING] Cargo.toml [ARCHIVING] Cargo.toml.orig [ARCHIVING] src/main.rs -[UPDATING] `[..]` index -[NOTE] package `multi v0.1.0` added to the packaged Cargo.lock file, was originally sourced from `[..]/foo/multi` -[NOTE] package `patched v1.0.0` added to the packaged Cargo.lock file, was originally sourced from `[..]/foo/patched` -[PACKAGED] [..] files, [..] ([..] compressed) -[WARNING] no (git) Cargo.toml found at `[..]/foo/Cargo.toml` in workdir `[..]` -", - ) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[WARNING] no (git) Cargo.toml found at `target/tmp/[..]/foo/Cargo.toml` in workdir `[..]` + +"#]].unordered()) .run(); } @@ -269,14 +261,13 @@ fn outdated_lock_version_change_does_not_warn() { p.change_file("Cargo.toml", &pl_manifest("foo", "0.2.0", "")); p.cargo("package --no-verify") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 1 package to latest compatible version -[UPDATING] foo v0.1.0 ([CWD]) -> v0.2.0 -[PACKAGING] foo v0.2.0 ([..]) -[PACKAGED] [..] files, [..] ([..] compressed) -", - ) +[UPDATING] foo v0.1.0 ([ROOT]/foo) -> v0.2.0 +[PACKAGING] foo v0.2.0 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); } @@ -322,13 +313,12 @@ fn no_warn_workspace_extras() { p.cargo("generate-lockfile").run(); p.cargo("package --no-verify") .cwd("a") - .with_stderr( - "\ -[PACKAGING] a v0.1.0 ([..]) -[UPDATING] `[..]` index -[PACKAGED] [..] files, [..] ([..] compressed) -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] a v0.1.0 ([ROOT]/foo/a) +[UPDATING] `dummy-registry` index +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); } @@ -354,15 +344,13 @@ fn warn_package_with_yanked() { // Make sure it sticks with the locked (yanked) version. Package::new("bar", "0.1.1").publish(); p.cargo("package --no-verify") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([..]) -[UPDATING] `[..]` index -[WARNING] package `bar v0.1.0` in Cargo.lock is yanked in registry \ - `crates-io`, consider updating to a version that is not yanked -[PACKAGED] [..] files, [..] ([..] compressed) -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[UPDATING] `dummy-registry` index +[WARNING] package `bar v0.1.0` in Cargo.lock is yanked in registry `crates-io`, consider updating to a version that is not yanked +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); } @@ -392,43 +380,40 @@ dependencies = [ .publish(); cargo_process("install --locked foo") - .with_stderr( - "\ -[UPDATING] `[..]` index + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index [DOWNLOADING] crates ... -[DOWNLOADED] foo v0.1.0 (registry `[..]`) +[DOWNLOADED] foo v0.1.0 (registry `dummy-registry`) [INSTALLING] foo v0.1.0 -[WARNING] package `bar v0.1.0` in Cargo.lock is yanked in registry \ - `crates-io`, consider running without --locked +[WARNING] package `bar v0.1.0` in Cargo.lock is yanked in registry `crates-io`, consider running without --locked [DOWNLOADING] crates ... -[DOWNLOADED] bar v0.1.0 (registry `[..]`) +[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`) [COMPILING] bar v0.1.0 [COMPILING] foo v0.1.0 -[FINISHED] `release` profile [optimized] target(s) in [..] -[INSTALLING] [..]/.cargo/bin/foo[EXE] +[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s +[INSTALLING] [ROOT]/home/.cargo/bin/foo[EXE] [INSTALLED] package `foo v0.1.0` (executable `foo[EXE]`) -[WARNING] be sure to add [..] -", - ) +[WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries + +"#]]) .run(); // Try again without --locked, make sure it uses 0.1.1 and does not warn. cargo_process("install --force foo") - .with_stderr( - "\ -[UPDATING] `[..]` index + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index [INSTALLING] foo v0.1.0 [LOCKING] 2 packages to latest compatible versions [DOWNLOADING] crates ... -[DOWNLOADED] bar v0.1.1 (registry `[..]`) +[DOWNLOADED] bar v0.1.1 (registry `dummy-registry`) [COMPILING] bar v0.1.1 [COMPILING] foo v0.1.0 -[FINISHED] `release` profile [optimized] target(s) in [..] -[REPLACING] [..]/.cargo/bin/foo[EXE] +[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s +[REPLACING] [ROOT]/home/.cargo/bin/foo[EXE] [REPLACED] package `foo v0.1.0` with `foo v0.1.0` (executable `foo[EXE]`) -[WARNING] be sure to add [..] -", - ) +[WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries + +"#]]) .run(); } @@ -454,33 +439,31 @@ fn ignore_lockfile() { .file(".gitignore", "Cargo.lock") }); p.cargo("package -l") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.lock Cargo.toml Cargo.toml.orig src/main.rs -", - ) + +"#]]) .run(); p.cargo("generate-lockfile").run(); p.cargo("package -v") - .with_stderr( - "\ -[PACKAGING] foo v0.0.1 ([..]) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.1 ([ROOT]/foo) [ARCHIVING] .cargo_vcs_info.json [ARCHIVING] Cargo.lock [ARCHIVING] Cargo.toml [ARCHIVING] Cargo.toml.orig [ARCHIVING] src/main.rs -[PACKAGED] 5 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.1 ([..]) -[COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[PACKAGED] 5 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -496,18 +479,17 @@ fn ignore_lockfile_inner() { p.cargo("generate-lockfile").cwd("bar").run(); p.cargo("package -v --no-verify") .cwd("bar") - .with_stderr( - "\ -[PACKAGING] bar v0.0.1 ([..]) + .with_stderr_data(str![[r#" +[PACKAGING] bar v0.0.1 ([ROOT]/foo/bar) [ARCHIVING] .cargo_vcs_info.json [ARCHIVING] .gitignore [ARCHIVING] Cargo.lock [ARCHIVING] Cargo.toml [ARCHIVING] Cargo.toml.orig [ARCHIVING] src/main.rs -[PACKAGED] 6 files, [..] ([..] compressed) -", - ) +[PACKAGED] 6 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) + +"#]]) .run(); } @@ -565,29 +547,28 @@ fn use_workspace_root_lockfile() { // Expect: package `bar` uses `serde v0.2.0` as required by workspace `Cargo.lock`. p.cargo("package --workspace") - .with_stderr( - "\ -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] bar v0.0.1 ([CWD]/bar) + .with_stderr_data(str![[r#" +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] bar v0.0.1 ([ROOT]/foo/bar) [UPDATING] `dummy-registry` index -[PACKAGED] 4 files, [..] -[VERIFYING] bar v0.0.1 ([CWD]/bar) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] bar v0.0.1 ([ROOT]/foo/bar) [DOWNLOADING] crates ... -[DOWNLOADED] serde v0.2.0 ([..]) +[DOWNLOADED] serde v0.2.0 (registry `dummy-registry`) [COMPILING] serde v0.2.0 -[COMPILING] bar v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[PACKAGED] 4 files, [..] -[VERIFYING] foo v0.0.1 ([CWD]) +[COMPILING] bar v0.0.1 ([ROOT]/foo/target/package/bar-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[WARNING] manifest has no documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. +[PACKAGING] foo v0.0.1 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.1 ([ROOT]/foo) [COMPILING] serde v0.2.0 -[COMPILING] foo v0.0.1 ([CWD][..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let package_path = p.root().join("target/package/foo-0.0.1.crate");