Skip to content

Commit

Permalink
Code review markups.
Browse files Browse the repository at this point in the history
  • Loading branch information
cswindle committed Nov 8, 2017
1 parent 4a302ac commit cb37d33
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
let pkg = ws.current()?;

if let &Some(ref allowed_registries) = pkg.publish() {
if opts.registry.is_none() || !allowed_registries.contains(&opts.registry.clone().unwrap()) {
if !match opts.registry {
Some(ref registry) => allowed_registries.contains(registry),
None => false,
} {
bail!("some crates cannot be published.\n\
`{}` is marked as unpublishable", pkg.name());
}
Expand Down
37 changes: 36 additions & 1 deletion tests/alt-registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn depend_on_alt_registry() {
}

#[test]
fn depend_on_alt_registry_depends_on_same_registry() {
fn depend_on_alt_registry_depends_on_same_registry_no_index() {
let p = project("foo")
.file("Cargo.toml", r#"
cargo-features = ["alternative-registries"]
Expand Down Expand Up @@ -107,6 +107,41 @@ fn depend_on_alt_registry_depends_on_same_registry() {
reg = registry::alt_registry())));
}

#[test]
fn depend_on_alt_registry_depends_on_same_registry() {
let p = project("foo")
.file("Cargo.toml", r#"
cargo-features = ["alternative-registries"]
[project]
name = "foo"
version = "0.0.1"
authors = []
[dependencies.bar]
version = "0.0.1"
registry = "alternative"
"#)
.file("src/main.rs", "fn main() {}")
.build();

Package::new("baz", "0.0.1").alternative(true).publish();
Package::new("bar", "0.0.1").registry_dep("baz", "0.0.1", registry::alt_registry().as_str()).alternative(true).publish();

assert_that(p.cargo("build").masquerade_as_nightly_cargo(),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[DOWNLOADING] [..] v0.0.1 (registry `file://[..]`)
[DOWNLOADING] [..] v0.0.1 (registry `file://[..]`)
[COMPILING] baz v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] secs
",
dir = p.url(),
reg = registry::alt_registry())));
}

#[test]
fn depend_on_alt_registry_depends_on_crates_io() {
let p = project("foo")
Expand Down

0 comments on commit cb37d33

Please sign in to comment.