2017-12-20 03:37:14 +00:00
|
|
|
use std::fs::{self, File};
|
2018-08-28 09:20:03 +00:00
|
|
|
use std::io::prelude::*;
|
2014-09-09 14:23:09 +00:00
|
|
|
|
2018-12-06 19:17:36 +00:00
|
|
|
use crate::support::git::repo;
|
|
|
|
use crate::support::paths;
|
|
|
|
use crate::support::{basic_manifest, project, publish};
|
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",
|
|
|
|
"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,
|
|
|
|
"vers": "0.0.1"
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"foo-0.0.1.crate",
|
|
|
|
&["Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn validate_upload_foo_clean() {
|
|
|
|
publish::validate_upload(
|
|
|
|
CLEAN_FOO_JSON,
|
|
|
|
"foo-0.0.1.crate",
|
|
|
|
&[
|
|
|
|
"Cargo.toml",
|
|
|
|
"Cargo.toml.orig",
|
|
|
|
"src/main.rs",
|
|
|
|
".cargo_vcs_info.json",
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2014-09-09 14:23:09 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn simple() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2017-06-22 19:32:30 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --no-verify --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `{reg}` 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])
|
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2017-12-20 03:37:14 +00:00
|
|
|
",
|
2018-09-08 02:42:26 +00:00
|
|
|
reg = publish::registry_path().to_str().unwrap()
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn old_token_location() {
|
|
|
|
publish::setup();
|
|
|
|
|
|
|
|
// publish::setup puts a token in this file.
|
|
|
|
fs::remove_file(paths::root().join(".cargo/config")).unwrap();
|
|
|
|
|
|
|
|
let credentials = paths::root().join("home/.cargo/credentials");
|
|
|
|
File::create(credentials)
|
|
|
|
.unwrap()
|
2018-07-25 08:58:40 +00:00
|
|
|
.write_all(br#"token = "api-token""#)
|
2017-12-20 03:37:14 +00:00
|
|
|
.unwrap();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-12-20 03:37:14 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-12-20 03:37:14 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --no-verify --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `{reg}` 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])
|
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2017-06-22 19:32:30 +00:00
|
|
|
",
|
2018-09-08 02:42:26 +00:00
|
|
|
reg = publish::registry_path().to_str().unwrap()
|
2018-12-08 11:19:47 +00:00
|
|
|
))
|
|
|
|
.run();
|
2017-06-22 19:32:30 +00:00
|
|
|
|
2018-12-30 04:46:15 +00:00
|
|
|
validate_upload_foo();
|
2017-06-22 19:32:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-22 20:34:57 +00:00
|
|
|
// TODO: Deprecated
|
|
|
|
// remove once it has been decided --host can be removed
|
2017-06-22 19:32:30 +00:00
|
|
|
#[test]
|
|
|
|
fn simple_with_host() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
2017-06-22 19:32: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#"
|
2014-09-09 14:23:09 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-11-18 12:23:53 +00:00
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --no-verify --host")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-06-22 19:32:30 +00:00
|
|
|
[WARNING] The flag '--host' is no longer valid.
|
|
|
|
|
|
|
|
Previous versions of Cargo accepted this flag, but it is being
|
|
|
|
deprecated. The flag is being renamed to 'index', as the flag
|
2018-03-08 11:12:00 +00:00
|
|
|
wants the location of the index. Please use '--index' instead.
|
2017-06-22 19:47:07 +00:00
|
|
|
|
|
|
|
This will soon become a hard error, so it's either recommended
|
|
|
|
to update to a fixed version or contact the upstream maintainer
|
|
|
|
about this warning.
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `{reg}` index
|
2017-06-22 19:47:07 +00:00
|
|
|
[WARNING] manifest has no documentation, [..]
|
|
|
|
See [..]
|
2018-09-08 02:42:26 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ([CWD])
|
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2017-06-22 19:47:07 +00:00
|
|
|
",
|
2018-09-08 02:42:26 +00:00
|
|
|
reg = publish::registry_path().to_str().unwrap()
|
2018-12-08 11:19:47 +00:00
|
|
|
))
|
|
|
|
.run();
|
2017-06-22 19:47:07 +00:00
|
|
|
|
2018-12-30 04:46:15 +00:00
|
|
|
validate_upload_foo();
|
2017-06-22 19:47:07 +00:00
|
|
|
}
|
|
|
|
|
2017-06-22 20:34:57 +00:00
|
|
|
// TODO: Deprecated
|
|
|
|
// remove once it has been decided --host can be removed
|
2017-06-22 19:47:07 +00:00
|
|
|
#[test]
|
|
|
|
fn simple_with_index_and_host() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
2017-06-22 19:47:07 +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#"
|
2017-06-22 19:47:07 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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:47:07 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --no-verify --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.arg("--host")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-06-22 19:47:07 +00:00
|
|
|
[WARNING] The flag '--host' is no longer valid.
|
|
|
|
|
|
|
|
Previous versions of Cargo accepted this flag, but it is being
|
|
|
|
deprecated. The flag is being renamed to 'index', as the flag
|
2018-03-08 11:12:00 +00:00
|
|
|
wants the location of the index. Please use '--index' instead.
|
2017-06-22 19:32:30 +00:00
|
|
|
|
|
|
|
This will soon become a hard error, so it's either recommended
|
|
|
|
to update to a fixed version or contact the upstream maintainer
|
|
|
|
about this warning.
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `{reg}` index
|
2016-05-20 14:00:15 +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])
|
|
|
|
[UPLOADING] foo v0.0.1 ([CWD])
|
2014-09-09 14:23:09 +00:00
|
|
|
",
|
2018-09-08 02:42:26 +00:00
|
|
|
reg = publish::registry_path().to_str().unwrap()
|
2018-12-08 11:19:47 +00:00
|
|
|
))
|
|
|
|
.run();
|
2014-09-09 14:23:09 +00:00
|
|
|
|
2018-12-30 04:46:15 +00:00
|
|
|
validate_upload_foo();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn git_deps() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2014-09-09 14:23:09 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-11-18 12:23:53 +00:00
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2014-09-09 14:23:09 +00:00
|
|
|
|
|
|
|
[dependencies.foo]
|
|
|
|
git = "git://path/to/nowhere"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish -v --no-verify --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2017-01-27 17:54:43 +00:00
|
|
|
[ERROR] crates cannot be published to crates.io with dependencies sourced from \
|
|
|
|
a repository\neither publish `foo` as its own crate on crates.io and \
|
|
|
|
specify a crates.io version as a dependency or pull it into this \
|
|
|
|
repository and specify it with a path and version\n\
|
|
|
|
(crate `foo` has repository path `git://path/to/nowhere`)\
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn path_dependency_no_version() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2014-09-27 04:14:46 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-11-18 12:23:53 +00:00
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2014-09-27 04:14:46 +00:00
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] all path dependencies must have a version specified when publishing.
|
2014-09-27 04:14:46 +00:00
|
|
|
dependency `bar` does not specify a version
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn unpublishable_crate() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2016-01-23 21:16:30 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = false
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] some crates cannot be published.
|
2016-01-23 21:16:30 +00:00
|
|
|
`foo` is marked as unpublishable
|
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
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn dont_publish_dirty() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().file("bar", "").build();
|
2016-06-10 13:43:34 +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#"
|
2016-06-10 13:43:34 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2016-06-10 13:43:34 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `[..]` 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
|
|
|
|
|
2016-09-03 01:05:26 +00:00
|
|
|
to proceed despite this, 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
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn publish_clean() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2016-06-10 13:43:34 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2016-06-10 13:43:34 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
|
|
|
validate_upload_foo_clean();
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn publish_in_sub_repo() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2016-06-10 13:43:34 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2016-06-10 13:43:34 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.cwd(p.root().join("bar"))
|
|
|
|
.arg("--index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
|
|
|
validate_upload_foo_clean();
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn publish_when_ignored() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2016-06-10 13:43:34 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
|
|
|
publish::validate_upload(
|
|
|
|
CLEAN_FOO_JSON,
|
|
|
|
"foo-0.0.1.crate",
|
|
|
|
&[
|
|
|
|
"Cargo.toml",
|
|
|
|
"Cargo.toml.orig",
|
|
|
|
"src/main.rs",
|
|
|
|
".gitignore",
|
|
|
|
".cargo_vcs_info.json",
|
|
|
|
],
|
|
|
|
);
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn ignore_when_crate_ignored() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2016-06-10 13:43:34 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.nocommit_file("bar/src/main.rs", "fn main() {}");
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.cwd(p.root().join("bar"))
|
|
|
|
.arg("--index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
|
|
|
publish::validate_upload(
|
|
|
|
CLEAN_FOO_JSON,
|
|
|
|
"foo-0.0.1.crate",
|
|
|
|
&["Cargo.toml", "Cargo.toml.orig", "src/main.rs", "baz"],
|
|
|
|
);
|
2016-06-10 13:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn new_crate_rejected() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2016-06-10 13:43:34 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.nocommit_file("src/main.rs", "fn main() {}");
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --index")
|
|
|
|
.arg(publish::registry().to_string())
|
|
|
|
.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
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn dry_run() {
|
2017-08-27 06:49:17 +00:00
|
|
|
publish::setup();
|
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#"
|
2016-07-17 23:43:57 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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")
|
|
|
|
.arg(publish::registry().to_string())
|
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 [..]
|
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
|
2017-08-27 06:49:17 +00:00
|
|
|
assert!(!publish::upload_path().join("api/v1/crates/new").exists());
|
2016-07-17 23:43:57 +00:00
|
|
|
}
|
2017-10-03 08:36:46 +00:00
|
|
|
|
2017-10-31 09:51:37 +00:00
|
|
|
#[test]
|
|
|
|
fn block_publish_feature_not_enabled() {
|
|
|
|
publish::setup();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-10-31 09:51:37 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = [
|
|
|
|
"test"
|
|
|
|
]
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-31 09:51:37 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --registry alternative -Zunstable-options")
|
|
|
|
.masquerade_as_nightly_cargo()
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-10-31 09:51:37 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
the `publish` manifest key is unstable for anything other than a value of true or false
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
feature `alternative-registries` is required
|
|
|
|
|
|
|
|
consider adding `cargo-features = [\"alternative-registries\"]` to the manifest
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-10-31 09:51:37 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 08:36:46 +00:00
|
|
|
#[test]
|
2017-10-31 06:28:09 +00:00
|
|
|
fn registry_not_in_publish_list() {
|
2017-10-03 08:36:46 +00:00
|
|
|
publish::setup();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-10-31 09:51:37 +00:00
|
|
|
cargo-features = ["alternative-registries"]
|
|
|
|
|
2017-10-03 08:36:46 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = [
|
|
|
|
"test"
|
|
|
|
]
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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")
|
|
|
|
.masquerade_as_nightly_cargo()
|
|
|
|
.arg("--registry")
|
|
|
|
.arg("alternative")
|
|
|
|
.arg("-Zunstable-options")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-10-03 08:36:46 +00:00
|
|
|
[ERROR] some crates cannot be published.
|
|
|
|
`foo` is marked as unpublishable
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn publish_empty_list() {
|
|
|
|
publish::setup();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-10-31 09:51:37 +00:00
|
|
|
cargo-features = ["alternative-registries"]
|
|
|
|
|
2017-10-03 08:36:46 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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 --registry alternative -Zunstable-options")
|
|
|
|
.masquerade_as_nightly_cargo()
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-10-03 08:36:46 +00:00
|
|
|
[ERROR] some crates cannot be published.
|
|
|
|
`foo` is marked as unpublishable
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2017-10-31 06:28:09 +00:00
|
|
|
fn publish_allowed_registry() {
|
2017-10-03 08:36:46 +00:00
|
|
|
publish::setup();
|
|
|
|
|
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#"
|
2017-10-31 09:51:37 +00:00
|
|
|
cargo-features = ["alternative-registries"]
|
|
|
|
|
2017-10-03 08:36:46 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
2018-12-30 04:46:15 +00:00
|
|
|
repository = "foo"
|
2017-10-31 06:28:09 +00:00
|
|
|
publish = ["alternative"]
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-03 08:36:46 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --registry alternative -Zunstable-options")
|
|
|
|
.masquerade_as_nightly_cargo()
|
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
|
|
|
validate_upload_foo_clean();
|
2017-10-03 08:36:46 +00:00
|
|
|
}
|
2017-10-31 06:28:09 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn block_publish_no_registry() {
|
|
|
|
publish::setup();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-10-31 09:51:37 +00:00
|
|
|
cargo-features = ["alternative-registries"]
|
|
|
|
|
2017-10-31 06:28:09 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-31 06:28:09 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --registry alternative -Zunstable-options")
|
|
|
|
.masquerade_as_nightly_cargo()
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-10-31 06:28:09 +00:00
|
|
|
[ERROR] some crates cannot be published.
|
|
|
|
`foo` is marked as unpublishable
|
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
|
|
|
}
|