all: add tests for usage error exit code

This commit is contained in:
Terts Diepraam
2022-09-10 20:59:42 +02:00
parent 975a1d170d
commit 9177cb7b24
74 changed files with 371 additions and 0 deletions
+5
View File
@@ -12,3 +12,8 @@ fn test_arch_help() {
.succeeds()
.stdout_contains("architecture name");
}
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
+5
View File
@@ -192,3 +192,8 @@ fn test_simple_format() {
.code_is(1)
.stderr_contains("extra operand 'c'");
}
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
+5
View File
@@ -8,6 +8,11 @@ fn test_invalid_option() {
new_ucmd!().arg("-w").arg("/").fails();
}
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
static DIR: &str = "/dev";
// we should always get both arguments, regardless of whether --reference was used
+5
View File
@@ -561,6 +561,11 @@ fn test_no_operands() {
.usage_error("missing operand");
}
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_mode_after_dash_dash() {
let (at, ucmd) = at_and_ucmd!();
+5
View File
@@ -78,6 +78,11 @@ fn test_invalid_option() {
new_ucmd!().arg("-w").arg("-q").arg("/").fails();
}
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_chown_only_owner() {
// test chown username file.txt
+5
View File
@@ -2,6 +2,11 @@
use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(125);
}
#[test]
fn test_missing_operand() {
let result = new_ucmd!().run();
+5
View File
@@ -2,6 +2,11 @@
use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_single_file() {
new_ucmd!()
+5
View File
@@ -2,6 +2,11 @@
use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn ab_no_args() {
new_ucmd!()
+5
View File
@@ -7,6 +7,11 @@ fn generate(from: u32, to: u32) -> String {
(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]
fn test_stdin() {
let (at, mut ucmd) = at_and_ucmd!();
+5
View File
@@ -39,6 +39,11 @@ static COMPLEX_SEQUENCE: &TestedSequence = &TestedSequence {
sequence: "9-,6-7,-2,4",
};
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_byte_sequence() {
for param in ["-b", "--bytes", "--byt"] {
+5
View File
@@ -5,6 +5,11 @@ use crate::common::util::*;
#[cfg(all(unix, not(target_os = "macos")))]
use rust_users::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_date_email() {
for param in ["--rfc-email", "--rfc-e", "-R"] {
+5
View File
@@ -75,6 +75,11 @@ fn build_ascii_block(n: usize) -> Vec<u8> {
(0..=127).cycle().take(n).collect()
}
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
// Sanity Tests
#[test]
fn version() {
+5
View File
@@ -3,6 +3,11 @@ use std::collections::HashSet;
use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_df_compatible_no_size_arg() {
new_ucmd!().arg("-a").succeeds();
+5
View File
@@ -4,6 +4,11 @@ use crate::common::util::*;
extern crate dircolors;
use self::dircolors::{guess_syntax, OutputFmt, StrUtils};
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_shell_syntax() {
use std::env;
+5
View File
@@ -1,5 +1,10 @@
use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_path_with_trailing_slashes() {
new_ucmd!()
+5
View File
@@ -41,6 +41,11 @@ fn _du_basics(s: &str) {
assert_eq!(s, answer);
}
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_du_basics_subdir() {
let ts = TestScenario::new(util_name!());
+5
View File
@@ -5,6 +5,11 @@ use std::env;
use std::path::Path;
use tempfile::tempdir;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(125);
}
#[test]
fn test_env_help() {
new_ucmd!()
+5
View File
@@ -2,6 +2,11 @@ use crate::common::util::*;
use uucore::display::Quotable;
// spell-checker:ignore (ToDO) taaaa tbbbb tcccc
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_with_tab() {
new_ucmd!()
+5
View File
@@ -27,6 +27,11 @@ use self::sieve::Sieve;
const NUM_PRIMES: usize = 10000;
const NUM_TESTS: usize = 100;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_parallel() {
use hex_literal::hex;
+5
View File
@@ -1,5 +1,10 @@
use crate::common::util::*;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_fmt() {
let result = new_ucmd!().arg("one-word-per-line.txt").run();

Some files were not shown because too many files have changed in this diff Show More