pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
let pkg = ws.current()?;
- // Allow publishing if a registry has been provided, or if there are no nightly
- // features enabled.
- if opts.registry.is_none() && !pkg.manifest().features().activated().is_empty() {
- bail!("cannot publish crates which activate nightly-only cargo features to crates.io")
- }
-
if let Some(ref allowed_registries) = *pkg.publish() {
if !match opts.registry {
Some(ref registry) => allowed_registries.contains(registry),
use cargotest::ChannelChanger;
-use cargotest::support::{execs, project};
+use cargotest::support::{execs, project, publish};
use hamcrest::assert_that;
#[test]
}
#[test]
-fn publish_rejected() {
+fn publish_allowed() {
+ publish::setup();
+
let p = project("foo")
.file(
"Cargo.toml",
.file("src/lib.rs", "")
.build();
assert_that(
- p.cargo("publish").masquerade_as_nightly_cargo(),
- execs().with_status(101).with_stderr(
- "error: cannot publish crates which activate nightly-only cargo features to crates.io",
- ),
+ p.cargo("publish")
+ .arg("--index")
+ .arg(publish::registry().to_string())
+ .masquerade_as_nightly_cargo(),
+ execs().with_status(0),
);
}