Skip to content

Commit 2b4a5f1

Browse files
committed
Auto merge of #6544 - ehuss:test-publish-patch, r=alexcrichton
Add test for publish with [patch] + cleanup. This adds a test for publishing with a `[patch]` dependency. There is also a bunch of refactoring/cleanup to make that work better. Previously there were no tests for publishing with a dependency! A rough summary of the changes: - Remove all the duplicate code from `support::publish`, consolidate everything in `support::registry`. - Move API tokens into `.cargo/credentials` so it's easier to remove them in tests. - Rename `registry`/`alt_registry` to `registry_url`/`alt_registry_url` to be consistent with all the other function names and to avoid ambiguity. - Separate the default 'dl' and 'api' directories. Not really important, but is more consistent with the alt registry layout.
2 parents afef1f0 + b5144c7 commit 2b4a5f1

File tree

10 files changed

+179
-163
lines changed

10 files changed

+179
-163
lines changed

tests/testsuite/alt_registry.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ fn block_publish_due_to_no_token() {
467467
// Setup the registry by publishing a package
468468
Package::new("bar", "0.0.1").alternative(true).publish();
469469

470+
fs::remove_file(paths::home().join(".cargo/credentials")).unwrap();
471+
470472
// Now perform the actual publish
471473
p.cargo("publish --registry alternative -Zunstable-options")
472474
.masquerade_as_nightly_cargo()

tests/testsuite/cargo_features.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::support::{project, publish};
1+
use crate::support::{project, registry};
22

33
#[test]
44
fn feature_required() {
@@ -295,7 +295,7 @@ fn z_flags_rejected() {
295295

296296
#[test]
297297
fn publish_allowed() {
298-
publish::setup();
298+
registry::init();
299299

300300
let p = project()
301301
.file(
@@ -312,7 +312,7 @@ fn publish_allowed() {
312312
.file("src/lib.rs", "")
313313
.build();
314314
p.cargo("publish --index")
315-
.arg(publish::registry().to_string())
315+
.arg(registry::registry_url().to_string())
316316
.masquerade_as_nightly_cargo()
317317
.run();
318318
}

tests/testsuite/cross_publish.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fs::File;
22

3-
use crate::support::{cross_compile, project, publish};
3+
use crate::support::{cross_compile, project, publish, registry};
44

55
#[test]
66
fn simple_cross_package() {
@@ -64,7 +64,7 @@ fn publish_with_target() {
6464
return;
6565
}
6666

67-
publish::setup();
67+
registry::init();
6868

6969
let p = project()
7070
.file(
@@ -96,7 +96,7 @@ fn publish_with_target() {
9696
let target = cross_compile::alternate();
9797

9898
p.cargo("publish --index")
99-
.arg(publish::registry().to_string())
99+
.arg(registry::registry_url().to_string())
100100
.arg("--target")
101101
.arg(&target)
102102
.with_stderr(&format!(
@@ -107,7 +107,7 @@ fn publish_with_target() {
107107
Finished dev [unoptimized + debuginfo] target(s) in [..]
108108
Uploading foo v0.0.0 ([CWD])
109109
",
110-
registry = publish::registry_path().to_str().unwrap()
110+
registry = registry::registry_path().to_str().unwrap()
111111
))
112112
.run();
113113
}

tests/testsuite/login.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::io::prelude::*;
33

44
use crate::support::cargo_process;
55
use crate::support::install::cargo_home;
6-
use crate::support::registry::{self, registry};
6+
use crate::support::registry::{self, registry_url};
77
use cargo::core::Shell;
88
use cargo::util::config::Config;
99
use toml;
@@ -62,7 +62,7 @@ fn login_with_old_credentials() {
6262
registry::init();
6363

6464
cargo_process("login --host")
65-
.arg(registry().to_string())
65+
.arg(registry_url().to_string())
6666
.arg(TOKEN)
6767
.run();
6868

@@ -76,7 +76,7 @@ fn login_with_new_credentials() {
7676
setup_new_credentials();
7777

7878
cargo_process("login --host")
79-
.arg(registry().to_string())
79+
.arg(registry_url().to_string())
8080
.arg(TOKEN)
8181
.run();
8282

@@ -94,7 +94,7 @@ fn login_with_old_and_new_credentials() {
9494
fn login_without_credentials() {
9595
registry::init();
9696
cargo_process("login --host")
97-
.arg(registry().to_string())
97+
.arg(registry_url().to_string())
9898
.arg(TOKEN)
9999
.run();
100100

@@ -108,7 +108,7 @@ fn new_credentials_is_used_instead_old() {
108108
setup_new_credentials();
109109

110110
cargo_process("login --host")
111-
.arg(registry().to_string())
111+
.arg(registry_url().to_string())
112112
.arg(TOKEN)
113113
.run();
114114

tests/testsuite/package.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ registry-index = "{}"
839839
[dependencies.ghi]
840840
version = "1.0"
841841
"#,
842-
registry::alt_registry()
842+
registry::alt_registry_url()
843843
);
844844

845845
validate_crate_contents(

0 commit comments

Comments
 (0)