Skip to content

Commit

Permalink
docs: fix tests that fail when the "suggestions" feature is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
tormol committed Oct 16, 2016
1 parent da88fd2 commit 996fc38
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ pub enum ErrorKind {
///
/// # Examples
///
/// ```rust
#[cfg_attr(not(feature="suggestions"), doc=" ```no_run")]
#[cfg_attr( feature="suggestions" , doc=" ```")]
/// # use clap::{App, Arg, ErrorKind, SubCommand};
/// let result = App::new("myprog")
/// .subcommand(SubCommand::with_name("config")
Expand Down
1 change: 1 addition & 0 deletions tests/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ fn require_delims() {
}

#[test]
#[cfg(feature="suggestions")]
fn did_you_mean() {
test::check_err_output(test::complex_app(), "clap-test --optio=foo",
"error: Found argument '--optio' which wasn't expected, or isn't valid in this context
Expand Down
10 changes: 10 additions & 0 deletions tests/possible_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@ include!("../clap-test.rs");

use clap::{App, Arg, ErrorKind};

#[cfg(feature="suggestions")]
static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option <option3>'
\t[values: fast, slow]
\tDid you mean 'slow'?
USAGE:
clap-test --Option <option3>
For more information try --help";
#[cfg(not(feature="suggestions"))]
static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option <option3>'
\t[values: fast, slow]
USAGE:
clap-test --Option <option3>
Expand Down
1 change: 1 addition & 0 deletions tests/subcommands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ fn multiple_aliases() {
}

#[test]
#[cfg(feature="suggestions")]
fn subcmd_did_you_mean_output() {
test::check_err_output(test::complex_app(), "clap-test subcm",
"error: The subcommand 'subcm' wasn't recognized
Expand Down

0 comments on commit 996fc38

Please sign in to comment.