Skip to content

Commit

Permalink
Update tests to use registry names
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Jul 21, 2021
1 parent 4efaa4e commit 8c75e2f
Show file tree
Hide file tree
Showing 18 changed files with 211 additions and 221 deletions.
6 changes: 3 additions & 3 deletions src/cargo/core/package_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,15 @@ mod tests {
let loc = CRATES_IO_INDEX.into_url().unwrap();
let pkg_id = PackageId::new("foo", "1.0.0", SourceId::for_registry(&loc).unwrap()).unwrap();
assert_eq!(
r#"PackageId { name: "foo", version: "1.0.0", source: "registry `https://github.com/rust-lang/crates.io-index`" }"#,
r#"PackageId { name: "foo", version: "1.0.0", source: "registry `crates-io`" }"#,
format!("{:?}", pkg_id)
);

let expected = r#"
PackageId {
name: "foo",
version: "1.0.0",
source: "registry `https://github.com/rust-lang/crates.io-index`",
source: "registry `crates-io`",
}
"#
.trim();
Expand All @@ -271,7 +271,7 @@ PackageId {
PackageId {
name: "foo",
version: "1.0.0",
source: "registry `https://github.com/rust-lang/crates.io-index`"
source: "registry `crates-io`"
}
"#
.trim();
Expand Down
115 changes: 52 additions & 63 deletions tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ fn depend_on_alt_registry() {
Package::new("bar", "0.0.1").alternative(true).publish();

p.cargo("build")
.with_stderr(&format!(
.with_stderr(
"\
[UPDATING] `{reg}` index
[UPDATING] `alternative` index
[DOWNLOADING] crates ...
[DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
[COMPILING] bar v0.0.1 (registry `alternative`)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
reg = registry::alt_registry_path().to_str().unwrap()
))
)
.run();

p.cargo("clean").run();
Expand All @@ -48,7 +47,7 @@ fn depend_on_alt_registry() {
p.cargo("build")
.with_stderr(
"\
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1 (registry `alternative`)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
Expand Down Expand Up @@ -83,19 +82,18 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() {
.publish();

p.cargo("build")
.with_stderr(&format!(
.with_stderr(
"\
[UPDATING] `{reg}` index
[UPDATING] `alternative` index
[DOWNLOADING] crates ...
[DOWNLOADED] [..] v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] baz v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
[COMPILING] baz v0.0.1 (registry `alternative`)
[COMPILING] bar v0.0.1 (registry `alternative`)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
reg = registry::alt_registry_path().to_str().unwrap()
))
)
.run();
}

Expand Down Expand Up @@ -126,19 +124,18 @@ fn depend_on_alt_registry_depends_on_same_registry() {
.publish();

p.cargo("build")
.with_stderr(&format!(
.with_stderr(
"\
[UPDATING] `{reg}` index
[UPDATING] `alternative` index
[DOWNLOADING] crates ...
[DOWNLOADED] [..] v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] baz v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
[COMPILING] baz v0.0.1 (registry `alternative`)
[COMPILING] bar v0.0.1 (registry `alternative`)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
reg = registry::alt_registry_path().to_str().unwrap()
))
)
.run();
}

Expand Down Expand Up @@ -169,21 +166,19 @@ fn depend_on_alt_registry_depends_on_crates_io() {
.publish();

p.cargo("build")
.with_stderr_unordered(&format!(
.with_stderr_unordered(
"\
[UPDATING] `{alt_reg}` index
[UPDATING] `{reg}` index
[UPDATING] `alternative` index
[UPDATING] `dummy-registry` index
[DOWNLOADING] crates ...
[DOWNLOADED] baz v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] baz v0.0.1 (registry `dummy-registry`)
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
[COMPILING] baz v0.0.1
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1 (registry `alternative`)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
alt_reg = registry::alt_registry_path().to_str().unwrap(),
reg = registry::registry_path().to_str().unwrap()
))
)
.run();
}

Expand Down Expand Up @@ -403,20 +398,19 @@ fn alt_registry_and_crates_io_deps() {
.publish();

p.cargo("build")
.with_stderr_contains(format!(
"[UPDATING] `{}` index",
registry::alt_registry_path().to_str().unwrap()
))
.with_stderr_contains(&format!(
"[UPDATING] `{}` index",
registry::registry_path().to_str().unwrap()
))
.with_stderr_contains("[DOWNLOADED] crates_io_dep v0.0.1 (registry `[ROOT][..]`)")
.with_stderr_contains("[DOWNLOADED] alt_reg_dep v0.1.0 (registry `[ROOT][..]`)")
.with_stderr_contains("[COMPILING] alt_reg_dep v0.1.0 (registry `[ROOT][..]`)")
.with_stderr_contains("[COMPILING] crates_io_dep v0.0.1")
.with_stderr_contains("[COMPILING] foo v0.0.1 ([CWD])")
.with_stderr_contains("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s")
.with_stderr_unordered(
"\
[UPDATING] `alternative` index
[UPDATING] `dummy-registry` index
[DOWNLOADING] crates ...
[DOWNLOADED] crates_io_dep v0.0.1 (registry `dummy-registry`)
[DOWNLOADED] alt_reg_dep v0.1.0 (registry `alternative`)
[COMPILING] alt_reg_dep v0.1.0 (registry `alternative`)
[COMPILING] crates_io_dep v0.0.1
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
)
.run();
}

Expand Down Expand Up @@ -607,7 +601,7 @@ fn patch_alt_reg() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] `[ROOT][..]` index
[UPDATING] `alternative` index
[COMPILING] bar v0.1.0 ([CWD]/bar)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
Expand Down Expand Up @@ -697,24 +691,20 @@ fn no_api() {
.build();

p.cargo("build")
.with_stderr(&format!(
.with_stderr(
"\
[UPDATING] `{reg}` index
[UPDATING] `alternative` index
[DOWNLOADING] crates ...
[DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
[COMPILING] bar v0.0.1 (registry `alternative`)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
reg = registry::alt_registry_path().to_str().unwrap()
))
)
.run();

// Check all of the API commands.
let err = format!(
"[ERROR] registry `{}` does not support API commands",
registry::alt_registry_path().display()
);
let err = "[ERROR] registry `alternative` does not support API commands";

p.cargo("login --registry alternative TOKEN")
.with_status(101)
Expand Down Expand Up @@ -1244,17 +1234,16 @@ fn registries_index_relative_url() {
Package::new("bar", "0.0.1").alternative(true).publish();

p.cargo("build")
.with_stderr(&format!(
.with_stderr(
"\
[UPDATING] `{reg}` index
[UPDATING] `relative` index
[DOWNLOADING] crates ...
[DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADED] bar v0.0.1 (registry `relative`)
[COMPILING] bar v0.0.1 (registry `relative`)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
reg = registry::alt_registry_path().to_str().unwrap()
))
)
.run();
}

Expand Down
8 changes: 4 additions & 4 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ Caused by:
failed to load source for dependency `bar`
Caused by:
Unable to update registry `https://[..]`
Unable to update registry `crates-io`
Caused by:
could not find a configured source with the name `bar` \
Expand Down Expand Up @@ -958,7 +958,7 @@ Caused by:
failed to load source for dependency `bar`
Caused by:
Unable to update registry `https://[..]`
Unable to update registry `crates-io`
Caused by:
detected a cycle of `replace-with` sources, [..]
Expand Down Expand Up @@ -1006,7 +1006,7 @@ Caused by:
failed to load source for dependency `bar`
Caused by:
Unable to update registry `https://[..]`
Unable to update registry `crates-io`
Caused by:
detected a cycle of `replace-with` sources, the source `crates-io` is \
Expand Down Expand Up @@ -1445,7 +1445,7 @@ fn redefined_sources() {
.with_status(101)
.with_stderr(
"\
[ERROR] source `foo` defines source registry `https://github.com/rust-lang/crates.io-index`, \
[ERROR] source `foo` defines source registry `crates-io`, \
but that source is already defined by `crates-io`
note: Sources are not allowed to be defined multiple times.
",
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4777,7 +4777,7 @@ fn avoid_dev_deps() {
"\
[UPDATING] [..]
[ERROR] no matching package named `baz` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
location searched: registry `crates-io`
required by package `bar v0.1.0 ([..]/foo)`
",
)
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn feature_required_dependency() {
[UPDATING] [..]
[DOWNLOADING] [..]
[DOWNLOADED] bar v1.0.0 [..]
error: failed to download replaced source registry `https://github.com/rust-lang/crates.io-index`
error: failed to download replaced source registry `crates-io`
Caused by:
failed to parse manifest at `[..]/bar-1.0.0/Cargo.toml`
Expand Down Expand Up @@ -136,7 +136,7 @@ Caused by:
unable to get packages from source
Caused by:
failed to download replaced source registry `https://github.com/rust-lang/crates.io-index`
failed to download replaced source registry `crates-io`
Caused by:
failed to parse manifest at `[..]/bar-1.0.0/Cargo.toml`
Expand Down
28 changes: 14 additions & 14 deletions tests/testsuite/cross_publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ fn simple_cross_package() {
if cross_compile::disabled() {
return;
}

let p = project()
.file(
"Cargo.toml",
Expand Down Expand Up @@ -42,10 +41,11 @@ fn simple_cross_package() {
p.cargo("package --target")
.arg(&target)
.with_stderr(
" Packaging foo v0.0.0 ([CWD])
Verifying foo v0.0.0 ([CWD])
Compiling foo v0.0.0 ([CWD]/target/package/foo-0.0.0)
Finished dev [unoptimized + debuginfo] target(s) in [..]
"\
[PACKAGING] foo v0.0.0 ([CWD])
[VERIFYING] foo v0.0.0 ([CWD])
[COMPILING] foo v0.0.0 ([CWD]/target/package/foo-0.0.0)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
Expand Down Expand Up @@ -100,15 +100,15 @@ fn publish_with_target() {
p.cargo("publish --token sekrit")
.arg("--target")
.arg(&target)
.with_stderr(&format!(
" Updating `{registry}` index
Packaging foo v0.0.0 ([CWD])
Verifying foo v0.0.0 ([CWD])
Compiling foo v0.0.0 ([CWD]/target/package/foo-0.0.0)
Finished dev [unoptimized + debuginfo] target(s) in [..]
Uploading foo v0.0.0 ([CWD])
.with_stderr(
"\
[UPDATING] `dummy-registry` index
[PACKAGING] foo v0.0.0 ([CWD])
[VERIFYING] foo v0.0.0 ([CWD])
[COMPILING] foo v0.0.0 ([CWD]/target/package/foo-0.0.0)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[UPLOADING] foo v0.0.0 ([CWD])
",
registry = registry::registry_path().to_str().unwrap()
))
)
.run();
}
2 changes: 1 addition & 1 deletion tests/testsuite/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Caused by:
no matching package found
searched package name: `baz`
perhaps you meant: bar or foo
location searched: registry `https://github.com/rust-lang/crates.io-index`
location searched: registry `crates-io`
required by package `bar v0.1.0`
",
)
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/features_namespaced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn dependency_gate_ignored() {
"\
[UPDATING] [..]
[ERROR] no matching package named `bar` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
location searched: registry `crates-io`
required by package `foo v0.1.0 ([..]/foo)`
",
)
Expand Down
Loading

0 comments on commit 8c75e2f

Please sign in to comment.