all: add tests for usage error exit code

This commit is contained in:
Terts Diepraam 2022-09-10 18:38:14 +02:00
parent 975a1d170d
commit 9177cb7b24
74 changed files with 371 additions and 0 deletions

View file

@ -12,3 +12,8 @@ fn test_arch_help() {
.succeeds() .succeeds()
.stdout_contains("architecture name"); .stdout_contains("architecture name");
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}

View file

@ -192,3 +192,8 @@ fn test_simple_format() {
.code_is(1) .code_is(1)
.stderr_contains("extra operand 'c'"); .stderr_contains("extra operand 'c'");
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}

View file

@ -8,6 +8,11 @@ fn test_invalid_option() {
new_ucmd!().arg("-w").arg("/").fails(); new_ucmd!().arg("-w").arg("/").fails();
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
static DIR: &str = "/dev"; static DIR: &str = "/dev";
// we should always get both arguments, regardless of whether --reference was used // we should always get both arguments, regardless of whether --reference was used

View file

@ -561,6 +561,11 @@ fn test_no_operands() {
.usage_error("missing operand"); .usage_error("missing operand");
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_mode_after_dash_dash() { fn test_mode_after_dash_dash() {
let (at, ucmd) = at_and_ucmd!(); let (at, ucmd) = at_and_ucmd!();

View file

@ -78,6 +78,11 @@ fn test_invalid_option() {
new_ucmd!().arg("-w").arg("-q").arg("/").fails(); new_ucmd!().arg("-w").arg("-q").arg("/").fails();
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_chown_only_owner() { fn test_chown_only_owner() {
// test chown username file.txt // test chown username file.txt

View file

@ -2,6 +2,11 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(125);
}
#[test] #[test]
fn test_missing_operand() { fn test_missing_operand() {
let result = new_ucmd!().run(); let result = new_ucmd!().run();

View file

@ -2,6 +2,11 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_single_file() { fn test_single_file() {
new_ucmd!() new_ucmd!()

View file

@ -2,6 +2,11 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn ab_no_args() { fn ab_no_args() {
new_ucmd!() new_ucmd!()

View file

@ -7,6 +7,11 @@ fn generate(from: u32, to: u32) -> String {
(from..to).fold(String::new(), |acc, v| format!("{}{}\n", acc, v)) (from..to).fold(String::new(), |acc, v| format!("{}{}\n", acc, v))
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_stdin() { fn test_stdin() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -39,6 +39,11 @@ static COMPLEX_SEQUENCE: &TestedSequence = &TestedSequence {
sequence: "9-,6-7,-2,4", sequence: "9-,6-7,-2,4",
}; };
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_byte_sequence() { fn test_byte_sequence() {
for param in ["-b", "--bytes", "--byt"] { for param in ["-b", "--bytes", "--byt"] {

View file

@ -5,6 +5,11 @@ use crate::common::util::*;
#[cfg(all(unix, not(target_os = "macos")))] #[cfg(all(unix, not(target_os = "macos")))]
use rust_users::*; use rust_users::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_date_email() { fn test_date_email() {
for param in ["--rfc-email", "--rfc-e", "-R"] { for param in ["--rfc-email", "--rfc-e", "-R"] {

View file

@ -75,6 +75,11 @@ fn build_ascii_block(n: usize) -> Vec<u8> {
(0..=127).cycle().take(n).collect() (0..=127).cycle().take(n).collect()
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
// Sanity Tests // Sanity Tests
#[test] #[test]
fn version() { fn version() {

View file

@ -3,6 +3,11 @@ use std::collections::HashSet;
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_df_compatible_no_size_arg() { fn test_df_compatible_no_size_arg() {
new_ucmd!().arg("-a").succeeds(); new_ucmd!().arg("-a").succeeds();

View file

@ -4,6 +4,11 @@ use crate::common::util::*;
extern crate dircolors; extern crate dircolors;
use self::dircolors::{guess_syntax, OutputFmt, StrUtils}; use self::dircolors::{guess_syntax, OutputFmt, StrUtils};
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_shell_syntax() { fn test_shell_syntax() {
use std::env; use std::env;

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_path_with_trailing_slashes() { fn test_path_with_trailing_slashes() {
new_ucmd!() new_ucmd!()

View file

@ -41,6 +41,11 @@ fn _du_basics(s: &str) {
assert_eq!(s, answer); assert_eq!(s, answer);
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_du_basics_subdir() { fn test_du_basics_subdir() {
let ts = TestScenario::new(util_name!()); let ts = TestScenario::new(util_name!());

View file

@ -5,6 +5,11 @@ use std::env;
use std::path::Path; use std::path::Path;
use tempfile::tempdir; use tempfile::tempdir;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(125);
}
#[test] #[test]
fn test_env_help() { fn test_env_help() {
new_ucmd!() new_ucmd!()

View file

@ -2,6 +2,11 @@ use crate::common::util::*;
use uucore::display::Quotable; use uucore::display::Quotable;
// spell-checker:ignore (ToDO) taaaa tbbbb tcccc // spell-checker:ignore (ToDO) taaaa tbbbb tcccc
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_with_tab() { fn test_with_tab() {
new_ucmd!() new_ucmd!()

View file

@ -27,6 +27,11 @@ use self::sieve::Sieve;
const NUM_PRIMES: usize = 10000; const NUM_PRIMES: usize = 10000;
const NUM_TESTS: usize = 100; const NUM_TESTS: usize = 100;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_parallel() { fn test_parallel() {
use hex_literal::hex; use hex_literal::hex;

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_fmt() { fn test_fmt() {
let result = new_ucmd!().arg("one-word-per-line.txt").run(); let result = new_ucmd!().arg("one-word-per-line.txt").run();

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_default_80_column_wrap() { fn test_default_80_column_wrap() {
new_ucmd!() new_ucmd!()

View file

@ -9,6 +9,12 @@ use crate::common::util::*;
const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31 const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
#[test]
#[cfg(unix)]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
#[cfg(unix)] #[cfg(unix)]
fn test_groups() { fn test_groups() {

View file

@ -116,3 +116,8 @@ fn test_check_sha1() {
.stdout_is("testf: OK\n") .stdout_is("testf: OK\n")
.stderr_is(""); .stderr_is("");
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}

View file

@ -9,6 +9,11 @@ use crate::common::util::*;
static INPUT: &str = "lorem_ipsum.txt"; static INPUT: &str = "lorem_ipsum.txt";
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_stdin_default() { fn test_stdin_default() {
new_ucmd!() new_ucmd!()

View file

@ -28,3 +28,8 @@ fn test_hostname_full() {
.succeeds() .succeeds()
.stdout_contains(ls_short_res.stdout_str().trim()); .stdout_contains(ls_short_res.stdout_str().trim());
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}

View file

@ -9,6 +9,11 @@ use crate::common::util::*;
const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31 const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
#[cfg(unix)] #[cfg(unix)]
fn test_id_no_specified_user() { fn test_id_no_specified_user() {

View file

@ -9,6 +9,11 @@ use std::process::Command;
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use std::thread::sleep; use std::thread::sleep;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_install_basic() { fn test_install_basic() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -8,6 +8,11 @@ use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
#[cfg(windows)] #[cfg(windows)]
use std::{ffi::OsString, os::windows::ffi::OsStringExt}; use std::{ffi::OsString, os::windows::ffi::OsStringExt};
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn empty_files() { fn empty_files() {
new_ucmd!() new_ucmd!()

View file

@ -45,6 +45,11 @@ impl Drop for Target {
} }
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_kill_list_all_signals() { fn test_kill_list_all_signals() {
// Check for a few signals. Do not try to be comprehensive. // Check for a few signals. Do not try to be comprehensive.

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[cfg(not(target_os = "android"))] #[cfg(not(target_os = "android"))]
#[test] #[test]
fn test_link_existing_file() { fn test_link_existing_file() {

View file

@ -1,6 +1,11 @@
use crate::common::util::*; use crate::common::util::*;
use std::path::PathBuf; use std::path::PathBuf;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_symlink_existing_file() { fn test_symlink_existing_file() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -1,6 +1,11 @@
use crate::common::util::*; use crate::common::util::*;
use std::env; use std::env;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_normal() { fn test_normal() {
let result = new_ucmd!().run(); let result = new_ucmd!().run();

View file

@ -20,6 +20,11 @@ static TEST_DIR11: &str = "mkdir_test11/..";
#[cfg(not(windows))] #[cfg(not(windows))]
static TEST_DIR12: &str = "mkdir_test12"; static TEST_DIR12: &str = "mkdir_test12";
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_mkdir_mkdir() { fn test_mkdir_mkdir() {
new_ucmd!().arg(TEST_DIR1).succeeds(); new_ucmd!().arg(TEST_DIR1).succeeds();

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_create_fifo_missing_operand() { fn test_create_fifo_missing_operand() {
new_ucmd!().fails().stderr_is("mkfifo: missing operand"); new_ucmd!().fails().stderr_is("mkfifo: missing operand");

View file

@ -1,5 +1,11 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
#[cfg(not(windows))]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[cfg(not(windows))] #[cfg(not(windows))]
#[test] #[test]
fn test_mknod_help() { fn test_mknod_help() {

View file

@ -4,6 +4,11 @@ extern crate time;
use self::filetime::*; use self::filetime::*;
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_mv_rename_dir() { fn test_mv_rename_dir() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_stdin_no_newline() { fn test_stdin_no_newline() {
new_ucmd!() new_ucmd!()

View file

@ -5,6 +5,11 @@ use std::thread::sleep;
// because stdin/stdout is not attached to a TTY. // because stdin/stdout is not attached to a TTY.
// All that can be tested is the side-effects. // All that can be tested is the side-effects.
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(125);
}
#[test] #[test]
#[cfg(any( #[cfg(any(
target_os = "linux", target_os = "linux",

View file

@ -1,6 +1,11 @@
// spell-checker:ignore incorrectnumber // spell-checker:ignore incorrectnumber
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_nproc() { fn test_nproc() {
let nproc: u8 = new_ucmd!().succeeds().stdout_str().trim().parse().unwrap(); let nproc: u8 = new_ucmd!().succeeds().stdout_str().trim().parse().unwrap();

View file

@ -2,6 +2,11 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_should_not_round_floats() { fn test_should_not_round_floats() {
new_ucmd!() new_ucmd!()

View file

@ -24,6 +24,11 @@ static ALPHA_OUT: &str = "
// XXX We could do a better job of ensuring that we have a fresh temp dir to ourselves, // XXX We could do a better job of ensuring that we have a fresh temp dir to ourselves,
// not a general one full of other process leftovers. // not a general one full of other process leftovers.
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
// Test that od can read one file and dump with default format // Test that od can read one file and dump with default format
#[test] #[test]
fn test_file() { fn test_file() {

View file

@ -128,6 +128,11 @@ static EXAMPLE_DATA: &[TestData] = &[
}, },
]; ];
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_combine_pairs_of_lines() { fn test_combine_pairs_of_lines() {
for s in ["-s", "--serial"] { for s in ["-s", "--serial"] {

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_default_mode() { fn test_default_mode() {
// test the default mode // test the default mode

View file

@ -12,6 +12,11 @@ use self::uucore::entries::{Locate, Passwd};
extern crate pinky; extern crate pinky;
pub use self::pinky::*; pub use self::pinky::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_capitalize() { fn test_capitalize() {
assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn gnu_ext_disabled_rightward_no_ref() { fn gnu_ext_disabled_rightward_no_ref() {
new_ucmd!() new_ucmd!()

View file

@ -4,6 +4,11 @@ use std::path::PathBuf;
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_default() { fn test_default() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -8,6 +8,11 @@ static NOT_A_DIRECTORY: &str = "Not a directory";
#[cfg(windows)] #[cfg(windows)]
static NOT_A_DIRECTORY: &str = "The directory name is invalid."; static NOT_A_DIRECTORY: &str = "The directory name is invalid.";
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_resolve() { fn test_resolve() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_rm_one_file() { fn test_rm_one_file() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -20,6 +20,11 @@ const NOT_A_DIRECTORY: &str = "The directory name is invalid.";
#[cfg(not(windows))] #[cfg(not(windows))]
const NOT_A_DIRECTORY: &str = "Not a directory"; const NOT_A_DIRECTORY: &str = "Not a directory";
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_rmdir_empty_directory_no_parents() { fn test_rmdir_empty_directory_no_parents() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -2,6 +2,11 @@
use crate::common::util::*; use crate::common::util::*;
use std::io::Read; use std::io::Read;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_hex_rejects_sign_after_identifier() { fn test_hex_rejects_sign_after_identifier() {
new_ucmd!() new_ucmd!()

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_shred_remove() { fn test_shred_remove() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_output_is_random_permutation() { fn test_output_is_random_permutation() {
let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

View file

@ -119,6 +119,11 @@ impl RandomFile {
} }
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_split_default() { fn test_split_default() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -10,6 +10,11 @@ use crate::common::util::*;
extern crate stat; extern crate stat;
pub use self::stat::*; pub use self::stat::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_scanners() { fn test_scanners() {
assert_eq!(Some((-5, 2)), "-5zxc".scan_num::<i32>()); assert_eq!(Some((-5, 2)), "-5zxc".scan_num::<i32>());

View file

@ -2,6 +2,11 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
#[ignore = "Fails because cargo test does not run in a tty"] #[ignore = "Fails because cargo test does not run in a tty"]
fn runs() { fn runs() {

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_bsd_single_file() { fn test_bsd_single_file() {
new_ucmd!() new_ucmd!()

View file

@ -3,6 +3,11 @@ extern crate tempfile;
use std::fs; use std::fs;
use tempfile::tempdir; use tempfile::tempdir;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_sync_default() { fn test_sync_default() {
new_ucmd!().succeeds(); new_ucmd!().succeeds();

View file

@ -1,6 +1,11 @@
// spell-checker:ignore axxbxx bxxaxx axxx axxxx xxaxx xxax xxxxa axyz zyax zyxa // spell-checker:ignore axxbxx bxxaxx axxx axxxx xxaxx xxax xxxxa axyz zyax zyxa
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_stdin_default() { fn test_stdin_default() {
new_ucmd!() new_ucmd!()

View file

@ -30,6 +30,11 @@ static FOLLOW_NAME_SHORT_EXP: &str = "follow_name_short.expected";
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
static FOLLOW_NAME_EXP: &str = "follow_name.expected"; static FOLLOW_NAME_EXP: &str = "follow_name.expected";
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
#[cfg(all(unix, not(target_os = "android")))] // FIXME: fix this test for Android #[cfg(all(unix, not(target_os = "android")))] // FIXME: fix this test for Android
fn test_stdin_default() { fn test_stdin_default() {

View file

@ -6,6 +6,11 @@ use crate::common::util::*;
// spell-checker:ignore nopipe // spell-checker:ignore nopipe
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_tee_processing_multiple_operands() { fn test_tee_processing_multiple_operands() {
// POSIX says: "Processing of at least 13 file operands shall be supported." // POSIX says: "Processing of at least 13 file operands shall be supported."

View file

@ -1,6 +1,11 @@
// spell-checker:ignore dont // spell-checker:ignore dont
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(125);
}
// FIXME: this depends on the system having true and false in PATH // FIXME: this depends on the system having true and false in PATH
// the best solution is probably to generate some test binaries that we can call for any // the best solution is probably to generate some test binaries that we can call for any
// utility that requires executing another program (kill, for instance) // utility that requires executing another program (kill, for instance)

View file

@ -59,6 +59,11 @@ fn str_to_filetime(format: &str, s: &str) -> FileTime {
FileTime::from_unix_time(offset_dt.unix_timestamp(), tm.nanosecond()) FileTime::from_unix_time(offset_dt.unix_timestamp(), tm.nanosecond())
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_touch_default() { fn test_touch_default() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -1,6 +1,11 @@
// spell-checker:ignore aabbaa aabbcc aabc abbb abcc abcdefabcdef abcdefghijk abcdefghijklmn abcdefghijklmnop ABCDEFGHIJKLMNOPQRS abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFZZ abcxyz ABCXYZ abcxyzabcxyz ABCXYZABCXYZ acbdef alnum amzamz AMZXAMZ bbbd cclass cefgm cntrl compl dabcdef dncase Gzabcdefg PQRST upcase wxyzz xdigit xycde xyyye xyyz xyzzzzxyzzzz ZABCDEF Zamz Cdefghijkl Cdefghijklmn // spell-checker:ignore aabbaa aabbcc aabc abbb abcc abcdefabcdef abcdefghijk abcdefghijklmn abcdefghijklmnop ABCDEFGHIJKLMNOPQRS abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFZZ abcxyz ABCXYZ abcxyzabcxyz ABCXYZABCXYZ acbdef alnum amzamz AMZXAMZ bbbd cclass cefgm cntrl compl dabcdef dncase Gzabcdefg PQRST upcase wxyzz xdigit xycde xyyye xyyz xyzzzzxyzzzz ZABCDEF Zamz Cdefghijkl Cdefghijklmn
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_to_upper() { fn test_to_upper() {
new_ucmd!() new_ucmd!()

View file

@ -1,5 +1,9 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_sort_call_graph() { fn test_sort_call_graph() {
new_ucmd!() new_ucmd!()

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_uname() { fn test_uname() {
new_ucmd!().succeeds(); new_ucmd!().succeeds();

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn unexpand_init_0() { fn unexpand_init_0() {
new_ucmd!() new_ucmd!()

View file

@ -9,6 +9,11 @@ static SKIP_CHARS: &str = "skip-chars.txt";
static SKIP_FIELDS: &str = "skip-fields.txt"; static SKIP_FIELDS: &str = "skip-fields.txt";
static SORTED_ZERO_TERMINATED: &str = "sorted-zero-terminated.txt"; static SORTED_ZERO_TERMINATED: &str = "sorted-zero-terminated.txt";
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_stdin_default() { fn test_stdin_default() {
new_ucmd!() new_ucmd!()

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_unlink_file() { fn test_unlink_file() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();

View file

@ -2,6 +2,11 @@ extern crate regex;
use self::regex::Regex; use self::regex::Regex;
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_uptime() { fn test_uptime() {
TestScenario::new(util_name!()) TestScenario::new(util_name!())

View file

@ -1,5 +1,10 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_users_no_arg() { fn test_users_no_arg() {
new_ucmd!().succeeds(); new_ucmd!().succeeds();

View file

@ -2,6 +2,11 @@ use crate::common::util::*;
// spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword weirdchars // spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword weirdchars
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_count_bytes_large_stdin() { fn test_count_bytes_large_stdin() {
for n in [ for n in [

View file

@ -7,6 +7,11 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[cfg(unix)] #[cfg(unix)]
#[test] #[test]
#[ignore = "issue #3219"] #[ignore = "issue #3219"]

View file

@ -5,6 +5,11 @@
use crate::common::util::*; use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
#[cfg(unix)] #[cfg(unix)]
fn test_normal() { fn test_normal() {

View file

@ -28,6 +28,11 @@ fn run(args: &[&str], expected: &[u8]) {
assert_eq!(buf.as_slice(), expected); assert_eq!(buf.as_slice(), expected);
} }
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test] #[test]
fn test_simple() { fn test_simple() {
run(&[], b"y\ny\ny\ny\n"); run(&[], b"y\ny\ny\ny\n");