Skip to content

Commit 8e2a760

Browse files
committed
refactor(tests): Hack publish to balance testing/wait_for_publish
1 parent 82dfa04 commit 8e2a760

File tree

5 files changed

+135
-1
lines changed

5 files changed

+135
-1
lines changed

tests/testsuite/artifact_dep.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,9 @@ fn env_vars_and_build_products_for_various_build_targets() {
18721872

18731873
#[cargo_test]
18741874
fn publish_artifact_dep() {
1875+
// HACK below allows us to use a local registry
18751876
let registry = registry::init();
1877+
18761878
Package::new("bar", "1.0.0").publish();
18771879
Package::new("baz", "1.0.0").publish();
18781880

@@ -1901,6 +1903,15 @@ fn publish_artifact_dep() {
19011903
.file("src/lib.rs", "")
19021904
.build();
19031905

1906+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
1907+
// the index.
1908+
//
1909+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
1910+
// the registry from processing the publish.
1911+
Package::new("foo", "0.1.0")
1912+
.file("src/lib.rs", "")
1913+
.publish();
1914+
19041915
p.cargo("publish -Z bindeps --no-verify")
19051916
.replace_crates_io(registry.index_url())
19061917
.masquerade_as_nightly_cargo(&["bindeps"])

tests/testsuite/credential_process.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Tests for credential-process.
22
3-
use cargo_test_support::registry::TestRegistry;
3+
use cargo_test_support::registry::{Package, TestRegistry};
44
use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, Project};
55
use std::fs;
66

@@ -94,6 +94,16 @@ fn warn_both_token_and_process() {
9494
.file("src/lib.rs", "")
9595
.build();
9696

97+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
98+
// the index.
99+
//
100+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
101+
// the registry from processing the publish.
102+
Package::new("foo", "0.1.0")
103+
.file("src/lib.rs", "")
104+
.alternative(true)
105+
.publish();
106+
97107
p.cargo("publish --no-verify --registry alternative -Z credential-process")
98108
.masquerade_as_nightly_cargo(&["credential-process"])
99109
.with_status(101)

tests/testsuite/features_namespaced.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,9 @@ bar v1.0.0
858858

859859
#[cargo_test]
860860
fn publish_no_implicit() {
861+
// HACK below allows us to use a local registry
861862
let registry = registry::init();
863+
862864
// Does not include implicit features or dep: syntax on publish.
863865
Package::new("opt-dep1", "1.0.0").publish();
864866
Package::new("opt-dep2", "1.0.0").publish();
@@ -885,6 +887,15 @@ fn publish_no_implicit() {
885887
.file("src/lib.rs", "")
886888
.build();
887889

890+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
891+
// the index.
892+
//
893+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
894+
// the registry from processing the publish.
895+
Package::new("foo", "0.1.0")
896+
.file("src/lib.rs", "")
897+
.publish();
898+
888899
p.cargo("publish --no-verify")
889900
.replace_crates_io(registry.index_url())
890901
.with_stderr(
@@ -971,7 +982,9 @@ feat = ["opt-dep1"]
971982

972983
#[cargo_test]
973984
fn publish() {
985+
// HACK below allows us to use a local registry
974986
let registry = registry::init();
987+
975988
// Publish behavior with explicit dep: syntax.
976989
Package::new("bar", "1.0.0").publish();
977990
let p = project()
@@ -997,6 +1010,15 @@ fn publish() {
9971010
.file("src/lib.rs", "")
9981011
.build();
9991012

1013+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
1014+
// the index.
1015+
//
1016+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
1017+
// the registry from processing the publish.
1018+
Package::new("foo", "0.1.0")
1019+
.file("src/lib.rs", "")
1020+
.publish();
1021+
10001022
p.cargo("publish")
10011023
.replace_crates_io(registry.index_url())
10021024
.with_stderr(

tests/testsuite/publish.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ fn validate_upload_foo_clean() {
101101

102102
#[cargo_test]
103103
fn simple() {
104+
// HACK below allows us to use a local registry
104105
let registry = registry::init();
105106

106107
let p = project()
@@ -118,6 +119,15 @@ fn simple() {
118119
.file("src/main.rs", "fn main() {}")
119120
.build();
120121

122+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
123+
// the index.
124+
//
125+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
126+
// the registry from processing the publish.
127+
Package::new("foo", "0.0.1")
128+
.file("src/lib.rs", "")
129+
.publish();
130+
121131
p.cargo("publish --no-verify")
122132
.replace_crates_io(registry.index_url())
123133
.with_stderr(
@@ -698,6 +708,7 @@ The registry `alternative` is not listed in the `publish` value in Cargo.toml.
698708

699709
#[cargo_test]
700710
fn publish_allowed_registry() {
711+
// HACK below allows us to use a local registry
701712
registry::alt_init();
702713

703714
let p = project().build();
@@ -721,6 +732,16 @@ fn publish_allowed_registry() {
721732
.file("src/main.rs", "fn main() {}")
722733
.build();
723734

735+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
736+
// the index.
737+
//
738+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
739+
// the registry from processing the publish.
740+
Package::new("foo", "0.0.1")
741+
.file("src/lib.rs", "")
742+
.alternative(true)
743+
.publish();
744+
724745
p.cargo("publish --registry alternative")
725746
.with_stderr(
726747
"\
@@ -748,6 +769,7 @@ fn publish_allowed_registry() {
748769

749770
#[cargo_test]
750771
fn publish_implicitly_to_only_allowed_registry() {
772+
// HACK below allows us to use a local registry
751773
registry::alt_init();
752774

753775
let p = project().build();
@@ -771,6 +793,16 @@ fn publish_implicitly_to_only_allowed_registry() {
771793
.file("src/main.rs", "fn main() {}")
772794
.build();
773795

796+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
797+
// the index.
798+
//
799+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
800+
// the registry from processing the publish.
801+
Package::new("foo", "0.0.1")
802+
.file("src/lib.rs", "")
803+
.alternative(true)
804+
.publish();
805+
774806
p.cargo("publish")
775807
.with_stderr(
776808
"\
@@ -1035,6 +1067,7 @@ fn publish_with_no_default_features() {
10351067

10361068
#[cargo_test]
10371069
fn publish_with_patch() {
1070+
// HACK below allows us to use a local registry
10381071
let registry = registry::init();
10391072
Package::new("bar", "1.0.0").publish();
10401073

@@ -1078,6 +1111,15 @@ fn publish_with_patch() {
10781111
// Remove the usage of new functionality and try again.
10791112
p.change_file("src/main.rs", "extern crate bar; pub fn main() {}");
10801113

1114+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
1115+
// the index.
1116+
//
1117+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
1118+
// the registry from processing the publish.
1119+
Package::new("foo", "0.0.1")
1120+
.file("src/lib.rs", "")
1121+
.publish();
1122+
10811123
p.cargo("publish")
10821124
.replace_crates_io(registry.index_url())
10831125
.with_stderr(
@@ -1233,7 +1275,9 @@ include `--registry crates-io` to use crates.io
12331275
// A dependency with both `git` and `version`.
12341276
#[cargo_test]
12351277
fn publish_git_with_version() {
1278+
// HACK below allows us to use a local registry
12361279
let registry = registry::init();
1280+
12371281
Package::new("dep1", "1.0.1")
12381282
.file("src/lib.rs", "pub fn f() -> i32 {1}")
12391283
.publish();
@@ -1274,6 +1318,16 @@ fn publish_git_with_version() {
12741318
.build();
12751319

12761320
p.cargo("run").with_stdout("2").run();
1321+
1322+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
1323+
// the index.
1324+
//
1325+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
1326+
// the registry from processing the publish.
1327+
Package::new("foo", "0.1.0")
1328+
.file("src/lib.rs", "")
1329+
.publish();
1330+
12771331
p.cargo("publish --no-verify")
12781332
.replace_crates_io(registry.index_url())
12791333
.with_stderr(
@@ -1367,6 +1421,7 @@ fn publish_git_with_version() {
13671421

13681422
#[cargo_test]
13691423
fn publish_dev_dep_no_version() {
1424+
// HACK below allows us to use a local registry
13701425
let registry = registry::init();
13711426

13721427
let p = project()
@@ -1392,6 +1447,15 @@ fn publish_dev_dep_no_version() {
13921447
.file("bar/src/lib.rs", "")
13931448
.build();
13941449

1450+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
1451+
// the index.
1452+
//
1453+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
1454+
// the registry from processing the publish.
1455+
Package::new("foo", "0.1.0")
1456+
.file("src/lib.rs", "")
1457+
.publish();
1458+
13951459
p.cargo("publish --no-verify")
13961460
.replace_crates_io(registry.index_url())
13971461
.with_stderr(
@@ -1846,6 +1910,7 @@ Caused by:
18461910

18471911
#[cargo_test]
18481912
fn in_package_workspace() {
1913+
// HACK below allows us to use a local registry
18491914
let registry = registry::init();
18501915

18511916
let p = project()
@@ -1874,6 +1939,13 @@ fn in_package_workspace() {
18741939
.file("li/src/main.rs", "fn main() {}")
18751940
.build();
18761941

1942+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
1943+
// the index.
1944+
//
1945+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
1946+
// the registry from processing the publish.
1947+
Package::new("li", "0.0.1").file("src/lib.rs", "").publish();
1948+
18771949
p.cargo("publish -p li --no-verify")
18781950
.replace_crates_io(registry.index_url())
18791951
.with_stderr(
@@ -1944,6 +2016,7 @@ fn with_duplicate_spec_in_members() {
19442016

19452017
#[cargo_test]
19462018
fn in_package_workspace_with_members_with_features_old() {
2019+
// HACK below allows us to use a local registry
19472020
let registry = registry::init();
19482021

19492022
let p = project()
@@ -1971,6 +2044,13 @@ fn in_package_workspace_with_members_with_features_old() {
19712044
.file("li/src/main.rs", "fn main() {}")
19722045
.build();
19732046

2047+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
2048+
// the index.
2049+
//
2050+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
2051+
// the registry from processing the publish.
2052+
Package::new("li", "0.0.1").file("src/lib.rs", "").publish();
2053+
19742054
p.cargo("publish -p li --no-verify")
19752055
.replace_crates_io(registry.index_url())
19762056
.with_stderr(

tests/testsuite/weak_dep_features.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,9 @@ bar v1.0.0
523523

524524
#[cargo_test]
525525
fn publish() {
526+
// HACK below allows us to use a local registry
526527
let registry = registry::init();
528+
527529
// Publish behavior with /? syntax.
528530
Package::new("bar", "1.0.0").feature("feat", &[]).publish();
529531
let p = project()
@@ -548,6 +550,15 @@ fn publish() {
548550
.file("src/lib.rs", "")
549551
.build();
550552

553+
// HACK: Inject `foo` directly into the index so `publish` won't block for it to be in
554+
// the index.
555+
//
556+
// This is to ensure we can verify the Summary we post to the registry as doing so precludes
557+
// the registry from processing the publish.
558+
Package::new("foo", "0.1.0")
559+
.file("src/lib.rs", "")
560+
.publish();
561+
551562
p.cargo("publish")
552563
.replace_crates_io(registry.index_url())
553564
.with_stderr(

0 commit comments

Comments
 (0)