Skip to content

Commit 41cf907

Browse files
authored
test(publish): Improvements in prep for -Zpackage-workspace stabilization (#15628)
### What does this PR try to resolve? Attempting to reduce the size of the stabilization PR so the stabilization changes are more obvious, without pulling something out that is meaningless. ### How to test and review this PR?
2 parents 8a9d8bd + 0d391bd commit 41cf907

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

tests/testsuite/publish.rs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,8 +2522,7 @@ You may press ctrl-c to skip waiting; the crate should be available shortly.
25222522

25232523
#[cargo_test]
25242524
fn with_duplicate_spec_in_members() {
2525-
// Use local registry for faster test times since no publish will occur
2526-
let registry = registry::init();
2525+
let registry = RegistryBuilder::new().http_api().http_index().build();
25272526

25282527
let p = project()
25292528
.file(
@@ -2630,8 +2629,7 @@ You may press ctrl-c to skip waiting; the crate should be available shortly.
26302629

26312630
#[cargo_test]
26322631
fn in_virtual_workspace() {
2633-
// Use local registry for faster test times since no publish will occur
2634-
let registry = registry::init();
2632+
let registry = RegistryBuilder::new().http_api().http_index().build();
26352633

26362634
let p = project()
26372635
.file(
@@ -2668,8 +2666,7 @@ fn in_virtual_workspace() {
26682666

26692667
#[cargo_test]
26702668
fn in_virtual_workspace_with_p() {
2671-
// `publish` generally requires a remote registry
2672-
let registry = registry::RegistryBuilder::new().http_api().build();
2669+
let registry = RegistryBuilder::new().http_api().http_index().build();
26732670

26742671
let p = project()
26752672
.file(
@@ -2771,8 +2768,7 @@ fn in_package_workspace_not_found() {
27712768

27722769
#[cargo_test]
27732770
fn in_package_workspace_found_multiple() {
2774-
// Use local registry for faster test times since no publish will occur
2775-
let registry = registry::init();
2771+
let registry = RegistryBuilder::new().http_api().http_index().build();
27762772

27772773
let p = project()
27782774
.file(
@@ -2828,8 +2824,7 @@ fn in_package_workspace_found_multiple() {
28282824
#[cargo_test]
28292825
// https://github.com/rust-lang/cargo/issues/10536
28302826
fn publish_path_dependency_without_workspace() {
2831-
// Use local registry for faster test times since no publish will occur
2832-
let registry = registry::init();
2827+
let registry = RegistryBuilder::new().http_api().http_index().build();
28332828

28342829
let p = project()
28352830
.file(
@@ -3403,7 +3398,7 @@ You may press ctrl-c to skip waiting; the crate should be available shortly.
34033398
}
34043399

34053400
#[cargo_test]
3406-
fn package_selection() {
3401+
fn package_selection_nightly() {
34073402
let registry = registry::RegistryBuilder::new().http_api().build();
34083403
let p = project()
34093404
.file(
@@ -3478,26 +3473,44 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
34783473
"#]])
34793474
.with_stdout_data(str![[r#""#]])
34803475
.run();
3476+
}
34813477

3482-
p.cargo("publish --no-verify --dry-run --package a --package b")
3478+
#[cargo_test]
3479+
fn package_selection() {
3480+
let registry = registry::RegistryBuilder::new().http_api().build();
3481+
let p = project()
3482+
.file(
3483+
"Cargo.toml",
3484+
r#"
3485+
[workspace]
3486+
members = ["a", "b"]
3487+
"#,
3488+
)
3489+
.file("a/Cargo.toml", &basic_manifest("a", "0.1.0"))
3490+
.file("a/src/lib.rs", "#[test] fn a() {}")
3491+
.file("b/Cargo.toml", &basic_manifest("b", "0.1.0"))
3492+
.file("b/src/lib.rs", "#[test] fn b() {}")
3493+
.build();
3494+
3495+
p.cargo("publish --no-verify --dry-run --workspace")
34833496
.replace_crates_io(registry.index_url())
34843497
.with_status(101)
34853498
.with_stderr_data(str![[r#"
3486-
[ERROR] the `--package (multiple occurrences)` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
3499+
[ERROR] the `--workspace` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
34873500
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
3488-
See https://github.com/rust-lang/cargo/issues/10948 for more information about the `--package (multiple occurrences)` flag.
3501+
See https://github.com/rust-lang/cargo/issues/10948 for more information about the `--workspace` flag.
34893502
34903503
"#]])
34913504
.with_stdout_data(str![[r#""#]])
34923505
.run();
34933506

3494-
p.cargo("publish --no-verify --dry-run --workspace")
3507+
p.cargo("publish --no-verify --dry-run --package a --package b")
34953508
.replace_crates_io(registry.index_url())
34963509
.with_status(101)
34973510
.with_stderr_data(str![[r#"
3498-
[ERROR] the `--workspace` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
3511+
[ERROR] the `--package (multiple occurrences)` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
34993512
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
3500-
See https://github.com/rust-lang/cargo/issues/10948 for more information about the `--workspace` flag.
3513+
See https://github.com/rust-lang/cargo/issues/10948 for more information about the `--package (multiple occurrences)` flag.
35013514
35023515
"#]])
35033516
.with_stdout_data(str![[r#""#]])

0 commit comments

Comments
 (0)