2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for the `cargo publish` command.
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::git::{self, repo};
|
|
|
|
use cargo_test_support::paths;
|
2023-02-19 05:26:59 +00:00
|
|
|
use cargo_test_support::registry::{self, Package, RegistryBuilder, Response};
|
2020-06-11 21:55:33 +00:00
|
|
|
use cargo_test_support::{basic_manifest, no_such_file_err_msg, project, publish};
|
2020-04-17 04:10:11 +00:00
|
|
|
use std::fs;
|
2022-09-08 15:40:40 +00:00
|
|
|
use std::sync::{Arc, Mutex};
|
2018-12-30 04:46:15 +00:00
|
|
|
|
|
|
|
const CLEAN_FOO_JSON: &str = r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [],
|
|
|
|
"description": "foo",
|
|
|
|
"documentation": "foo",
|
|
|
|
"features": {},
|
|
|
|
"homepage": "foo",
|
|
|
|
"keywords": [],
|
|
|
|
"license": "MIT",
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": "foo",
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"vers": "0.0.1"
|
|
|
|
}
|
|
|
|
"#;
|
|
|
|
|
|
|
|
fn validate_upload_foo() {
|
|
|
|
publish::validate_upload(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [],
|
|
|
|
"description": "foo",
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": "MIT",
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"vers": "0.0.1"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"foo-0.0.1.crate",
|
2019-06-10 19:38:51 +00:00
|
|
|
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
2018-12-30 04:46:15 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-05-18 14:40:55 +00:00
|
|
|
fn validate_upload_li() {
|
2021-07-21 17:33:19 +00:00
|
|
|
publish::validate_upload(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [],
|
2022-05-18 14:40:55 +00:00
|
|
|
"description": "li",
|
2021-07-21 17:33:19 +00:00
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": "MIT",
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
2022-05-18 14:40:55 +00:00
|
|
|
"name": "li",
|
2021-07-21 17:33:19 +00:00
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": "1.69",
|
2021-07-21 17:33:19 +00:00
|
|
|
"vers": "0.0.1"
|
|
|
|
}
|
|
|
|
"#,
|
2022-05-18 14:40:55 +00:00
|
|
|
"li-0.0.1.crate",
|
2021-07-21 17:33:19 +00:00
|
|
|
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn simple() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2016-05-25 20:55:42 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-06-22 19:32:30 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2022-08-31 05:53:47 +00:00
|
|
|
[UPDATING] crates.io index
|
2017-06-22 19:32:30 +00:00
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
2018-09-08 02:42:26 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ([CWD])
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2018-09-08 02:42:26 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `foo v0.0.1` to be available at registry `crates-io`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 at registry `crates-io`
|
2017-12-20 03:37:14 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2017-12-20 03:37:14 +00:00
|
|
|
|
2018-12-30 04:46:15 +00:00
|
|
|
validate_upload_foo();
|
2017-12-20 03:37:14 +00:00
|
|
|
}
|
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// Check that the `token` key works at the root instead of under a
|
|
|
|
// `[registry]` table.
|
2022-12-12 17:49:22 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn simple_publish_with_http() {
|
|
|
|
let _reg = registry::RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.token(registry::Token::Plaintext("sekrit".to_string()))
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify --token sekrit --registry dummy-registry")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] foo v0.0.1 ([CWD])
|
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `dummy-registry`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `foo v0.0.1` to be available at registry `dummy-registry`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 at registry `dummy-registry`
|
2022-12-12 17:49:22 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn simple_publish_with_asymmetric() {
|
|
|
|
let _reg = registry::RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
|
|
|
.alternative_named("dummy-registry")
|
|
|
|
.token(registry::Token::rfc_key())
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-08-24 05:12:50 +00:00
|
|
|
p.cargo("publish --no-verify -Zasymmetric-token --registry dummy-registry")
|
|
|
|
.masquerade_as_nightly_cargo(&["asymmetric-token"])
|
2022-12-12 17:49:22 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] foo v0.0.1 ([CWD])
|
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `dummy-registry`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `foo v0.0.1` to be available at registry `dummy-registry`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 at registry `dummy-registry`
|
2022-12-12 17:49:22 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-12-20 03:37:14 +00:00
|
|
|
fn old_token_location() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2017-12-20 03:37:14 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-12-20 03:37:14 +00:00
|
|
|
.build();
|
|
|
|
|
2023-01-03 21:40:58 +00:00
|
|
|
let credentials = paths::home().join(".cargo/credentials.toml");
|
2019-01-11 23:56:46 +00:00
|
|
|
fs::remove_file(&credentials).unwrap();
|
|
|
|
|
|
|
|
// Verify can't publish without a token.
|
2020-03-06 23:05:12 +00:00
|
|
|
p.cargo("publish --no-verify")
|
2022-08-31 05:53:47 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
2019-01-11 23:56:46 +00:00
|
|
|
.with_status(101)
|
2020-03-06 23:05:12 +00:00
|
|
|
.with_stderr_contains(
|
2022-10-31 16:44:01 +00:00
|
|
|
"[ERROR] no token found, \
|
|
|
|
please run `cargo login`",
|
2020-03-06 23:05:12 +00:00
|
|
|
)
|
2019-01-11 23:56:46 +00:00
|
|
|
.run();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
fs::write(&credentials, format!(r#"token = "{}""#, registry.token())).unwrap();
|
2019-01-11 23:56:46 +00:00
|
|
|
|
2020-03-06 23:05:12 +00:00
|
|
|
p.cargo("publish --no-verify")
|
2022-08-31 05:53:47 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2022-08-31 05:53:47 +00:00
|
|
|
[UPDATING] crates.io index
|
2017-12-20 03:37:14 +00:00
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
2018-09-08 02:42:26 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ([CWD])
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2018-09-08 02:42:26 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
2017-06-22 19:32:30 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2017-06-22 19:32:30 +00:00
|
|
|
|
2022-10-07 20:19:40 +00:00
|
|
|
// Skip `validate_upload_foo` as we just cared we got far enough for verify the token behavior.
|
|
|
|
// Other tests will verify the endpoint gets the right payload.
|
2021-12-02 02:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn simple_with_index() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2021-12-02 02:42:52 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2021-12-02 02:42:52 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.arg("--token")
|
|
|
|
.arg(registry.token())
|
|
|
|
.arg("--index")
|
2022-06-09 03:04:33 +00:00
|
|
|
.arg(registry.index_url().as_str())
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `[ROOT]/registry`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2021-12-02 02:42:52 +00:00
|
|
|
.run();
|
|
|
|
|
2022-10-07 20:19:40 +00:00
|
|
|
// Skip `validate_upload_foo` as we just cared we got far enough for verify the VCS behavior.
|
|
|
|
// Other tests will verify the endpoint gets the right payload.
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn git_deps() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2014-09-09 14:23:09 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2014-09-09 14:23:09 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.foo]
|
|
|
|
git = "git://path/to/nowhere"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-09-09 14:23:09 +00:00
|
|
|
|
2023-06-27 16:26:27 +00:00
|
|
|
p.cargo("publish --no-verify")
|
2022-08-31 05:53:47 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2019-08-11 23:50:13 +00:00
|
|
|
[ERROR] all dependencies must have a version specified when publishing.
|
|
|
|
dependency `foo` does not specify a version
|
|
|
|
Note: The published dependency will use the version from crates.io,
|
|
|
|
the `git` specification will be removed from the dependency declaration.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn path_dependency_no_version() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2014-09-27 04:14:46 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2014-09-27 04:14:46 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
path = "bar"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("bar/src/lib.rs", "")
|
|
|
|
.build();
|
2014-09-09 14:23:09 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2019-08-11 23:50:13 +00:00
|
|
|
[ERROR] all dependencies must have a version specified when publishing.
|
2014-09-27 04:14:46 +00:00
|
|
|
dependency `bar` does not specify a version
|
2019-08-11 23:50:13 +00:00
|
|
|
Note: The published dependency will use the version from crates.io,
|
|
|
|
the `path` specification will be removed from the dependency declaration.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn unpublishable_crate() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-06-09 03:04:33 +00:00
|
|
|
let registry = registry::init();
|
2016-01-23 21:16:30 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = false
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-01-23 21:16:30 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --index")
|
2022-06-09 03:04:33 +00:00
|
|
|
.arg(registry.index_url().as_str())
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2019-04-11 18:34:00 +00:00
|
|
|
[ERROR] `foo` cannot be published.
|
2023-10-06 18:01:58 +00:00
|
|
|
`package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-06-10 13:43:34 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-06-10 13:43:34 +00:00
|
|
|
fn dont_publish_dirty() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2022-10-07 20:00:59 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().file("bar", "").build();
|
2016-06-10 13:43:34 +00:00
|
|
|
|
2019-08-11 23:50:13 +00:00
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2016-06-10 13:43:34 +00:00
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2022-08-31 05:53:47 +00:00
|
|
|
[UPDATING] crates.io index
|
2017-04-09 02:20:41 +00:00
|
|
|
error: 1 files in the working directory contain changes that were not yet \
|
|
|
|
committed into git:
|
2016-06-10 13:43:34 +00:00
|
|
|
|
|
|
|
bar
|
|
|
|
|
2019-12-11 14:31:26 +00:00
|
|
|
to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-06-10 13:43:34 +00:00
|
|
|
fn publish_clean() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2016-06-10 13:43:34 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().build();
|
2017-02-15 14:16:41 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
let _ = repo(&paths::root().join("foo"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2016-06-10 13:43:34 +00:00
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
2022-10-07 20:19:40 +00:00
|
|
|
// Skip `validate_upload_foo_clean` as we just cared we got far enough for verify the VCS behavior.
|
|
|
|
// Other tests will verify the endpoint gets the right payload.
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-06-10 13:43:34 +00:00
|
|
|
fn publish_in_sub_repo() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2016-06-10 13:43:34 +00:00
|
|
|
|
2018-07-24 12:59:42 +00:00
|
|
|
let p = project().no_manifest().file("baz", "").build();
|
2017-02-15 14:16:41 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
let _ = repo(&paths::root().join("foo"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2016-06-10 13:43:34 +00:00
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.cwd("bar")
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
2022-10-07 20:19:40 +00:00
|
|
|
// Skip `validate_upload_foo_clean` as we just cared we got far enough for verify the VCS behavior.
|
|
|
|
// Other tests will verify the endpoint gets the right payload.
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-06-10 13:43:34 +00:00
|
|
|
fn publish_when_ignored() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2016-06-10 13:43:34 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().file("baz", "").build();
|
2017-02-15 14:16:41 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
let _ = repo(&paths::root().join("foo"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2016-06-10 13:43:34 +00:00
|
|
|
.file(".gitignore", "baz")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
2022-10-07 20:19:40 +00:00
|
|
|
// Skip `validate_upload` as we just cared we got far enough for verify the VCS behavior.
|
|
|
|
// Other tests will verify the endpoint gets the right payload.
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-06-10 13:43:34 +00:00
|
|
|
fn ignore_when_crate_ignored() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2016-06-10 13:43:34 +00:00
|
|
|
|
2018-07-24 12:59:42 +00:00
|
|
|
let p = project().no_manifest().file("bar/baz", "").build();
|
2017-02-15 14:16:41 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
let _ = repo(&paths::root().join("foo"))
|
2016-06-10 13:43:34 +00:00
|
|
|
.file(".gitignore", "bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.nocommit_file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.nocommit_file("bar/src/main.rs", "fn main() {}");
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.cwd("bar")
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
2022-10-07 20:19:40 +00:00
|
|
|
// Skip `validate_upload` as we just cared we got far enough for verify the VCS behavior.
|
|
|
|
// Other tests will verify the endpoint gets the right payload.
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-06-10 13:43:34 +00:00
|
|
|
fn new_crate_rejected() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2016-06-10 13:43:34 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().file("baz", "").build();
|
2017-02-15 14:16:41 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
let _ = repo(&paths::root().join("foo"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.nocommit_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.nocommit_file("src/main.rs", "fn main() {}");
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
2018-12-29 01:47:50 +00:00
|
|
|
.with_stderr_contains(
|
|
|
|
"[ERROR] 3 files in the working directory contain \
|
|
|
|
changes that were not yet committed into git:",
|
|
|
|
)
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
2016-07-17 23:43:57 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-17 23:43:57 +00:00
|
|
|
fn dry_run() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-06-09 03:04:33 +00:00
|
|
|
let registry = registry::init();
|
2016-07-17 23:43:57 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-17 23:43:57 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --dry-run --index")
|
2022-06-09 03:04:33 +00:00
|
|
|
.arg(registry.index_url().as_str())
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `[..]` index
|
2016-07-17 23:43:57 +00:00
|
|
|
[WARNING] manifest has no documentation, [..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See [..]
|
2018-09-08 02:42:26 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ([CWD])
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
2016-07-17 23:43:57 +00:00
|
|
|
[COMPILING] foo v0.0.1 [..]
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2018-09-08 02:42:26 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2016-07-17 23:43:57 +00:00
|
|
|
[WARNING] aborting upload due to dry run
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-17 23:43:57 +00:00
|
|
|
|
|
|
|
// Ensure the API request wasn't actually made
|
2019-01-11 23:56:46 +00:00
|
|
|
assert!(registry::api_path().join("api/v1/crates").exists());
|
|
|
|
assert!(!registry::api_path().join("api/v1/crates/new").exists());
|
2016-07-17 23:43:57 +00:00
|
|
|
}
|
2017-10-03 08:36:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-10-31 06:28:09 +00:00
|
|
|
fn registry_not_in_publish_list() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = [
|
|
|
|
"test"
|
|
|
|
]
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-31 06:28:09 +00:00
|
|
|
.build();
|
2017-10-03 08:36:46 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.arg("--registry")
|
|
|
|
.arg("alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2019-04-11 18:34:00 +00:00
|
|
|
[ERROR] `foo` cannot be published.
|
2022-10-24 14:50:25 +00:00
|
|
|
The registry `alternative` is not listed in the `package.publish` value in Cargo.toml.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-10-03 08:36:46 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-10-03 08:36:46 +00:00
|
|
|
fn publish_empty_list() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = []
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-31 06:28:09 +00:00
|
|
|
.build();
|
2017-10-03 08:36:46 +00:00
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2019-04-11 18:34:00 +00:00
|
|
|
[ERROR] `foo` cannot be published.
|
2023-10-06 18:01:58 +00:00
|
|
|
`package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-10-03 08:36:46 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-10-31 06:28:09 +00:00
|
|
|
fn publish_allowed_registry() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let _registry = RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
|
|
|
.alternative()
|
|
|
|
.build();
|
2017-10-03 08:36:46 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().build();
|
2017-10-03 08:36:46 +00:00
|
|
|
|
2017-10-31 06:28:09 +00:00
|
|
|
let _ = repo(&paths::root().join("foo"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
publish = ["alternative"]
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-03 08:36:46 +00:00
|
|
|
.build();
|
|
|
|
|
2022-10-07 20:00:59 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `alternative`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `foo v0.0.1` to be available at registry `alternative`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 at registry `alternative`
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
2019-01-11 23:56:46 +00:00
|
|
|
publish::validate_alt_upload(
|
|
|
|
CLEAN_FOO_JSON,
|
|
|
|
"foo-0.0.1.crate",
|
|
|
|
&[
|
2019-06-10 19:38:51 +00:00
|
|
|
"Cargo.lock",
|
2019-01-11 23:56:46 +00:00
|
|
|
"Cargo.toml",
|
|
|
|
"Cargo.toml.orig",
|
|
|
|
"src/main.rs",
|
|
|
|
".cargo_vcs_info.json",
|
|
|
|
],
|
|
|
|
);
|
2017-10-03 08:36:46 +00:00
|
|
|
}
|
2017-10-31 06:28:09 +00:00
|
|
|
|
2020-07-31 00:26:29 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn publish_implicitly_to_only_allowed_registry() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let _registry = RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
|
|
|
.alternative()
|
|
|
|
.build();
|
2020-07-31 00:26:29 +00:00
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
publish = ["alternative"]
|
|
|
|
"#,
|
2020-07-31 00:26:29 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-10-07 20:00:59 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[NOTE] Found `alternative` as only allowed registry. Publishing to it automatically.
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `alternative`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
|
|
|
.run();
|
2020-07-31 00:26:29 +00:00
|
|
|
|
|
|
|
publish::validate_alt_upload(
|
|
|
|
CLEAN_FOO_JSON,
|
|
|
|
"foo-0.0.1.crate",
|
|
|
|
&[
|
|
|
|
"Cargo.lock",
|
|
|
|
"Cargo.toml",
|
|
|
|
"Cargo.toml.orig",
|
|
|
|
"src/main.rs",
|
|
|
|
".cargo_vcs_info.json",
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-09-15 16:47:59 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn publish_failed_with_index_and_only_allowed_registry() {
|
|
|
|
let registry = RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
|
|
|
.alternative()
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
publish = ["alternative"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish")
|
|
|
|
.arg("--index")
|
|
|
|
.arg(registry.index_url().as_str())
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[NOTE] Found `alternative` as only allowed registry. Publishing to it automatically.
|
|
|
|
[ERROR] command-line argument --index requires --token to be specified
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2020-07-31 00:26:29 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn publish_fail_with_no_registry_specified() {
|
|
|
|
let p = project().build();
|
|
|
|
|
|
|
|
let _ = repo(&paths::root().join("foo"))
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
publish = ["alternative", "test"]
|
|
|
|
"#,
|
2020-07-31 00:26:29 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] `foo` cannot be published.
|
2022-10-24 14:50:25 +00:00
|
|
|
The registry `crates-io` is not listed in the `package.publish` value in Cargo.toml.
|
2020-07-31 00:26:29 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-10-31 06:28:09 +00:00
|
|
|
fn block_publish_no_registry() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = []
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-31 06:28:09 +00:00
|
|
|
.build();
|
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2019-04-11 18:34:00 +00:00
|
|
|
[ERROR] `foo` cannot be published.
|
2023-10-06 18:01:58 +00:00
|
|
|
`package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-10-31 06:28:09 +00:00
|
|
|
}
|
2018-12-26 13:48:25 +00:00
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// Explicitly setting `crates-io` in the publish list.
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-04-11 18:34:00 +00:00
|
|
|
fn publish_with_crates_io_explicit() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2019-04-11 18:34:00 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = ["crates-io"]
|
|
|
|
"#,
|
2019-04-11 18:34:00 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --registry alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] `foo` cannot be published.
|
2022-10-24 14:50:25 +00:00
|
|
|
The registry `alternative` is not listed in the `package.publish` value in Cargo.toml.
|
2019-04-11 18:34:00 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[PACKAGING] [..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2019-04-11 18:34:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-12-26 13:48:25 +00:00
|
|
|
fn publish_with_select_features() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2018-12-26 13:48:25 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2018-12-26 13:48:25 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[features]
|
|
|
|
required = []
|
|
|
|
optional = []
|
|
|
|
"#,
|
2018-12-29 15:33:20 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-12-26 13:48:25 +00:00
|
|
|
"src/main.rs",
|
2019-01-09 16:41:03 +00:00
|
|
|
"#[cfg(not(feature = \"required\"))]
|
2018-12-26 13:48:25 +00:00
|
|
|
compile_error!(\"This crate requires `required` feature!\");
|
|
|
|
fn main() {}",
|
2019-01-09 16:41:03 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-12-26 13:48:25 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --features required")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 18:44:28 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
2022-10-07 18:44:28 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
2022-10-07 18:44:28 +00:00
|
|
|
",
|
|
|
|
)
|
2019-01-09 16:41:03 +00:00
|
|
|
.run();
|
2018-12-26 13:48:25 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-12-26 13:48:25 +00:00
|
|
|
fn publish_with_all_features() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2018-12-26 13:48:25 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2018-12-26 13:48:25 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[features]
|
|
|
|
required = []
|
|
|
|
optional = []
|
|
|
|
"#,
|
2018-12-29 15:33:20 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-12-26 13:48:25 +00:00
|
|
|
"src/main.rs",
|
2019-01-09 16:41:03 +00:00
|
|
|
"#[cfg(not(feature = \"required\"))]
|
2018-12-26 13:48:25 +00:00
|
|
|
compile_error!(\"This crate requires `required` feature!\");
|
|
|
|
fn main() {}",
|
2019-01-09 16:41:03 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-12-26 13:48:25 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --all-features")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 18:44:28 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
2022-10-07 18:44:28 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
2022-10-07 18:44:28 +00:00
|
|
|
",
|
|
|
|
)
|
2019-01-09 16:41:03 +00:00
|
|
|
.run();
|
2017-10-31 06:28:09 +00:00
|
|
|
}
|
2019-01-09 17:25:36 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-01-09 17:25:36 +00:00
|
|
|
fn publish_with_no_default_features() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2019-01-09 17:25:36 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2019-01-09 17:25:36 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[features]
|
|
|
|
default = ["required"]
|
|
|
|
required = []
|
|
|
|
"#,
|
2019-01-09 17:25:36 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
"#[cfg(not(feature = \"required\"))]
|
|
|
|
compile_error!(\"This crate requires `required` feature!\");
|
|
|
|
fn main() {}",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-default-features")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2019-01-09 17:25:36 +00:00
|
|
|
.with_status(101)
|
2022-10-06 21:46:44 +00:00
|
|
|
.with_stderr_contains("error: This crate requires `required` feature!")
|
2019-01-09 17:25:36 +00:00
|
|
|
.run();
|
|
|
|
}
|
2019-01-11 23:56:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-01-11 23:56:46 +00:00
|
|
|
fn publish_with_patch() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2019-01-11 23:56:46 +00:00
|
|
|
Package::new("bar", "1.0.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
[dependencies]
|
|
|
|
bar = "1.0"
|
|
|
|
[patch.crates-io]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
"#,
|
2019-01-11 23:56:46 +00:00
|
|
|
)
|
2019-01-10 06:38:13 +00:00
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
"extern crate bar;
|
|
|
|
fn main() {
|
|
|
|
bar::newfunc();
|
|
|
|
}",
|
|
|
|
)
|
2019-01-11 23:56:46 +00:00
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "1.0.0"))
|
2019-01-10 06:38:13 +00:00
|
|
|
.file("bar/src/lib.rs", "pub fn newfunc() {}")
|
2019-01-11 23:56:46 +00:00
|
|
|
.build();
|
|
|
|
|
|
|
|
// Check that it works with the patched crate.
|
|
|
|
p.cargo("build").run();
|
|
|
|
|
2019-01-10 06:38:13 +00:00
|
|
|
// Check that verify fails with patched crate which has new functionality.
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2019-01-11 23:56:46 +00:00
|
|
|
.with_status(101)
|
2022-10-06 21:46:44 +00:00
|
|
|
.with_stderr_contains("[..]newfunc[..]")
|
2019-01-11 23:56:46 +00:00
|
|
|
.run();
|
2019-01-10 06:38:13 +00:00
|
|
|
|
|
|
|
// Remove the usage of new functionality and try again.
|
|
|
|
p.change_file("src/main.rs", "extern crate bar; pub fn main() {}");
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
2023-02-19 05:26:59 +00:00
|
|
|
[UPDATING] crates.io index
|
2022-10-07 20:00:59 +00:00
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2019-01-10 06:38:13 +00:00
|
|
|
|
|
|
|
publish::validate_upload(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "normal",
|
|
|
|
"name": "bar",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^1.0"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": "foo",
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": "MIT",
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2019-01-10 06:38:13 +00:00
|
|
|
"vers": "0.0.1"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"foo-0.0.1.crate",
|
2019-06-10 19:38:51 +00:00
|
|
|
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
2019-01-10 06:38:13 +00:00
|
|
|
);
|
2019-01-11 23:56:46 +00:00
|
|
|
}
|
2019-04-16 16:52:07 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-04-16 16:52:07 +00:00
|
|
|
fn publish_checks_for_token_before_verify() {
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::RegistryBuilder::new()
|
|
|
|
.no_configure_token()
|
|
|
|
.build();
|
2019-04-16 16:52:07 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
2019-04-16 16:52:07 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// Assert upload token error before the package is verified
|
|
|
|
p.cargo("publish")
|
2022-08-31 05:53:47 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
2019-04-16 16:52:07 +00:00
|
|
|
.with_status(101)
|
2022-10-31 16:44:01 +00:00
|
|
|
.with_stderr_contains("[ERROR] no token found, please run `cargo login`")
|
2019-04-16 16:52:07 +00:00
|
|
|
.with_stderr_does_not_contain("[VERIFYING] foo v0.0.1 ([CWD])")
|
|
|
|
.run();
|
|
|
|
|
|
|
|
// Assert package verified successfully on dry run
|
|
|
|
p.cargo("publish --dry-run")
|
2022-08-31 05:53:47 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 18:44:28 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
2022-10-07 18:44:28 +00:00
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
|
|
|
[WARNING] aborting upload due to dry run
|
|
|
|
",
|
|
|
|
)
|
2019-04-16 16:52:07 +00:00
|
|
|
.run();
|
|
|
|
}
|
2019-08-12 01:58:52 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn publish_with_bad_source() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
|
|
|
[source.crates-io]
|
|
|
|
replace-with = 'local-registry'
|
|
|
|
|
|
|
|
[source.local-registry]
|
|
|
|
local-registry = 'registry'
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
2019-08-12 01:58:52 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2022-08-31 05:53:47 +00:00
|
|
|
[ERROR] crates-io is replaced with non-remote-registry source registry `[..]/foo/registry`;
|
|
|
|
include `--registry crates-io` to use crates.io
|
2019-08-12 01:58:52 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.change_file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
|
|
|
[source.crates-io]
|
|
|
|
replace-with = "vendored-sources"
|
|
|
|
|
|
|
|
[source.vendored-sources]
|
|
|
|
directory = "vendor"
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
2019-08-12 01:58:52 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2022-08-31 05:53:47 +00:00
|
|
|
[ERROR] crates-io is replaced with non-remote-registry source dir [..]/foo/vendor;
|
|
|
|
include `--registry crates-io` to use crates.io
|
2019-08-12 01:58:52 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2019-08-11 23:50:13 +00:00
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// A dependency with both `git` and `version`.
|
2019-08-11 23:50:13 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn publish_git_with_version() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2022-10-07 20:19:16 +00:00
|
|
|
|
2019-08-11 23:50:13 +00:00
|
|
|
Package::new("dep1", "1.0.1")
|
|
|
|
.file("src/lib.rs", "pub fn f() -> i32 {1}")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let git_project = git::new("dep1", |project| {
|
|
|
|
project
|
|
|
|
.file("Cargo.toml", &basic_manifest("dep1", "1.0.0"))
|
|
|
|
.file("src/lib.rs", "pub fn f() -> i32 {2}")
|
|
|
|
});
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
edition = "2018"
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
dep1 = {{version = "1.0", git="{}"}}
|
|
|
|
"#,
|
|
|
|
git_project.url()
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
|
|
|
pub fn main() {
|
|
|
|
println!("{}", dep1::f());
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("run").with_stdout("2").run();
|
2022-10-07 20:19:16 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
2023-02-19 05:26:59 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.1.0 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.1.0 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.1.0 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2019-08-11 23:50:13 +00:00
|
|
|
|
|
|
|
publish::validate_upload_with_contents(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "normal",
|
|
|
|
"name": "dep1",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^1.0"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": "foo",
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": "MIT",
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2019-08-11 23:50:13 +00:00
|
|
|
"vers": "0.1.0"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"foo-0.1.0.crate",
|
|
|
|
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
|
|
|
&[
|
|
|
|
(
|
|
|
|
"Cargo.toml",
|
|
|
|
// Check that only `version` is included in Cargo.toml.
|
2021-06-16 02:23:17 +00:00
|
|
|
&format!(
|
|
|
|
"{}\n\
|
|
|
|
[package]\n\
|
|
|
|
edition = \"2018\"\n\
|
|
|
|
name = \"foo\"\n\
|
|
|
|
version = \"0.1.0\"\n\
|
|
|
|
authors = []\n\
|
|
|
|
description = \"foo\"\n\
|
|
|
|
license = \"MIT\"\n\
|
2021-11-02 00:18:32 +00:00
|
|
|
\n\
|
2021-06-16 02:23:17 +00:00
|
|
|
[dependencies.dep1]\n\
|
|
|
|
version = \"1.0\"\n\
|
|
|
|
",
|
|
|
|
cargo::core::package::MANIFEST_PREAMBLE
|
|
|
|
),
|
2019-08-11 23:50:13 +00:00
|
|
|
),
|
|
|
|
(
|
|
|
|
"Cargo.lock",
|
|
|
|
// The important check here is that it is 1.0.1 in the registry.
|
2021-06-16 02:23:17 +00:00
|
|
|
"# This file is automatically @generated by Cargo.\n\
|
|
|
|
# It is not intended for manual editing.\n\
|
|
|
|
version = 3\n\
|
|
|
|
\n\
|
|
|
|
[[package]]\n\
|
|
|
|
name = \"dep1\"\n\
|
|
|
|
version = \"1.0.1\"\n\
|
|
|
|
source = \"registry+https://github.com/rust-lang/crates.io-index\"\n\
|
|
|
|
checksum = \"[..]\"\n\
|
|
|
|
\n\
|
2019-08-11 23:50:13 +00:00
|
|
|
[[package]]\n\
|
|
|
|
name = \"foo\"\n\
|
|
|
|
version = \"0.1.0\"\n\
|
|
|
|
dependencies = [\n\
|
2019-11-08 23:48:04 +00:00
|
|
|
\x20\"dep1\",\n\
|
2019-08-11 23:50:13 +00:00
|
|
|
]\n\
|
2021-06-16 02:23:17 +00:00
|
|
|
",
|
2019-08-11 23:50:13 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2019-09-05 21:56:21 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn publish_dev_dep_no_version() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2019-09-05 21:56:21 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
|
|
|
|
[dev-dependencies]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
|
|
|
.file("bar/src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2019-09-05 21:56:21 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[PACKAGING] foo v0.1.0 [..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2019-09-05 21:56:21 +00:00
|
|
|
[UPLOADING] foo v0.1.0 [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.1.0 [..]
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.1.0 [..]
|
2019-09-05 21:56:21 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2019-09-11 00:06:32 +00:00
|
|
|
publish::validate_upload_with_contents(
|
2019-09-05 21:56:21 +00:00
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [],
|
|
|
|
"description": "foo",
|
|
|
|
"documentation": "foo",
|
|
|
|
"features": {},
|
|
|
|
"homepage": "foo",
|
|
|
|
"keywords": [],
|
|
|
|
"license": "MIT",
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": "foo",
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2019-09-05 21:56:21 +00:00
|
|
|
"vers": "0.1.0"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"foo-0.1.0.crate",
|
|
|
|
&["Cargo.toml", "Cargo.toml.orig", "src/lib.rs"],
|
2019-09-11 00:06:32 +00:00
|
|
|
&[(
|
|
|
|
"Cargo.toml",
|
2021-06-16 02:23:17 +00:00
|
|
|
&format!(
|
|
|
|
r#"{}
|
2019-09-11 00:06:32 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
description = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
license = "MIT"
|
|
|
|
repository = "foo"
|
2022-01-31 13:21:44 +00:00
|
|
|
|
|
|
|
[dev-dependencies]
|
2019-09-11 00:06:32 +00:00
|
|
|
"#,
|
2021-06-16 02:23:17 +00:00
|
|
|
cargo::core::package::MANIFEST_PREAMBLE
|
|
|
|
),
|
2019-09-11 00:06:32 +00:00
|
|
|
)],
|
2019-09-05 21:56:21 +00:00
|
|
|
);
|
|
|
|
}
|
2020-01-07 14:02:33 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn credentials_ambiguous_filename() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2020-01-07 14:02:33 +00:00
|
|
|
|
2023-01-03 21:40:58 +00:00
|
|
|
// Make token in `credentials.toml` incorrect to ensure it is not read.
|
2020-01-07 14:02:33 +00:00
|
|
|
let credentials_toml = paths::home().join(".cargo/credentials.toml");
|
2023-01-03 21:40:58 +00:00
|
|
|
fs::write(credentials_toml, r#"token = "wrong-token""#).unwrap();
|
2020-01-07 14:02:33 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
2020-01-07 14:02:33 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-01-03 21:40:58 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains("[..]Unauthorized message from server[..]")
|
|
|
|
.run();
|
|
|
|
|
|
|
|
// Favor `credentials` if exists.
|
|
|
|
let credentials = paths::home().join(".cargo/credentials");
|
|
|
|
fs::write(credentials, r#"token = "sekrit""#).unwrap();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 18:44:28 +00:00
|
|
|
.with_stderr(
|
2020-01-07 14:02:33 +00:00
|
|
|
"\
|
2022-10-07 18:44:28 +00:00
|
|
|
[..]
|
2022-10-31 16:44:01 +00:00
|
|
|
[WARNING] Both `[..]/credentials` and `[..]/credentials.toml` exist. Using `[..]/credentials`
|
2022-10-07 18:44:28 +00:00
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
2022-10-07 18:44:28 +00:00
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 [..]
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
2020-01-07 14:02:33 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2020-03-06 23:05:12 +00:00
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// --index will not load registry.token to avoid possibly leaking
|
|
|
|
// crates.io token to another server.
|
2020-03-06 23:05:12 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn index_requires_token() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-06-09 03:04:33 +00:00
|
|
|
let registry = registry::init();
|
2022-10-07 20:16:34 +00:00
|
|
|
|
2023-01-03 21:40:58 +00:00
|
|
|
let credentials = paths::home().join(".cargo/credentials.toml");
|
2020-03-07 01:29:12 +00:00
|
|
|
fs::remove_file(&credentials).unwrap();
|
2020-03-06 23:05:12 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify --index")
|
2022-06-09 03:04:33 +00:00
|
|
|
.arg(registry.index_url().as_str())
|
2020-03-06 23:05:12 +00:00
|
|
|
.with_status(101)
|
2020-03-07 01:29:12 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] command-line argument --index requires --token to be specified
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// publish with source replacement without --registry
|
2020-03-07 01:29:12 +00:00
|
|
|
#[cargo_test]
|
2022-08-31 05:53:47 +00:00
|
|
|
fn cratesio_source_replacement() {
|
2020-03-07 01:29:12 +00:00
|
|
|
registry::init();
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
2020-03-07 01:29:12 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify")
|
2022-08-31 05:53:47 +00:00
|
|
|
.with_status(101)
|
2020-03-07 01:29:12 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
2022-08-31 05:53:47 +00:00
|
|
|
[ERROR] crates-io is replaced with remote registry dummy-registry;
|
|
|
|
include `--registry dummy-registry` or `--registry crates-io`
|
2020-03-07 01:29:12 +00:00
|
|
|
",
|
|
|
|
)
|
2020-03-06 23:05:12 +00:00
|
|
|
.run();
|
|
|
|
}
|
2020-06-11 21:55:33 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn publish_with_missing_readme() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2022-10-07 20:16:34 +00:00
|
|
|
|
2020-06-11 21:55:33 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
homepage = "https://example.com/"
|
|
|
|
readme = "foo.md"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2020-06-11 21:55:33 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(&format!(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
2023-04-25 17:25:58 +00:00
|
|
|
[WARNING] readme `foo.md` does not appear to exist (relative to `[..]/foo`).
|
|
|
|
Please update the readme setting in the manifest at `[..]/foo/Cargo.toml`
|
|
|
|
This may become a hard error in the future.
|
2020-06-11 21:55:33 +00:00
|
|
|
[PACKAGING] foo v0.1.0 [..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2020-06-11 21:55:33 +00:00
|
|
|
[UPLOADING] foo v0.1.0 [..]
|
|
|
|
[ERROR] failed to read `readme` file for package `foo v0.1.0 ([ROOT]/foo)`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to read `[ROOT]/foo/foo.md`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
{}
|
|
|
|
",
|
|
|
|
no_such_file_err_msg()
|
|
|
|
))
|
|
|
|
.run();
|
|
|
|
}
|
2021-01-28 20:39:51 +00:00
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// Registry returns an API error.
|
2021-01-28 20:39:51 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn api_error_json() {
|
2022-06-09 03:04:33 +00:00
|
|
|
let _registry = registry::RegistryBuilder::new()
|
|
|
|
.alternative()
|
|
|
|
.http_api()
|
2022-09-09 20:58:58 +00:00
|
|
|
.add_responder("/api/v1/crates/new", |_, _| Response {
|
2022-06-09 03:04:33 +00:00
|
|
|
body: br#"{"errors": [{"detail": "you must be logged in"}]}"#.to_vec(),
|
|
|
|
code: 403,
|
|
|
|
headers: vec![],
|
|
|
|
})
|
|
|
|
.build();
|
2021-01-28 20:39:51 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2021-01-28 20:39:51 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify --registry alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[PACKAGING] foo v0.0.1 [..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2021-01-28 20:39:51 +00:00
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
2021-02-27 20:38:17 +00:00
|
|
|
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
the remote server responded with an error (status 403 Forbidden): you must be logged in
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// Registry returns an API error with a 200 status code.
|
2021-02-27 20:38:17 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn api_error_200() {
|
2022-06-09 03:04:33 +00:00
|
|
|
let _registry = registry::RegistryBuilder::new()
|
|
|
|
.alternative()
|
|
|
|
.http_api()
|
2022-09-09 20:58:58 +00:00
|
|
|
.add_responder("/api/v1/crates/new", |_, _| Response {
|
2022-06-09 03:04:33 +00:00
|
|
|
body: br#"{"errors": [{"detail": "max upload size is 123"}]}"#.to_vec(),
|
|
|
|
code: 200,
|
|
|
|
headers: vec![],
|
|
|
|
})
|
|
|
|
.build();
|
2021-02-27 20:38:17 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2021-02-27 20:38:17 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify --registry alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[PACKAGING] foo v0.0.1 [..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2021-02-27 20:38:17 +00:00
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
|
|
|
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
the remote server responded with an error: max upload size is 123
|
2021-01-28 20:39:51 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// Registry returns an error code without a JSON message.
|
2021-01-28 20:39:51 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn api_error_code() {
|
2022-06-09 03:04:33 +00:00
|
|
|
let _registry = registry::RegistryBuilder::new()
|
|
|
|
.alternative()
|
|
|
|
.http_api()
|
2022-09-09 20:58:58 +00:00
|
|
|
.add_responder("/api/v1/crates/new", |_, _| Response {
|
2022-06-09 03:04:33 +00:00
|
|
|
body: br#"go away"#.to_vec(),
|
|
|
|
code: 400,
|
|
|
|
headers: vec![],
|
|
|
|
})
|
|
|
|
.build();
|
2021-01-28 20:39:51 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2021-01-28 20:39:51 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify --registry alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[PACKAGING] foo v0.0.1 [..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2021-01-28 20:39:51 +00:00
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
2021-02-27 20:38:17 +00:00
|
|
|
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to get a 200 OK response, got 400
|
|
|
|
headers:
|
|
|
|
<tab>HTTP/1.1 400
|
|
|
|
<tab>Content-Length: 7
|
2023-09-22 20:37:26 +00:00
|
|
|
<tab>Connection: close
|
2021-02-27 20:38:17 +00:00
|
|
|
<tab>
|
|
|
|
body:
|
|
|
|
go away
|
2021-01-28 20:39:51 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// Registry has a network error.
|
2021-01-28 20:39:51 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn api_curl_error() {
|
2022-06-09 03:04:33 +00:00
|
|
|
let _registry = registry::RegistryBuilder::new()
|
|
|
|
.alternative()
|
|
|
|
.http_api()
|
2022-09-09 20:58:58 +00:00
|
|
|
.add_responder("/api/v1/crates/new", |_, _| {
|
2022-06-09 03:04:33 +00:00
|
|
|
panic!("broke");
|
|
|
|
})
|
|
|
|
.build();
|
2021-01-28 20:39:51 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2021-01-28 20:39:51 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// This doesn't check for the exact text of the error in the remote
|
|
|
|
// possibility that cargo is linked with a weird version of libcurl, or
|
|
|
|
// curl changes the text of the message. Currently the message 52
|
|
|
|
// (CURLE_GOT_NOTHING) is:
|
|
|
|
// Server returned nothing (no headers, no data) (Empty reply from server)
|
|
|
|
p.cargo("publish --no-verify --registry alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[PACKAGING] foo v0.0.1 [..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2021-01-28 20:39:51 +00:00
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
2021-02-27 20:38:17 +00:00
|
|
|
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
[52] [..]
|
2021-01-28 20:39:51 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-10-07 19:31:20 +00:00
|
|
|
// Registry returns an invalid response.
|
2021-01-28 20:39:51 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn api_other_error() {
|
2022-06-09 03:04:33 +00:00
|
|
|
let _registry = registry::RegistryBuilder::new()
|
|
|
|
.alternative()
|
|
|
|
.http_api()
|
2022-09-09 20:58:58 +00:00
|
|
|
.add_responder("/api/v1/crates/new", |_, _| Response {
|
2022-06-09 03:04:33 +00:00
|
|
|
body: b"\xff".to_vec(),
|
|
|
|
code: 200,
|
|
|
|
headers: vec![],
|
|
|
|
})
|
|
|
|
.build();
|
2021-01-28 20:39:51 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2021-01-28 20:39:51 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify --registry alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[PACKAGING] foo v0.0.1 [..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2021-01-28 20:39:51 +00:00
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
2021-02-27 20:38:17 +00:00
|
|
|
[ERROR] failed to publish to registry at http://127.0.0.1:[..]/
|
|
|
|
|
|
|
|
Caused by:
|
2023-06-25 13:27:58 +00:00
|
|
|
invalid response body from server
|
2021-01-28 20:39:51 +00:00
|
|
|
|
|
|
|
Caused by:
|
2023-06-25 13:27:58 +00:00
|
|
|
invalid utf-8 sequence of [..]
|
2021-01-28 20:39:51 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2021-07-21 17:33:19 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
2022-05-18 14:40:55 +00:00
|
|
|
fn in_package_workspace() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2022-05-18 14:40:55 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
2022-05-23 13:01:55 +00:00
|
|
|
edition = "2021"
|
2022-05-18 14:40:55 +00:00
|
|
|
[workspace]
|
|
|
|
members = ["li"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"li/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "li"
|
|
|
|
version = "0.0.1"
|
2023-03-24 20:46:59 +00:00
|
|
|
rust-version = "1.69"
|
2022-05-18 14:40:55 +00:00
|
|
|
description = "li"
|
|
|
|
license = "MIT"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("li/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish -p li --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-05-18 14:40:55 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] manifest has no documentation, homepage or repository.
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] li v0.0.1 ([CWD]/li)
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2022-05-18 14:40:55 +00:00
|
|
|
[UPLOADING] li v0.0.1 ([CWD]/li)
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] li v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] li v0.0.1 [..]
|
2022-05-18 14:40:55 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
validate_upload_li();
|
|
|
|
}
|
|
|
|
|
2022-05-25 10:17:08 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn with_duplicate_spec_in_members() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2022-05-25 10:17:08 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
[workspace]
|
|
|
|
resolver = "2"
|
|
|
|
members = ["li","bar"]
|
|
|
|
default-members = ["li","bar"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"li/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "li"
|
|
|
|
version = "0.0.1"
|
|
|
|
description = "li"
|
|
|
|
license = "MIT"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("li/src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
description = "bar"
|
|
|
|
license = "MIT"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-05-25 10:17:08 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2022-05-26 00:49:06 +00:00
|
|
|
"error: the `-p` argument must be specified to select a single package to publish",
|
2022-05-25 10:17:08 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn in_package_workspace_with_members_with_features_old() {
|
2023-02-19 05:26:59 +00:00
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
2022-05-25 10:17:08 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
[workspace]
|
|
|
|
members = ["li"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"li/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "li"
|
|
|
|
version = "0.0.1"
|
2023-03-24 20:46:59 +00:00
|
|
|
rust-version = "1.69"
|
2022-05-25 10:17:08 +00:00
|
|
|
description = "li"
|
|
|
|
license = "MIT"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("li/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish -p li --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-05-25 10:17:08 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] manifest has no documentation, homepage or repository.
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] li v0.0.1 ([CWD]/li)
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2022-05-25 10:17:08 +00:00
|
|
|
[UPLOADING] li v0.0.1 ([CWD]/li)
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] li v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] li v0.0.1 [..]
|
2022-05-25 10:17:08 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
validate_upload_li();
|
|
|
|
}
|
|
|
|
|
2022-05-18 14:40:55 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn in_virtual_workspace() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2021-07-21 17:33:19 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
2022-05-18 14:40:55 +00:00
|
|
|
members = ["foo"]
|
2021-07-21 17:33:19 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2021-07-21 17:33:19 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
2022-05-18 14:40:55 +00:00
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-05-18 14:40:55 +00:00
|
|
|
.with_status(101)
|
2022-05-24 01:15:44 +00:00
|
|
|
.with_stderr(
|
|
|
|
"error: the `-p` argument must be specified in the root of a virtual workspace",
|
|
|
|
)
|
2022-05-18 14:40:55 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-05-26 00:49:06 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn in_virtual_workspace_with_p() {
|
2022-10-07 20:19:40 +00:00
|
|
|
// `publish` generally requires a remote registry
|
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2022-05-26 00:49:06 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["foo","li"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-05-26 00:49:06 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"li/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "li"
|
|
|
|
version = "0.0.1"
|
2023-03-24 20:46:59 +00:00
|
|
|
rust-version = "1.69"
|
2022-05-26 00:49:06 +00:00
|
|
|
description = "li"
|
|
|
|
license = "MIT"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("li/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish -p li --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-05-26 00:49:06 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[WARNING] manifest has no documentation, homepage or repository.
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] li v0.0.1 ([CWD]/li)
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2022-05-26 00:49:06 +00:00
|
|
|
[UPLOADING] li v0.0.1 ([CWD]/li)
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] li v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] li v0.0.1 [..]
|
2022-05-26 00:49:06 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-05-18 14:40:55 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn in_package_workspace_not_found() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2022-05-18 14:40:55 +00:00
|
|
|
|
|
|
|
let p = project()
|
2021-07-21 17:33:19 +00:00
|
|
|
.file(
|
2022-05-18 14:40:55 +00:00
|
|
|
"Cargo.toml",
|
2021-07-21 17:33:19 +00:00
|
|
|
r#"
|
2022-05-18 14:40:55 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
2022-05-23 13:01:55 +00:00
|
|
|
edition = "2021"
|
2022-05-18 14:40:55 +00:00
|
|
|
[workspace]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"li/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "li"
|
2021-07-21 17:33:19 +00:00
|
|
|
version = "0.0.1"
|
2022-05-18 14:40:55 +00:00
|
|
|
edition = "2021"
|
2021-07-21 17:33:19 +00:00
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
2022-05-18 14:40:55 +00:00
|
|
|
description = "li"
|
2021-07-21 17:33:19 +00:00
|
|
|
"#,
|
|
|
|
)
|
2022-05-18 14:40:55 +00:00
|
|
|
.file("li/src/main.rs", "fn main() {}")
|
2021-07-21 17:33:19 +00:00
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish -p li --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-05-18 14:40:55 +00:00
|
|
|
.with_status(101)
|
2021-07-26 19:56:53 +00:00
|
|
|
.with_stderr(
|
2021-07-21 17:33:19 +00:00
|
|
|
"\
|
2022-05-23 13:01:55 +00:00
|
|
|
error: package ID specification `li` did not match any packages
|
|
|
|
|
|
|
|
<tab>Did you mean `foo`?
|
2021-07-26 19:56:53 +00:00
|
|
|
",
|
|
|
|
)
|
2021-07-21 17:33:19 +00:00
|
|
|
.run();
|
2022-05-18 14:40:55 +00:00
|
|
|
}
|
2021-07-21 17:33:19 +00:00
|
|
|
|
2022-05-18 14:40:55 +00:00
|
|
|
#[cargo_test]
|
2022-05-23 13:01:55 +00:00
|
|
|
fn in_package_workspace_found_multiple() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2022-05-18 14:40:55 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
2022-05-23 13:01:55 +00:00
|
|
|
edition = "2021"
|
2022-05-18 14:40:55 +00:00
|
|
|
[workspace]
|
|
|
|
members = ["li","lii"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"li/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "li"
|
|
|
|
version = "0.0.1"
|
|
|
|
edition = "2021"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "li"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("li/src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"lii/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "lii"
|
|
|
|
version = "0.0.1"
|
|
|
|
edition = "2021"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "lii"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("lii/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
2021-07-21 17:33:19 +00:00
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish -p li* --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-05-18 14:40:55 +00:00
|
|
|
.with_status(101)
|
2021-07-26 19:56:53 +00:00
|
|
|
.with_stderr(
|
2021-07-21 17:33:19 +00:00
|
|
|
"\
|
2022-05-23 13:01:55 +00:00
|
|
|
error: the `-p` argument must be specified to select a single package to publish
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
// https://github.com/rust-lang/cargo/issues/10536
|
|
|
|
fn publish_path_dependency_without_workspace() {
|
2022-10-07 20:16:34 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::init();
|
2022-05-23 13:01:55 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
edition = "2021"
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "bar"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
edition = "2021"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "bar"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish -p bar --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-05-23 13:01:55 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: package ID specification `bar` did not match any packages
|
|
|
|
|
|
|
|
<tab>Did you mean `foo`?
|
2021-07-26 19:56:53 +00:00
|
|
|
",
|
|
|
|
)
|
2021-07-21 17:33:19 +00:00
|
|
|
.run();
|
|
|
|
}
|
2022-09-22 16:00:49 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn http_api_not_noop() {
|
2022-08-31 05:53:47 +00:00
|
|
|
let registry = registry::RegistryBuilder::new().http_api().build();
|
2022-09-22 16:00:49 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-10-07 20:00:59 +00:00
|
|
|
[package]
|
2022-09-22 16:00:49 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(registry.index_url())
|
2022-10-07 20:00:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
|
|
|
[..]
|
|
|
|
[..]
|
2022-10-21 03:05:34 +00:00
|
|
|
[..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `crates-io`
|
2023-02-14 20:57:25 +00:00
|
|
|
note: Waiting [..]
|
|
|
|
You may press ctrl-c [..]
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] foo v0.0.1 [..]
|
fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
are propagation delays. This has the side effect of being noisy
because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
didn't seem to be a problem, blocking by default is the less error
prone case, and there doesn't seem to be enough justification for a
"don't block" flag.
The timeout was 5min but I dropped it to 1m. Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.
Fixes #9507
2022-07-21 16:48:29 +00:00
|
|
|
",
|
2022-10-07 20:00:59 +00:00
|
|
|
)
|
2022-08-31 05:53:47 +00:00
|
|
|
.run();
|
2022-09-22 16:00:49 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build").run();
|
|
|
|
}
|
2022-09-08 15:41:54 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
2022-11-02 15:39:21 +00:00
|
|
|
fn wait_for_first_publish() {
|
2022-09-08 15:41:54 +00:00
|
|
|
// Counter for number of tries before the package is "published"
|
|
|
|
let arc: Arc<Mutex<u32>> = Arc::new(Mutex::new(0));
|
|
|
|
let arc2 = arc.clone();
|
|
|
|
|
|
|
|
// Registry returns an invalid response.
|
|
|
|
let registry = registry::RegistryBuilder::new()
|
|
|
|
.http_index()
|
|
|
|
.http_api()
|
|
|
|
.add_responder("/index/de/la/delay", move |req, server| {
|
|
|
|
let mut lock = arc.lock().unwrap();
|
|
|
|
*lock += 1;
|
|
|
|
if *lock <= 1 {
|
|
|
|
server.not_found(req)
|
|
|
|
} else {
|
|
|
|
server.index(req)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "delay"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-10-13 21:00:23 +00:00
|
|
|
p.cargo("publish --no-verify")
|
2022-09-08 15:41:54 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2022-10-24 16:07:02 +00:00
|
|
|
[UPDATING] crates.io index
|
2022-09-08 15:41:54 +00:00
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] delay v0.0.1 ([CWD])
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2022-09-08 15:41:54 +00:00
|
|
|
[UPLOADING] delay v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] delay v0.0.1 to registry `crates-io`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `delay v0.0.1` to be available at registry `crates-io`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] delay v0.0.1 at registry `crates-io`
|
2022-09-08 15:41:54 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.
A step towards #9507
2022-07-21 16:48:29 +00:00
|
|
|
// Verify the responder has been pinged
|
2022-09-08 15:41:54 +00:00
|
|
|
let lock = arc2.lock().unwrap();
|
feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.
A step towards #9507
2022-07-21 16:48:29 +00:00
|
|
|
assert_eq!(*lock, 2);
|
2022-09-08 15:41:54 +00:00
|
|
|
drop(lock);
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
delay = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-10-13 21:00:23 +00:00
|
|
|
p.cargo("build").with_status(0).run();
|
2022-09-08 15:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// A separate test is needed for package names with - or _ as they hit
|
|
|
|
/// the responder twice per cargo invocation. If that ever gets changed
|
|
|
|
/// this test will need to be changed accordingly.
|
|
|
|
#[cargo_test]
|
2022-11-02 15:39:21 +00:00
|
|
|
fn wait_for_first_publish_underscore() {
|
2022-09-08 15:41:54 +00:00
|
|
|
// Counter for number of tries before the package is "published"
|
|
|
|
let arc: Arc<Mutex<u32>> = Arc::new(Mutex::new(0));
|
|
|
|
let arc2 = arc.clone();
|
2023-04-05 20:52:01 +00:00
|
|
|
let misses = Arc::new(Mutex::new(Vec::new()));
|
|
|
|
let misses2 = misses.clone();
|
2022-09-08 15:41:54 +00:00
|
|
|
|
|
|
|
// Registry returns an invalid response.
|
|
|
|
let registry = registry::RegistryBuilder::new()
|
|
|
|
.http_index()
|
|
|
|
.http_api()
|
|
|
|
.add_responder("/index/de/la/delay_with_underscore", move |req, server| {
|
|
|
|
let mut lock = arc.lock().unwrap();
|
|
|
|
*lock += 1;
|
2022-10-31 16:44:01 +00:00
|
|
|
if *lock <= 1 {
|
2022-09-08 15:41:54 +00:00
|
|
|
server.not_found(req)
|
|
|
|
} else {
|
|
|
|
server.index(req)
|
|
|
|
}
|
|
|
|
})
|
2023-04-05 20:52:01 +00:00
|
|
|
.not_found_handler(move |req, _| {
|
|
|
|
misses.lock().unwrap().push(req.url.to_string());
|
|
|
|
Response {
|
|
|
|
body: b"not found".to_vec(),
|
|
|
|
code: 404,
|
|
|
|
headers: vec![],
|
|
|
|
}
|
|
|
|
})
|
2022-09-08 15:41:54 +00:00
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "delay_with_underscore"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-10-13 21:00:23 +00:00
|
|
|
p.cargo("publish --no-verify")
|
2022-09-08 15:41:54 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2022-10-24 16:07:02 +00:00
|
|
|
[UPDATING] crates.io index
|
2022-09-08 15:41:54 +00:00
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] delay_with_underscore v0.0.1 ([CWD])
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
2022-09-08 15:41:54 +00:00
|
|
|
[UPLOADING] delay_with_underscore v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] delay_with_underscore v0.0.1 to registry `crates-io`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `delay_with_underscore v0.0.1` to be available at registry `crates-io`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] delay_with_underscore v0.0.1 at registry `crates-io`
|
2022-09-08 15:41:54 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.
A step towards #9507
2022-07-21 16:48:29 +00:00
|
|
|
// Verify the repsponder has been pinged
|
2022-09-08 15:41:54 +00:00
|
|
|
let lock = arc2.lock().unwrap();
|
2022-10-31 16:44:01 +00:00
|
|
|
assert_eq!(*lock, 2);
|
2022-09-08 15:41:54 +00:00
|
|
|
drop(lock);
|
2023-04-05 20:52:01 +00:00
|
|
|
{
|
|
|
|
let misses = misses2.lock().unwrap();
|
|
|
|
assert!(
|
|
|
|
misses.len() == 1,
|
|
|
|
"should only have 1 not found URL; instead found {misses:?}"
|
|
|
|
);
|
|
|
|
}
|
2022-09-08 15:41:54 +00:00
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
delay_with_underscore = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-10-13 21:00:23 +00:00
|
|
|
p.cargo("build").with_status(0).run();
|
feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.
A step towards #9507
2022-07-21 16:48:29 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 15:39:21 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn wait_for_subsequent_publish() {
|
|
|
|
// Counter for number of tries before the package is "published"
|
|
|
|
let arc: Arc<Mutex<u32>> = Arc::new(Mutex::new(0));
|
|
|
|
let arc2 = arc.clone();
|
2022-11-09 00:14:52 +00:00
|
|
|
let publish_req = Arc::new(Mutex::new(None));
|
|
|
|
let publish_req2 = publish_req.clone();
|
2022-11-02 15:39:21 +00:00
|
|
|
|
|
|
|
let registry = registry::RegistryBuilder::new()
|
|
|
|
.http_index()
|
|
|
|
.http_api()
|
2022-11-09 00:14:52 +00:00
|
|
|
.add_responder("/api/v1/crates/new", move |req, server| {
|
|
|
|
// Capture the publish request, but defer publishing
|
|
|
|
*publish_req.lock().unwrap() = Some(req.clone());
|
|
|
|
server.ok(req)
|
|
|
|
})
|
2022-11-02 15:39:21 +00:00
|
|
|
.add_responder("/index/de/la/delay", move |req, server| {
|
|
|
|
let mut lock = arc.lock().unwrap();
|
|
|
|
*lock += 1;
|
2022-11-09 00:14:52 +00:00
|
|
|
if *lock == 3 {
|
|
|
|
// Run the publish on the 3rd attempt
|
2022-12-13 00:29:37 +00:00
|
|
|
let rep = server
|
|
|
|
.check_authorized_publish(&publish_req2.lock().unwrap().as_ref().unwrap());
|
2022-12-12 17:49:22 +00:00
|
|
|
assert_eq!(rep.code, 200);
|
2022-11-02 15:39:21 +00:00
|
|
|
}
|
2022-11-09 00:14:52 +00:00
|
|
|
server.index(req)
|
2022-11-02 15:39:21 +00:00
|
|
|
})
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// Publish an earlier version
|
|
|
|
Package::new("delay", "0.0.1")
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "delay"
|
|
|
|
version = "0.0.2"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-10-13 21:00:23 +00:00
|
|
|
p.cargo("publish --no-verify")
|
2022-11-02 15:39:21 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] crates.io index
|
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] delay v0.0.2 ([CWD])
|
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
|
|
|
[UPLOADING] delay v0.0.2 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] delay v0.0.2 to registry `crates-io`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `delay v0.0.2` to be available at registry `crates-io`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] delay v0.0.2 at registry `crates-io`
|
2022-11-02 15:39:21 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
// Verify the responder has been pinged
|
|
|
|
let lock = arc2.lock().unwrap();
|
2022-11-02 21:42:14 +00:00
|
|
|
assert_eq!(*lock, 3);
|
2022-11-02 15:39:21 +00:00
|
|
|
drop(lock);
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
delay = "0.0.2"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-14 20:57:25 +00:00
|
|
|
p.cargo("check").with_status(0).run();
|
2022-11-02 15:39:21 +00:00
|
|
|
}
|
|
|
|
|
feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.
A step towards #9507
2022-07-21 16:48:29 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn skip_wait_for_publish() {
|
|
|
|
// Intentionally using local registry so the crate never makes it to the index
|
|
|
|
let registry = registry::init();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
"
|
|
|
|
[publish]
|
|
|
|
timeout = 0
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify -Zpublish-timeout")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.masquerade_as_nightly_cargo(&["publish-timeout"])
|
2022-09-08 15:41:54 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.
A step towards #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPDATING] crates.io index
|
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] foo v0.0.1 ([CWD])
|
2022-10-21 03:05:34 +00:00
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension. When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates. I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check. In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.
This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
into
- crates-index has re-implemented index support incorrectly in the past,
currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
might not be sufficient
- Once the sparse registry is available, crates-index users will find
out when the package is ready in git but it might not be ready through
the sparse registry because of CDNs
This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.
A step towards #9507
2022-07-21 16:48:29 +00:00
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2022-09-08 15:41:54 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2023-02-14 20:55:47 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn timeout_waiting_for_publish() {
|
|
|
|
// Publish doesn't happen within the timeout window.
|
|
|
|
let registry = registry::RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.delayed_index_update(20)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "delay"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(
|
|
|
|
".cargo/config.toml",
|
|
|
|
r#"
|
|
|
|
[publish]
|
|
|
|
timeout = 2
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify -Zpublish-timeout")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.masquerade_as_nightly_cargo(&["publish-timeout"])
|
|
|
|
.with_status(0)
|
2023-02-14 20:57:25 +00:00
|
|
|
.with_stderr(
|
2023-02-14 20:55:47 +00:00
|
|
|
"\
|
|
|
|
[UPDATING] crates.io index
|
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] delay v0.0.1 ([CWD])
|
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
|
|
|
[UPLOADING] delay v0.0.1 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] delay v0.0.1 to registry `crates-io`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `delay v0.0.1` to be available at registry `crates-io`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
warning: timed out waiting for `delay v0.0.1` to be available in registry `crates-io`
|
|
|
|
note: The registry may have a backlog that is delaying making the crate available. The crate should be available soon.
|
2023-02-14 20:55:47 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn wait_for_git_publish() {
|
|
|
|
// Slow publish to an index with a git index.
|
|
|
|
let registry = registry::RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.delayed_index_update(5)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// Publish an earlier version
|
|
|
|
Package::new("delay", "0.0.1")
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "delay"
|
|
|
|
version = "0.0.2"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.with_status(0)
|
2023-02-14 20:57:25 +00:00
|
|
|
.with_stderr(
|
2023-02-14 20:55:47 +00:00
|
|
|
"\
|
|
|
|
[UPDATING] crates.io index
|
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] delay v0.0.2 ([CWD])
|
|
|
|
[PACKAGED] [..] files, [..] ([..] compressed)
|
|
|
|
[UPLOADING] delay v0.0.2 ([CWD])
|
2023-02-17 17:44:53 +00:00
|
|
|
[UPLOADED] delay v0.0.2 to registry `crates-io`
|
2023-02-17 17:50:34 +00:00
|
|
|
note: Waiting for `delay v0.0.2` to be available at registry `crates-io`.
|
2023-02-14 20:57:25 +00:00
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
2023-02-17 17:44:53 +00:00
|
|
|
[PUBLISHED] delay v0.0.2 at registry `crates-io`
|
2023-02-14 20:55:47 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
[dependencies]
|
|
|
|
delay = "0.0.2"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check").with_status(0).run();
|
|
|
|
}
|
2023-04-09 19:15:40 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn invalid_token() {
|
|
|
|
// Checks publish behavior with an invalid token.
|
|
|
|
let registry = RegistryBuilder::new().http_api().http_index().build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --no-verify")
|
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.env("CARGO_REGISTRY_TOKEN", "\x16")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] crates.io index
|
|
|
|
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[PACKAGED] 4 files, [..]
|
|
|
|
[UPLOADING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
error: failed to publish to registry at http://127.0.0.1:[..]/
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
token contains invalid characters.
|
|
|
|
Only printable ISO-8859-1 characters are allowed as it is sent in a HTTPS header.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.with_status(101)
|
|
|
|
.run();
|
|
|
|
}
|
2023-10-04 18:00:37 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn versionless_package() {
|
2023-10-04 17:33:35 +00:00
|
|
|
// Use local registry for faster test times since no publish will occur
|
|
|
|
let registry = registry::init();
|
|
|
|
|
2023-10-04 18:00:37 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
description = "foo"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish")
|
2023-10-04 17:33:35 +00:00
|
|
|
.replace_crates_io(registry.index_url())
|
|
|
|
.with_status(101)
|
2023-10-04 18:00:37 +00:00
|
|
|
.with_stderr(
|
2023-10-04 17:33:35 +00:00
|
|
|
"\
|
2023-10-06 18:01:58 +00:00
|
|
|
error: `foo` cannot be published.
|
|
|
|
`package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
|
2023-10-04 17:33:35 +00:00
|
|
|
",
|
2023-10-04 18:00:37 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|