From 996fc381763a48d125c7ea8a58fed057fd0b4ac6 Mon Sep 17 00:00:00 2001 From: tormol Date: Wed, 5 Oct 2016 20:06:32 +0200 Subject: [PATCH] docs: fix tests that fail when the "suggestions" feature is disabled --- src/errors.rs | 3 ++- tests/opts.rs | 1 + tests/possible_values.rs | 10 ++++++++++ tests/subcommands.rs | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/errors.rs b/src/errors.rs index c704ee7afb8..d8602c4a540 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -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") diff --git a/tests/opts.rs b/tests/opts.rs index 315d31c9855..e9af6276c9c 100644 --- a/tests/opts.rs +++ b/tests/opts.rs @@ -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 diff --git a/tests/possible_values.rs b/tests/possible_values.rs index f5e1fb88700..405438223b0 100644 --- a/tests/possible_values.rs +++ b/tests/possible_values.rs @@ -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 ' \t[values: fast, slow] \tDid you mean 'slow'? +USAGE: + clap-test --Option + +For more information try --help"; +#[cfg(not(feature="suggestions"))] +static PV_ERROR: &'static str = "error: 'slo' isn't a valid value for '--Option ' +\t[values: fast, slow] + + USAGE: clap-test --Option diff --git a/tests/subcommands.rs b/tests/subcommands.rs index 8ac3e69577c..bbde9b00b38 100644 --- a/tests/subcommands.rs +++ b/tests/subcommands.rs @@ -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