Skip to content

Commit 262ab4e

Browse files
committed
refactor(tests): Hack publish to balance testing/wait_for_publish
1 parent 51c9f80 commit 262ab4e

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
@@ -100,6 +100,7 @@ fn validate_upload_foo_clean() {
100100

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

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

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

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

702713
let p = project().build();
@@ -720,6 +731,16 @@ fn publish_allowed_registry() {
720731
.file("src/main.rs", "fn main() {}")
721732
.build();
722733

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

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

752774
let p = project().build();
@@ -770,6 +792,16 @@ fn publish_implicitly_to_only_allowed_registry() {
770792
.file("src/main.rs", "fn main() {}")
771793
.build();
772794

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

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

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

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

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

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

13711426
let p = project()
@@ -1391,6 +1446,15 @@ fn publish_dev_dep_no_version() {
13911446
.file("bar/src/lib.rs", "")
13921447
.build();
13931448

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

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

18501915
let p = project()
@@ -1873,6 +1938,13 @@ fn in_package_workspace() {
18731938
.file("li/src/main.rs", "fn main() {}")
18741939
.build();
18751940

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

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

19482021
let p = project()
@@ -1970,6 +2043,13 @@ fn in_package_workspace_with_members_with_features_old() {
19702043
.file("li/src/main.rs", "fn main() {}")
19712044
.build();
19722045

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