Skip to content

Commit

Permalink
Auto merge of #40 - killercup:feature/no-optional-dev-deps, r=killercup
Browse files Browse the repository at this point in the history
There Can't Be Optional Dev Deps
  • Loading branch information
homu committed Oct 18, 2015
2 parents bc1e40d + 7c68e57 commit 541524e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
11 changes: 0 additions & 11 deletions src/bin/add/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ macro_rules! toml_table {
}
}

/// Errors when parsing CLI arguments
quick_error! {
#[derive(Debug)]
pub enum ArgParseError {
/// Internal error parsing args to TOML
BuildingDependency {
description("Error build a dependency description from arguments")
}
}
}

#[derive(Debug, RustcDecodable)]
/// Docopts input args.
pub struct Args {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/add/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use args::Args;

static USAGE: &'static str = r"
Usage:
cargo add <crate> [--dev|--build] [--ver=<semver>|--git=<uri>|--path=<uri>] [options]
cargo add <crate> [--dev|--build|--optional] [--ver=<semver>|--git=<uri>|--path=<uri>] [options]
cargo add (-h|--help)
cargo add --version
Expand Down
18 changes: 16 additions & 2 deletions tests/cargo-add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,27 @@ fn adds_optional_dep() {
assert_eq!(val.as_bool().expect("optional not a bool"), true);
}

#[test]
#[should_panic]
fn failt_to_add_optional_dev_dep() {
let (_tmpdir, manifest) = clone_out_test("tests/fixtures/add/Cargo.toml.sample");

// dependency not present beforehand
let toml = get_toml(&manifest);
assert!(toml.lookup("dependencies.versioned-package").is_none());

// Fails because optional dependencies must be in `dependencies` table.
execute_command(&["add", "versioned-package", "--ver", ">=0.1.1", "--dev", "--optional"],
&manifest);
}

#[test]
fn no_argument() {
assert_cli!("target/debug/cargo-add", &["add"] => Error 1,
r"Invalid arguments.
Usage:
cargo add <crate> [--dev|--build] [--ver=<semver>|--git=<uri>|--path=<uri>] [options]
cargo add <crate> [--dev|--build|--optional] [--ver=<semver>|--git=<uri>|--path=<uri>] [options]
cargo add (-h|--help)
cargo add --version")
.unwrap();
Expand All @@ -203,7 +217,7 @@ fn unknown_flags() {
r"Unknown flag: '--flag'
Usage:
cargo add <crate> [--dev|--build] [--ver=<semver>|--git=<uri>|--path=<uri>] [options]
cargo add <crate> [--dev|--build|--optional] [--ver=<semver>|--git=<uri>|--path=<uri>] [options]
cargo add (-h|--help)
cargo add --version")
.unwrap();
Expand Down

0 comments on commit 541524e

Please sign in to comment.