diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index f012e26932e..76f2c1b07fa 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -1,8 +1,7 @@ //! Tests for alternative registries. -#![allow(deprecated)] - use cargo_test_support::compare::assert_e2e; +use cargo_test_support::prelude::*; use cargo_test_support::publish::validate_alt_upload; use cargo_test_support::registry::{self, Package, RegistryBuilder}; use cargo_test_support::str; @@ -33,30 +32,28 @@ fn depend_on_alt_registry() { Package::new("bar", "0.0.1").alternative(true).publish(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index [LOCKING] 2 packages to latest compatible versions [DOWNLOADING] crates ... [DOWNLOADED] bar v0.0.1 (registry `alternative`) [CHECKING] bar v0.0.1 (registry `alternative`) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("clean").run(); // Don't download a second time p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [CHECKING] bar v0.0.1 (registry `alternative`) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -88,19 +85,18 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() { .publish(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index [LOCKING] 3 packages to latest compatible versions [DOWNLOADING] crates ... -[DOWNLOADED] [..] v0.0.1 (registry `alternative`) -[DOWNLOADED] [..] v0.0.1 (registry `alternative`) +[DOWNLOADED] baz v0.0.1 (registry `alternative`) +[DOWNLOADED] bar v0.0.1 (registry `alternative`) [CHECKING] baz v0.0.1 (registry `alternative`) [CHECKING] bar v0.0.1 (registry `alternative`) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -132,19 +128,18 @@ fn depend_on_alt_registry_depends_on_same_registry() { .publish(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index [LOCKING] 3 packages to latest compatible versions [DOWNLOADING] crates ... -[DOWNLOADED] [..] v0.0.1 (registry `alternative`) -[DOWNLOADED] [..] v0.0.1 (registry `alternative`) +[DOWNLOADED] baz v0.0.1 (registry `alternative`) +[DOWNLOADED] bar v0.0.1 (registry `alternative`) [CHECKING] baz v0.0.1 (registry `alternative`) [CHECKING] bar v0.0.1 (registry `alternative`) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -176,8 +171,8 @@ fn depend_on_alt_registry_depends_on_crates_io() { .publish(); p.cargo("check") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [UPDATING] `alternative` index [UPDATING] `dummy-registry` index [LOCKING] 3 packages to latest compatible versions @@ -186,9 +181,11 @@ fn depend_on_alt_registry_depends_on_crates_io() { [DOWNLOADED] bar v0.0.1 (registry `alternative`) [CHECKING] baz v0.0.1 [CHECKING] bar v0.0.1 (registry `alternative`) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -218,14 +215,13 @@ fn registry_and_path_dep_works() { .build(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[CHECKING] bar v0.0.1 ([CWD]/bar) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[CHECKING] bar v0.0.1 ([ROOT]/foo/bar) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -253,10 +249,13 @@ fn registry_incompatible_with_git() { p.cargo("check") .with_status(101) - .with_stderr_contains( - " dependency (bar) specification is ambiguous. \ - Only one of `git` or `registry` is allowed.", - ) + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` + +Caused by: + dependency (bar) specification is ambiguous. Only one of `git` or `registry` is allowed. + +"#]]) .run(); } @@ -286,7 +285,13 @@ fn cannot_publish_to_crates_io_with_registry_dependency() { p.cargo("publish") .replace_crates_io(crates_io.index_url()) .with_status(101) - .with_stderr_contains("[ERROR] crates cannot be published to crates.io[..]") + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[ERROR] crates cannot be published to crates.io with dependencies sourced from other +registries. `bar` needs to be published to crates.io before publishing this crate. +(crate `bar` is pulled from registry `alternative`) + +"#]]) .run(); p.cargo("publish") @@ -296,7 +301,13 @@ fn cannot_publish_to_crates_io_with_registry_dependency() { .arg("--index") .arg(crates_io.index_url().as_str()) .with_status(101) - .with_stderr_contains("[ERROR] crates cannot be published to crates.io[..]") + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[ERROR] crates cannot be published to crates.io with dependencies sourced from other +registries. `bar` needs to be published to crates.io before publishing this crate. +(crate `bar` is pulled from registry `alternative`) + +"#]]) .run(); } @@ -329,27 +340,26 @@ fn publish_with_registry_dependency() { Package::new("bar", "0.0.1").alternative(true).publish(); p.cargo("publish --registry alternative") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index -[WARNING] [..] -[..] -[PACKAGING] foo v0.0.1 [..] +[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) [UPDATING] `alternative` index -[VERIFYING] foo v0.0.1 [..] -[DOWNLOADING] [..] +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[DOWNLOADING] crates ... [DOWNLOADED] bar v0.0.1 (registry `alternative`) [COMPILING] bar v0.0.1 (registry `alternative`) -[COMPILING] foo v0.0.1 [..] -[FINISHED] [..] -[PACKAGED] [..] -[UPLOADING] foo v0.0.1 [..] +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[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 to skip waiting; the crate should be available shortly. [PUBLISHED] foo v0.0.1 at registry `alternative` -", - ) + +"#]]) .run(); validate_alt_upload( @@ -420,19 +430,21 @@ fn alt_registry_and_crates_io_deps() { .publish(); p.cargo("check") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [UPDATING] `alternative` index [UPDATING] `dummy-registry` index [LOCKING] 3 packages to latest compatible versions [DOWNLOADING] crates ... [DOWNLOADED] crates_io_dep v0.0.1 (registry `dummy-registry`) [DOWNLOADED] alt_reg_dep v0.1.0 (registry `alternative`) -[CHECKING] alt_reg_dep v0.1.0 (registry `alternative`) [CHECKING] crates_io_dep v0.0.1 -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", +[CHECKING] alt_reg_dep v0.1.0 (registry `alternative`) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -447,12 +459,12 @@ fn block_publish_due_to_no_token() { // Now perform the actual publish p.cargo("publish --registry alternative") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index -error: no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", - ) +[ERROR] no token found for `alternative`, please run `cargo login --registry alternative` +or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN + +"#]]) .run(); } @@ -474,12 +486,12 @@ fn cargo_registries_crates_io_protocol() { p.cargo("publish --registry alternative") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index -error: no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", - ) +[ERROR] no token found for `alternative`, please run `cargo login --registry alternative` +or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN + +"#]]) .run(); } @@ -495,23 +507,22 @@ fn publish_to_alt_registry() { // Now perform the actual publish p.cargo("publish --registry alternative") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index -[WARNING] [..] -[..] -[PACKAGING] foo v0.0.1 [..] -[VERIFYING] foo v0.0.1 [..] -[COMPILING] foo v0.0.1 [..] -[FINISHED] [..] -[PACKAGED] [..] -[UPLOADING] foo v0.0.1 [..] +[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) +[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 +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[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 to skip waiting; the crate should be available shortly. [PUBLISHED] foo v0.0.1 at registry `alternative` -", - ) + +"#]]) .run(); validate_alt_upload( @@ -574,27 +585,26 @@ fn publish_with_crates_io_dep() { Package::new("bar", "0.0.1").publish(); p.cargo("publish --registry alternative") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index -[WARNING] [..] -[..] -[PACKAGING] foo v0.0.1 [..] +[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] `dummy-registry` index -[VERIFYING] foo v0.0.1 [..] -[DOWNLOADING] [..] +[VERIFYING] foo v0.0.1 ([ROOT]/foo) +[DOWNLOADING] crates ... [DOWNLOADED] bar v0.0.1 (registry `dummy-registry`) [COMPILING] bar v0.0.1 -[COMPILING] foo v0.0.1 [..] -[FINISHED] [..] -[PACKAGED] [..] -[UPLOADING] foo v0.0.1 [..] +[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[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 to skip waiting; the crate should be available shortly. [PUBLISHED] foo v0.0.1 at registry `alternative` -", - ) + +"#]]) .run(); validate_alt_upload( @@ -655,14 +665,13 @@ fn passwords_in_registries_index_url_forbidden() { p.cargo("publish --registry alternative") .with_status(101) - .with_stderr( - "\ -error: invalid index URL for registry `alternative` defined in [..]/home/.cargo/config.toml + .with_stderr_data(str![[r#" +[ERROR] invalid index URL for registry `alternative` defined in [ROOT]/home/.cargo/config.toml Caused by: registry URLs may not contain passwords -", - ) + +"#]]) .run(); } @@ -698,15 +707,14 @@ fn patch_alt_reg() { .build(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index [LOCKING] 2 packages to latest compatible versions -[CHECKING] bar v0.1.0 ([CWD]/bar) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[CHECKING] bar v0.1.0 ([ROOT]/foo/bar) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -732,8 +740,7 @@ fn bad_registry_name() { p.cargo("build") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] invalid character ` ` in registry name: `bad name`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters) @@ -741,12 +748,12 @@ fn bad_registry_name() { | 8 | [dependencies.bar] | _________________^ - 9 | | version = \"0.0.1\" -10 | | registry = \"bad name\" + 9 | | version = "0.0.1" +10 | | registry = "bad name" | |_____________________________________^ | -", - ) + +"#]]) .run(); for cmd in &[ @@ -762,7 +769,10 @@ fn bad_registry_name() { .arg("--registry") .arg("bad name") .with_status(101) - .with_stderr("[ERROR] invalid character ` ` in registry name: `bad name`, [..]") + .with_stderr_data(str![[r#" +[ERROR] invalid character ` ` in registry name: `bad name`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters) + +"#]]) .run(); } } @@ -791,50 +801,68 @@ fn no_api() { .build(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index [LOCKING] 2 packages to latest compatible versions [DOWNLOADING] crates ... [DOWNLOADED] bar v0.0.1 (registry `alternative`) [CHECKING] bar v0.0.1 (registry `alternative`) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) - .run(); +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s - // Check all of the API commands. - let err = "[ERROR] registry `alternative` does not support API commands"; +"#]]) + .run(); p.cargo("login --registry alternative TOKEN") .with_status(101) - .with_stderr_contains(&err) + .with_stderr_data(str![[r#" +[ERROR] registry `alternative` does not support API commands + +"#]]) .run(); p.cargo("publish --registry alternative") .with_status(101) - .with_stderr_contains(&err) + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[ERROR] registry `alternative` does not support API commands + +"#]]) .run(); p.cargo("search --registry alternative") .with_status(101) - .with_stderr_contains(&err) + .with_stderr_data(str![[r#" +[ERROR] registry `alternative` does not support API commands + +"#]]) .run(); p.cargo("owner --registry alternative --list") .with_status(101) - .with_stderr_contains(&err) + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[ERROR] registry `alternative` does not support API commands + +"#]]) .run(); p.cargo("yank --registry alternative --version=0.0.1 bar") .with_status(101) - .with_stderr_contains(&err) + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[ERROR] registry `alternative` does not support API commands + +"#]]) .run(); p.cargo("yank --registry alternative --version=0.0.1 bar") - .with_stderr_contains(&err) .with_status(101) + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index +[ERROR] registry `alternative` does not support API commands + +"#]]) .run(); } @@ -876,277 +904,455 @@ fn alt_reg_metadata() { // altdep -> bar: null (because it is in crates.io) // iodep -> altdep2: alternative-registry p.cargo("metadata --format-version=1 --no-deps") - .with_json( - r#" - { - "packages": [ - { - "name": "foo", - "version": "0.0.1", - "id": "path+file:[..]/foo#0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": null, - "dependencies": [ - { - "name": "altdep", - "source": "registry+file:[..]/alternative-registry", - "req": "^0.0.1", - "kind": null, - "rename": null, - "optional": false, - "uses_default_features": true, - "features": [], - "target": null, - "registry": "file:[..]/alternative-registry" - }, - { - "name": "iodep", - "source": "registry+https://github.com/rust-lang/crates.io-index", - "req": "^0.0.1", - "kind": null, - "rename": null, - "optional": false, - "uses_default_features": true, - "features": [], - "target": null, - "registry": null - } - ], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]/foo/Cargo.toml", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - } - ], - "workspace_members": [ - "path+file:[..]/foo#0.0.1" - ], - "workspace_default_members": [ - "path+file:[..]/foo#0.0.1" - ], - "resolve": null, - "target_directory": "[..]/foo/target", - "version": 1, - "workspace_root": "[..]/foo", - "metadata": null - }"#, + .with_stdout_data( + str![[r#" +{ + "metadata": null, + "packages": [ + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [ + { + "features": [], + "kind": null, + "name": "altdep", + "optional": false, + "registry": "[ROOTURL]/alternative-registry", + "rename": null, + "req": "^0.0.1", + "source": "registry+[ROOTURL]/alternative-registry", + "target": null, + "uses_default_features": true + }, + { + "features": [], + "kind": null, + "name": "iodep", + "optional": false, + "registry": null, + "rename": null, + "req": "^0.0.1", + "source": "registry+https://github.com/rust-lang/crates.io-index", + "target": null, + "uses_default_features": true + } + ], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "path+[ROOTURL]/foo#0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/foo/Cargo.toml", + "metadata": null, + "name": "foo", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": null, + "targets": [ + { + "crate_types": [ + "lib" + ], + "doc": true, + "doctest": true, + "edition": "2015", + "kind": [ + "lib" + ], + "name": "foo", + "src_path": "[ROOT]/foo/src/lib.rs", + "test": true + } + ], + "version": "0.0.1" + } + ], + "resolve": null, + "target_directory": "[ROOT]/foo/target", + "version": 1, + "workspace_default_members": [ + "path+[ROOTURL]/foo#0.0.1" + ], + "workspace_members": [ + "path+[ROOTURL]/foo#0.0.1" + ], + "workspace_root": "[ROOT]/foo" +} +"#]] + .json(), ) .run(); // --no-deps uses a different code path, make sure both work. p.cargo("metadata --format-version=1") - .with_json( - r#" - { - "packages": [ - { - "name": "altdep", - "version": "0.0.1", - "id": "registry+file:[..]/alternative-registry#altdep@0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": "registry+file:[..]/alternative-registry", - "dependencies": [ - { - "name": "bar", - "source": "registry+https://github.com/rust-lang/crates.io-index", - "req": "^0.0.1", - "kind": null, - "rename": null, - "optional": false, - "uses_default_features": true, - "features": [], - "target": null, - "registry": null - } - ], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]/altdep-0.0.1/Cargo.toml", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - }, - { - "name": "altdep2", - "version": "0.0.1", - "id": "registry+file:[..]/alternative-registry#altdep2@0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": "registry+file:[..]/alternative-registry", - "dependencies": [], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]/altdep2-0.0.1/Cargo.toml", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - }, - { - "name": "bar", - "version": "0.0.1", - "id": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": "registry+https://github.com/rust-lang/crates.io-index", - "dependencies": [], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]/bar-0.0.1/Cargo.toml", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - }, - { - "name": "foo", - "version": "0.0.1", - "id": "path+file:[..]/foo#0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": null, - "dependencies": [ - { - "name": "altdep", - "source": "registry+file:[..]/alternative-registry", - "req": "^0.0.1", - "kind": null, - "rename": null, - "optional": false, - "uses_default_features": true, - "features": [], - "target": null, - "registry": "file:[..]/alternative-registry" - }, - { - "name": "iodep", - "source": "registry+https://github.com/rust-lang/crates.io-index", - "req": "^0.0.1", - "kind": null, - "rename": null, - "optional": false, - "uses_default_features": true, - "features": [], - "target": null, - "registry": null - } - ], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]/foo/Cargo.toml", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - }, - { - "name": "iodep", - "version": "0.0.1", - "id": "registry+https://github.com/rust-lang/crates.io-index#iodep@0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": "registry+https://github.com/rust-lang/crates.io-index", - "dependencies": [ - { - "name": "altdep2", - "source": "registry+file:[..]/alternative-registry", - "req": "^0.0.1", - "kind": null, - "rename": null, - "optional": false, - "uses_default_features": true, - "features": [], - "target": null, - "registry": "file:[..]/alternative-registry" - } - ], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]/iodep-0.0.1/Cargo.toml", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - } - ], - "workspace_members": [ - "path+file:[..]/foo#0.0.1" - ], - "workspace_default_members": [ - "path+file:[..]/foo#0.0.1" - ], - "resolve": "{...}", - "target_directory": "[..]/foo/target", - "version": 1, - "workspace_root": "[..]/foo", - "metadata": null - }"#, + .with_stdout_data( + str![[r#" +{ + "metadata": null, + "packages": [ + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [ + { + "features": [], + "kind": null, + "name": "bar", + "optional": false, + "registry": null, + "rename": null, + "req": "^0.0.1", + "source": "registry+https://github.com/rust-lang/crates.io-index", + "target": null, + "uses_default_features": true + } + ], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "registry+[ROOTURL]/alternative-registry#altdep@0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/altdep-0.0.1/Cargo.toml", + "metadata": null, + "name": "altdep", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": "registry+[ROOTURL]/alternative-registry", + "targets": [ + { + "crate_types": [ + "lib" + ], + "doc": true, + "doctest": true, + "edition": "2015", + "kind": [ + "lib" + ], + "name": "altdep", + "src_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/altdep-0.0.1/src/lib.rs", + "test": true + } + ], + "version": "0.0.1" + }, + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "registry+[ROOTURL]/alternative-registry#altdep2@0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/altdep2-0.0.1/Cargo.toml", + "metadata": null, + "name": "altdep2", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": "registry+[ROOTURL]/alternative-registry", + "targets": [ + { + "crate_types": [ + "lib" + ], + "doc": true, + "doctest": true, + "edition": "2015", + "kind": [ + "lib" + ], + "name": "altdep2", + "src_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/altdep2-0.0.1/src/lib.rs", + "test": true + } + ], + "version": "0.0.1" + }, + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/bar-0.0.1/Cargo.toml", + "metadata": null, + "name": "bar", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": "registry+https://github.com/rust-lang/crates.io-index", + "targets": [ + { + "crate_types": [ + "lib" + ], + "doc": true, + "doctest": true, + "edition": "2015", + "kind": [ + "lib" + ], + "name": "bar", + "src_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/bar-0.0.1/src/lib.rs", + "test": true + } + ], + "version": "0.0.1" + }, + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [ + { + "features": [], + "kind": null, + "name": "altdep", + "optional": false, + "registry": "[ROOTURL]/alternative-registry", + "rename": null, + "req": "^0.0.1", + "source": "registry+[ROOTURL]/alternative-registry", + "target": null, + "uses_default_features": true + }, + { + "features": [], + "kind": null, + "name": "iodep", + "optional": false, + "registry": null, + "rename": null, + "req": "^0.0.1", + "source": "registry+https://github.com/rust-lang/crates.io-index", + "target": null, + "uses_default_features": true + } + ], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "path+[ROOTURL]/foo#0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/foo/Cargo.toml", + "metadata": null, + "name": "foo", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": null, + "targets": [ + { + "crate_types": [ + "lib" + ], + "doc": true, + "doctest": true, + "edition": "2015", + "kind": [ + "lib" + ], + "name": "foo", + "src_path": "[ROOT]/foo/src/lib.rs", + "test": true + } + ], + "version": "0.0.1" + }, + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [ + { + "features": [], + "kind": null, + "name": "altdep2", + "optional": false, + "registry": "[ROOTURL]/alternative-registry", + "rename": null, + "req": "^0.0.1", + "source": "registry+[ROOTURL]/alternative-registry", + "target": null, + "uses_default_features": true + } + ], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "registry+https://github.com/rust-lang/crates.io-index#iodep@0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/iodep-0.0.1/Cargo.toml", + "metadata": null, + "name": "iodep", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": "registry+https://github.com/rust-lang/crates.io-index", + "targets": [ + { + "crate_types": [ + "lib" + ], + "doc": true, + "doctest": true, + "edition": "2015", + "kind": [ + "lib" + ], + "name": "iodep", + "src_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/iodep-0.0.1/src/lib.rs", + "test": true + } + ], + "version": "0.0.1" + } + ], + "resolve": { + "nodes": [ + { + "dependencies": [ + "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1" + ], + "deps": [ + { + "dep_kinds": [ + { + "kind": null, + "target": null + } + ], + "name": "bar", + "pkg": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1" + } + ], + "features": [], + "id": "registry+[ROOTURL]/alternative-registry#altdep@0.0.1" + }, + { + "dependencies": [], + "deps": [], + "features": [], + "id": "registry+[ROOTURL]/alternative-registry#altdep2@0.0.1" + }, + { + "dependencies": [], + "deps": [], + "features": [], + "id": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1" + }, + { + "dependencies": [ + "registry+[ROOTURL]/alternative-registry#altdep@0.0.1", + "registry+https://github.com/rust-lang/crates.io-index#iodep@0.0.1" + ], + "deps": [ + { + "dep_kinds": [ + { + "kind": null, + "target": null + } + ], + "name": "altdep", + "pkg": "registry+[ROOTURL]/alternative-registry#altdep@0.0.1" + }, + { + "dep_kinds": [ + { + "kind": null, + "target": null + } + ], + "name": "iodep", + "pkg": "registry+https://github.com/rust-lang/crates.io-index#iodep@0.0.1" + } + ], + "features": [], + "id": "path+[ROOTURL]/foo#0.0.1" + }, + { + "dependencies": [ + "registry+[ROOTURL]/alternative-registry#altdep2@0.0.1" + ], + "deps": [ + { + "dep_kinds": [ + { + "kind": null, + "target": null + } + ], + "name": "altdep2", + "pkg": "registry+[ROOTURL]/alternative-registry#altdep2@0.0.1" + } + ], + "features": [], + "id": "registry+https://github.com/rust-lang/crates.io-index#iodep@0.0.1" + } + ], + "root": "path+[ROOTURL]/foo#0.0.1" + }, + "target_directory": "[ROOT]/foo/target", + "version": 1, + "workspace_default_members": [ + "path+[ROOTURL]/foo#0.0.1" + ], + "workspace_members": [ + "path+[ROOTURL]/foo#0.0.1" + ], + "workspace_root": "[ROOT]/foo" +} +"#]] + .json(), ) .run(); } @@ -1193,128 +1399,222 @@ fn unknown_registry() { // foo -> bar registry = null // bar -> baz registry = alternate p.cargo("metadata --format-version=1") - .with_json( - r#" - { - "packages": [ - { - "name": "bar", - "version": "0.0.1", - "id": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": "registry+https://github.com/rust-lang/crates.io-index", - "dependencies": [ - { - "name": "baz", - "source": "registry+file://[..]/alternative-registry", - "req": "^0.0.1", - "kind": null, - "rename": null, - "optional": false, - "uses_default_features": true, - "features": [], - "target": null, - "registry": "file:[..]/alternative-registry" - } - ], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - }, - { - "name": "baz", - "version": "0.0.1", - "id": "registry+file://[..]/alternative-registry#baz@0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": "registry+file://[..]/alternative-registry", - "dependencies": [], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - }, - { - "name": "foo", - "version": "0.0.1", - "id": "path+file://[..]/foo#0.0.1", - "license": null, - "license_file": null, - "description": null, - "source": null, - "dependencies": [ - { - "name": "bar", - "source": "registry+https://github.com/rust-lang/crates.io-index", - "req": "^0.0.1", - "kind": null, - "rename": null, - "optional": false, - "uses_default_features": true, - "features": [], - "target": null, - "registry": null - } - ], - "targets": "{...}", - "features": {}, - "manifest_path": "[..]/foo/Cargo.toml", - "metadata": null, - "publish": null, - "authors": [], - "categories": [], - "default_run": null, - "keywords": [], - "readme": null, - "repository": null, - "rust_version": null, - "homepage": null, - "documentation": null, - "edition": "2015", - "links": null - } - ], - "workspace_members": [ - "path+file://[..]/foo#0.0.1" - ], - "workspace_default_members": [ - "path+file://[..]/foo#0.0.1" - ], - "resolve": "{...}", - "target_directory": "[..]/foo/target", - "version": 1, - "workspace_root": "[..]/foo", - "metadata": null - } - "#, + .with_stdout_data( + str![[r#" +{ + "metadata": null, + "packages": [ + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [ + { + "features": [], + "kind": null, + "name": "baz", + "optional": false, + "registry": "[ROOTURL]/alternative-registry", + "rename": null, + "req": "^0.0.1", + "source": "registry+[ROOTURL]/alternative-registry", + "target": null, + "uses_default_features": true + } + ], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/bar-0.0.1/Cargo.toml", + "metadata": null, + "name": "bar", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": "registry+https://github.com/rust-lang/crates.io-index", + "targets": [ + { + "crate_types": [ + "lib" + ], + "doc": true, + "doctest": true, + "edition": "2015", + "kind": [ + "lib" + ], + "name": "bar", + "src_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/bar-0.0.1/src/lib.rs", + "test": true + } + ], + "version": "0.0.1" + }, + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "registry+[ROOTURL]/alternative-registry#baz@0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/baz-0.0.1/Cargo.toml", + "metadata": null, + "name": "baz", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": "registry+[ROOTURL]/alternative-registry", + "targets": [ + { + "crate_types": [ + "lib" + ], + "doc": true, + "doctest": true, + "edition": "2015", + "kind": [ + "lib" + ], + "name": "baz", + "src_path": "[ROOT]/home/.cargo/registry/src/-[HASH]/baz-0.0.1/src/lib.rs", + "test": true + } + ], + "version": "0.0.1" + }, + { + "authors": [], + "categories": [], + "default_run": null, + "dependencies": [ + { + "features": [], + "kind": null, + "name": "bar", + "optional": false, + "registry": null, + "rename": null, + "req": "^0.0.1", + "source": "registry+https://github.com/rust-lang/crates.io-index", + "target": null, + "uses_default_features": true + } + ], + "description": null, + "documentation": null, + "edition": "2015", + "features": {}, + "homepage": null, + "id": "path+[ROOTURL]/foo#0.0.1", + "keywords": [], + "license": null, + "license_file": null, + "links": null, + "manifest_path": "[ROOT]/foo/Cargo.toml", + "metadata": null, + "name": "foo", + "publish": null, + "readme": null, + "repository": null, + "rust_version": null, + "source": null, + "targets": [ + { + "crate_types": [ + "bin" + ], + "doc": true, + "doctest": false, + "edition": "2015", + "kind": [ + "bin" + ], + "name": "foo", + "src_path": "[ROOT]/foo/src/main.rs", + "test": true + } + ], + "version": "0.0.1" + } + ], + "resolve": { + "nodes": [ + { + "dependencies": [ + "registry+[ROOTURL]/alternative-registry#baz@0.0.1" + ], + "deps": [ + { + "dep_kinds": [ + { + "kind": null, + "target": null + } + ], + "name": "baz", + "pkg": "registry+[ROOTURL]/alternative-registry#baz@0.0.1" + } + ], + "features": [], + "id": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1" + }, + { + "dependencies": [], + "deps": [], + "features": [], + "id": "registry+[ROOTURL]/alternative-registry#baz@0.0.1" + }, + { + "dependencies": [ + "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1" + ], + "deps": [ + { + "dep_kinds": [ + { + "kind": null, + "target": null + } + ], + "name": "bar", + "pkg": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1" + } + ], + "features": [], + "id": "path+[ROOTURL]/foo#0.0.1" + } + ], + "root": "path+[ROOTURL]/foo#0.0.1" + }, + "target_directory": "[ROOT]/foo/target", + "version": 1, + "workspace_default_members": [ + "path+[ROOTURL]/foo#0.0.1" + ], + "workspace_members": [ + "path+[ROOTURL]/foo#0.0.1" + ], + "workspace_root": "[ROOT]/foo" +} +"#]] + .json(), ) .run(); } @@ -1354,17 +1654,16 @@ fn registries_index_relative_url() { Package::new("bar", "0.0.1").alternative(true).publish(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `relative` index [LOCKING] 2 packages to latest compatible versions [DOWNLOADING] crates ... [DOWNLOADED] bar v0.0.1 (registry `relative`) [CHECKING] bar v0.0.1 (registry `relative`) -[CHECKING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1403,18 +1702,16 @@ fn registries_index_relative_path_not_allowed() { Package::new("bar", "0.0.1").alternative(true).publish(); p.cargo("check") - .with_stderr(&format!( - "\ -error: failed to parse manifest at `{root}/foo/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: - invalid index URL for registry `relative` defined in [..]/.cargo/config.toml + invalid index URL for registry `relative` defined in [ROOT]/.cargo/config.toml Caused by: invalid url `alternative-registry`: relative URL without a base -", - root = paths::root().to_str().unwrap() - )) + +"#]]) .with_status(101) .run(); } @@ -1427,9 +1724,14 @@ fn both_index_and_registry() { .arg("--registry=foo") .arg("--index=foo") .with_status(1) - .with_stderr_contains( - "error: the argument '--registry ' cannot be used with '--index '", - ) + .with_stderr_data(str![[r#" +[ERROR] the argument '--registry ' cannot be used with '--index ' + +Usage: [..] + +For more information, try '--help'. + +"#]]) .run(); } } @@ -1448,7 +1750,10 @@ fn both_index_and_default() { .env("CARGO_REGISTRY_DEFAULT", "undefined") .arg(format!("--index=index_url")) .with_status(101) - .with_stderr("[ERROR] invalid url `index_url`: relative URL without a base") + .with_stderr_data(str![[r#" +[ERROR] invalid url `index_url`: relative URL without a base + +"#]]) .run(); } } @@ -1569,13 +1874,13 @@ fn warn_for_unused_fields() { p.cargo("publish --registry alternative") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index -[WARNING] unused config key `registries.alternative.unexpected-field` in `[..]config.toml` +[WARNING] unused config key `registries.alternative.unexpected-field` in `[ROOT]/foo/.cargo/config.toml` [ERROR] no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", - ) +or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN + +"#]]) .run(); let crates_io = registry::RegistryBuilder::new() @@ -1584,13 +1889,13 @@ or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", p.cargo("publish --registry crates-io") .replace_crates_io(crates_io.index_url()) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[WARNING] unused config key `registry.unexpected-field` in `[..]config.toml` +[WARNING] unused config key `registry.unexpected-field` in `[ROOT]/foo/.cargo/config.toml` [ERROR] no token found, please run `cargo login` -or use environment variable CARGO_REGISTRY_TOKEN", - ) +or use environment variable CARGO_REGISTRY_TOKEN + +"#]]) .run(); } @@ -1613,10 +1918,10 @@ fn config_empty_registry_name() { .arg("--registry") .arg("") .with_status(101) - .with_stderr( - "\ -[ERROR] registry name cannot be empty", - ) + .with_stderr_data(str![[r#" +[ERROR] registry name cannot be empty + +"#]]) .run(); } @@ -1628,10 +1933,10 @@ fn empty_registry_flag() { .arg("--registry") .arg("") .with_status(101) - .with_stderr( - "\ -[ERROR] registry name cannot be empty", - ) + .with_stderr_data(str![[r#" +[ERROR] registry name cannot be empty + +"#]]) .run(); } @@ -1661,17 +1966,16 @@ fn empty_dependency_registry() { p.cargo("check") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] registry name cannot be empty --> Cargo.toml:8:23 | -8 | bar = { version = \"0.1.0\", registry = \"\" } +8 | bar = { version = "0.1.0", registry = "" } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -", - ) + +"#]]) .run(); }