tests ~ refactor/polish spelling (comments, names, and exceptions)

This commit is contained in:
Roy Ivy III 2021-05-30 00:10:54 -05:00
parent 5c9b474cc8
commit 4e20dedf58
63 changed files with 368 additions and 302 deletions

View file

@ -3,7 +3,7 @@ use uu_factor::numeric;
fn gcd(c: &mut Criterion) {
let inputs = {
// Deterministic RNG; use an explicitely-named RNG to guarantee stability
// Deterministic RNG; use an explicitly-named RNG to guarantee stability
use rand::{RngCore, SeedableRng};
use rand_chacha::ChaCha8Rng;
const SEED: u64 = 0xa_b4d_1dea_dead_cafe;

View file

@ -15,10 +15,10 @@ fn table(c: &mut Criterion) {
CHUNK_SIZE
);
let inputs = {
// Deterministic RNG; use an explicitely-named RNG to guarantee stability
// Deterministic RNG; use an explicitly-named RNG to guarantee stability
use rand::{RngCore, SeedableRng};
use rand_chacha::ChaCha8Rng;
const SEED: u64 = 0xdead_bebe_ea75_cafe;
const SEED: u64 = 0xdead_bebe_ea75_cafe; // spell-checker:disable-line
let mut rng = ChaCha8Rng::seed_from_u64(SEED);
std::iter::repeat_with(move || array_init::<_, _, INPUT_SIZE>(|_| rng.next_u64()))

View file

@ -14,14 +14,14 @@ fn test_encode() {
new_ucmd!()
.pipe_in(input)
.succeeds()
.stdout_only("JBSWY3DPFQQFO33SNRSCC===\n");
.stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); // spell-checker:disable-line
// Using '-' as our file
new_ucmd!()
.arg("-")
.pipe_in(input)
.succeeds()
.stdout_only("JBSWY3DPFQQFO33SNRSCC===\n");
.stdout_only("JBSWY3DPFQQFO33SNRSCC===\n"); // spell-checker:disable-line
}
#[test]
@ -29,13 +29,13 @@ fn test_base32_encode_file() {
new_ucmd!()
.arg("input-simple.txt")
.succeeds()
.stdout_only("JBSWY3DPFQQFO33SNRSCCCQ=\n");
.stdout_only("JBSWY3DPFQQFO33SNRSCCCQ=\n"); // spell-checker:disable-line
}
#[test]
fn test_decode() {
for decode_param in &["-d", "--decode"] {
let input = "JBSWY3DPFQQFO33SNRSCC===\n";
let input = "JBSWY3DPFQQFO33SNRSCC===\n"; // spell-checker:disable-line
new_ucmd!()
.arg(decode_param)
.pipe_in(input)
@ -46,7 +46,7 @@ fn test_decode() {
#[test]
fn test_garbage() {
let input = "aGVsbG8sIHdvcmxkIQ==\0";
let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line
new_ucmd!()
.arg("-d")
.pipe_in(input)
@ -57,7 +57,7 @@ fn test_garbage() {
#[test]
fn test_ignore_garbage() {
for ignore_garbage_param in &["-i", "--ignore-garbage"] {
let input = "JBSWY\x013DPFQ\x02QFO33SNRSCC===\n";
let input = "JBSWY\x013DPFQ\x02QFO33SNRSCC===\n"; // spell-checker:disable-line
new_ucmd!()
.arg("-d")
.arg(ignore_garbage_param)
@ -77,7 +77,7 @@ fn test_wrap() {
.pipe_in(input)
.succeeds()
.stdout_only(
"KRUGKIDROVUWG2ZAMJZG\n653OEBTG66BANJ2W24DT\nEBXXMZLSEB2GQZJANRQX\nU6JAMRXWOLQ=\n",
"KRUGKIDROVUWG2ZAMJZG\n653OEBTG66BANJ2W24DT\nEBXXMZLSEB2GQZJANRQX\nU6JAMRXWOLQ=\n", // spell-checker:disable-line
);
}
}

View file

@ -6,14 +6,14 @@ fn test_encode() {
new_ucmd!()
.pipe_in(input)
.succeeds()
.stdout_only("aGVsbG8sIHdvcmxkIQ==\n");
.stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); // spell-checker:disable-line
// Using '-' as our file
new_ucmd!()
.arg("-")
.pipe_in(input)
.succeeds()
.stdout_only("aGVsbG8sIHdvcmxkIQ==\n");
.stdout_only("aGVsbG8sIHdvcmxkIQ==\n"); // spell-checker:disable-line
}
#[test]
@ -21,13 +21,13 @@ fn test_base64_encode_file() {
new_ucmd!()
.arg("input-simple.txt")
.succeeds()
.stdout_only("SGVsbG8sIFdvcmxkIQo=\n");
.stdout_only("SGVsbG8sIFdvcmxkIQo=\n"); // spell-checker:disable-line
}
#[test]
fn test_decode() {
for decode_param in &["-d", "--decode"] {
let input = "aGVsbG8sIHdvcmxkIQ==";
let input = "aGVsbG8sIHdvcmxkIQ=="; // spell-checker:disable-line
new_ucmd!()
.arg(decode_param)
.pipe_in(input)
@ -38,7 +38,7 @@ fn test_decode() {
#[test]
fn test_garbage() {
let input = "aGVsbG8sIHdvcmxkIQ==\0";
let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line
new_ucmd!()
.arg("-d")
.pipe_in(input)
@ -49,7 +49,7 @@ fn test_garbage() {
#[test]
fn test_ignore_garbage() {
for ignore_garbage_param in &["-i", "--ignore-garbage"] {
let input = "aGVsbG8sIHdvcmxkIQ==\0";
let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line
new_ucmd!()
.arg("-d")
.arg(ignore_garbage_param)
@ -68,6 +68,7 @@ fn test_wrap() {
.arg("20")
.pipe_in(input)
.succeeds()
// spell-checker:disable-next-line
.stdout_only("VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n");
}
}

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) reallylongexecutable
use crate::common::util::*;
#[cfg(any(unix, target_os = "redox"))]
use std::ffi::OsStr;
@ -50,7 +52,7 @@ fn test_remove_suffix() {
}
#[test]
fn test_dont_remove_suffix() {
fn test_do_not_remove_suffix() {
new_ucmd!()
.args(&["/foo/bar/baz", "baz"])
.succeeds()
@ -64,7 +66,7 @@ fn test_multiple_param() {
new_ucmd!()
.args(&[multiple_param, path, path])
.succeeds()
.stdout_only("baz\nbaz\n");
.stdout_only("baz\nbaz\n"); // spell-checker:disable-line
}
}
@ -75,7 +77,7 @@ fn test_suffix_param() {
new_ucmd!()
.args(&[suffix_param, ".exe", path, path])
.succeeds()
.stdout_only("baz\nbaz\n");
.stdout_only("baz\nbaz\n"); // spell-checker:disable-line
}
}

View file

@ -9,11 +9,12 @@ fn test_output_simple() {
new_ucmd!()
.args(&["alpha.txt"])
.succeeds()
.stdout_only("abcde\nfghij\nklmno\npqrst\nuvwxyz\n");
.stdout_only("abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line
}
#[test]
fn test_no_options() {
// spell-checker:disable-next-line
for fixture in &["empty.txt", "alpha.txt", "nonewline.txt"] {
// Give fixture through command line file argument
new_ucmd!()
@ -66,8 +67,8 @@ fn test_fifo_symlink() {
assert!(s.fixtures.is_fifo("dir/pipe"));
// Make cat read the pipe through a symlink
s.fixtures.symlink_file("dir/pipe", "sympipe");
let proc = s.ucmd().args(&["sympipe"]).run_no_wait();
s.fixtures.symlink_file("dir/pipe", "sympipe"); // spell-checker:disable-line
let proc = s.ucmd().args(&["sympipe"]).run_no_wait(); // spell-checker:disable-line
let data = vec_of_size(128 * 1024);
let data2 = data.clone();
@ -110,7 +111,7 @@ fn test_piped_to_regular_file() {
.succeeds();
}
let contents = read_to_string(&file_path).unwrap();
assert_eq!(contents, "abcde\nfghij\nklmno\npqrst\nuvwxyz\n");
assert_eq!(contents, "abcde\nfghij\nklmno\npqrst\nuvwxyz\n"); // spell-checker:disable-line
}
}
@ -169,6 +170,7 @@ fn test_directory() {
fn test_directory_and_file() {
let s = TestScenario::new(util_name!());
s.fixtures.mkdir("test_directory2");
// spell-checker:disable-next-line
for fixture in &["empty.txt", "alpha.txt", "nonewline.txt"] {
s.ucmd()
.args(&["test_directory2", fixture])
@ -190,8 +192,8 @@ fn test_three_directories_and_file_and_stdin() {
"test_directory3/test_directory4",
"alpha.txt",
"-",
"filewhichdoesnotexist.txt",
"nonewline.txt",
"file_which_does_not_exist.txt",
"nonewline.txt", // spell-checker:disable-line
"test_directory3/test_directory5",
"test_directory3/../test_directory3/test_directory5",
"test_directory3",
@ -200,12 +202,13 @@ fn test_three_directories_and_file_and_stdin() {
.fails()
.stderr_is_fixture("three_directories_and_file_and_stdin.stderr.expected")
.stdout_is(
"abcde\nfghij\nklmno\npqrst\nuvwxyz\nstdout bytestext without a trailing newline",
"abcde\nfghij\nklmno\npqrst\nuvwxyz\nstdout bytestext without a trailing newline", // spell-checker:disable-line
);
}
#[test]
fn test_output_multi_files_print_all_chars() {
// spell-checker:disable
new_ucmd!()
.args(&["alpha.txt", "256.txt", "-A", "-n"])
.succeeds()
@ -222,10 +225,12 @@ fn test_output_multi_files_print_all_chars() {
M-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-\
pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?",
);
// spell-checker:enable
}
#[test]
fn test_numbered_lines_no_trailing_newline() {
// spell-checker:disable
new_ucmd!()
.args(&["nonewline.txt", "alpha.txt", "-n"])
.succeeds()
@ -233,6 +238,7 @@ fn test_numbered_lines_no_trailing_newline() {
" 1\ttext without a trailing newlineabcde\n 2\tfghij\n \
3\tklmno\n 4\tpqrst\n 5\tuvwxyz\n",
);
// spell-checker:enable
}
#[test]
@ -310,6 +316,7 @@ fn test_stdin_squeeze_blank() {
#[test]
fn test_stdin_number_non_blank() {
// spell-checker:disable-next-line
for same_param in &["-b", "--number-nonblank"] {
new_ucmd!()
.arg(same_param)
@ -322,6 +329,7 @@ fn test_stdin_number_non_blank() {
#[test]
fn test_non_blank_overrides_number() {
// spell-checker:disable-next-line
for &same_param in &["-b", "--number-nonblank"] {
new_ucmd!()
.args(&[same_param, "-"])

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) nosuchgroup
use crate::common::util::*;
use rust_users::*;

View file

@ -21,7 +21,7 @@ struct TestCase {
after: u32,
}
fn mkfile(file: &str, mode: u32) {
fn make_file(file: &str, mode: u32) {
OpenOptions::new()
.mode(mode)
.create(true)
@ -34,7 +34,7 @@ fn mkfile(file: &str, mode: u32) {
}
fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) {
mkfile(&at.plus_as_string(TEST_FILE), test.before);
make_file(&at.plus_as_string(TEST_FILE), test.before);
let perms = at.metadata(TEST_FILE).permissions().mode();
if perms != test.before {
panic!(
@ -123,6 +123,7 @@ fn test_chmod_octal() {
#[test]
#[allow(clippy::unreadable_literal)]
// spell-checker:disable-next-line
fn test_chmod_ugoa() {
let _guard = UMASK_MUTEX.lock();
@ -283,7 +284,7 @@ fn test_chmod_reference_file() {
},
];
let (at, ucmd) = at_and_ucmd!();
mkfile(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS);
make_file(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS);
run_single_test(&tests[0], at, ucmd);
}
@ -318,10 +319,10 @@ fn test_chmod_recursive() {
at.mkdir("a/b");
at.mkdir("a/b/c");
at.mkdir("z");
mkfile(&at.plus_as_string("a/a"), 0o100444);
mkfile(&at.plus_as_string("a/b/b"), 0o100444);
mkfile(&at.plus_as_string("a/b/c/c"), 0o100444);
mkfile(&at.plus_as_string("z/y"), 0o100444);
make_file(&at.plus_as_string("a/a"), 0o100444);
make_file(&at.plus_as_string("a/b/b"), 0o100444);
make_file(&at.plus_as_string("a/b/c/c"), 0o100444);
make_file(&at.plus_as_string("z/y"), 0o100444);
ucmd.arg("-R")
.arg("--verbose")
@ -351,9 +352,9 @@ fn test_chmod_non_existing_file() {
.arg("-R")
.arg("--verbose")
.arg("-r,a+w")
.arg("dont-exist")
.arg("does-not-exist")
.fails()
.stderr_contains(&"cannot access 'dont-exist': No such file or directory");
.stderr_contains(&"cannot access 'does-not-exist': No such file or directory");
}
#[test]
@ -432,6 +433,7 @@ fn test_chmod_symlink_non_existing_file_recursive() {
.no_stdout();
let expected_stdout = &format!(
// spell-checker:disable-next-line
"mode of '{}' retained as 0755 (rwxr-xr-x)\nneither symbolic link '{}/{}' nor referent has been changed",
test_directory, test_directory, test_symlink
);
@ -473,8 +475,8 @@ fn test_chmod_strip_minus_from_mode() {
("chmod -c -R +w FILE ", "chmod -c -R +w FILE "),
("chmod a=r,=xX FILE", "chmod a=r,=xX FILE"),
(
"chmod -v --reference RFILE -R FILE",
"chmod -v --reference RFILE -R FILE",
"chmod -v --reference REF_FILE -R FILE",
"chmod -v --reference REF_FILE -R FILE",
),
("chmod -Rvc -w-x FILE", "chmod -Rvc w-x FILE"),
("chmod 755 -v FILE", "chmod 755 -v FILE"),

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist groupname notexisting passgrp
use crate::common::util::*;
#[cfg(target_os = "linux")]
use rust_users::get_effective_uid;

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) araba newroot userspec
use crate::common::util::*;
#[test]

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) asdf
use crate::common::util::*;
#[test]
@ -40,7 +42,7 @@ fn test_empty() {
#[test]
fn test_arg_overrides_stdin() {
let (at, mut ucmd) = at_and_ucmd!();
let input = "foobarfoobar";
let input = "foobarfoobar"; // spell-checker:disable-line
at.touch("a");
@ -78,17 +80,17 @@ fn test_invalid_file() {
}
// Make sure crc is correct for files larger than 32 bytes
// but <128 bytes (1 fold pclmul)
// but <128 bytes (1 fold pclmul) // spell-checker:disable-line
#[test]
fn test_crc_for_bigger_than_32_bytes() {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg("chars.txt").succeeds();
let mut stdout_splitted = result.stdout_str().split(' ');
let mut stdout_split = result.stdout_str().split(' ');
let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap();
let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap();
let cksum: i64 = stdout_split.next().unwrap().parse().unwrap();
let bytes_cnt: i64 = stdout_split.next().unwrap().parse().unwrap();
assert_eq!(cksum, 586_047_089);
assert_eq!(bytes_cnt, 16);
@ -100,10 +102,10 @@ fn test_stdin_larger_than_128_bytes() {
let result = ucmd.arg("larger_than_2056_bytes.txt").succeeds();
let mut stdout_splitted = result.stdout_str().split(' ');
let mut stdout_split = result.stdout_str().split(' ');
let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap();
let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap();
let cksum: i64 = stdout_split.next().unwrap().parse().unwrap();
let bytes_cnt: i64 = stdout_split.next().unwrap().parse().unwrap();
assert_eq!(cksum, 945_881_979);
assert_eq!(bytes_cnt, 2058);

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) defaultcheck nocheck
use crate::common::util::*;
#[test]
@ -33,19 +35,19 @@ fn ab_dash_three() {
}
#[test]
fn aempty() {
fn a_empty() {
new_ucmd!()
.args(&["a", "empty"])
.succeeds()
.stdout_only_fixture("aempty.expected");
.stdout_only_fixture("aempty.expected"); // spell-checker:disable-line
}
#[test]
fn emptyempty() {
fn empty_empty() {
new_ucmd!()
.args(&["empty", "empty"])
.succeeds()
.stdout_only_fixture("emptyempty.expected");
.stdout_only_fixture("emptyempty.expected"); // spell-checker:disable-line
}
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
@ -68,8 +70,8 @@ fn output_delimiter_require_arg() {
// even though (info) documentation suggests this is an option
// in latest GNU Coreutils comm, it actually is not.
// this test is essentially an alarm in case someone well-intendingly
// implements it.
// this test is essentially an alarm in case some well-intending
// developer implements it.
//marked as unimplemented as error message not set yet.
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
#[test]

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (flags) reflink (fs) tmpfs
use crate::common::util::*;
#[cfg(not(windows))]
use std::fs::set_permissions;
@ -926,7 +928,7 @@ fn test_cp_archive() {
let (at, mut ucmd) = at_and_ucmd!();
let ts = time::now().to_timespec();
let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32);
// set the file creation/modif an hour ago
// set the file creation/modification an hour ago
filetime::set_file_times(
at.plus_as_string(TEST_HELLO_WORLD_SOURCE),
previous,
@ -1055,7 +1057,7 @@ fn test_cp_preserve_timestamps() {
let (at, mut ucmd) = at_and_ucmd!();
let ts = time::now().to_timespec();
let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32);
// set the file creation/modif an hour ago
// set the file creation/modification an hour ago
filetime::set_file_times(
at.plus_as_string(TEST_HELLO_WORLD_SOURCE),
previous,
@ -1084,11 +1086,11 @@ fn test_cp_preserve_timestamps() {
#[test]
#[cfg(target_os = "linux")]
fn test_cp_dont_preserve_timestamps() {
fn test_cp_no_preserve_timestamps() {
let (at, mut ucmd) = at_and_ucmd!();
let ts = time::now().to_timespec();
let previous = FileTime::from_unix_time(ts.sec as i64 - 3600, ts.nsec as u32);
// set the file creation/modif an hour ago
// set the file creation/modification an hour ago
filetime::set_file_times(
at.plus_as_string(TEST_HELLO_WORLD_SOURCE),
previous,
@ -1181,7 +1183,7 @@ fn test_cp_one_file_system() {
scene.cmd("umount").arg(mountpoint_path).succeeds();
assert!(!at_dst.file_exists(TEST_MOUNT_OTHER_FILESYSTEM_FILE));
// Check if the other files were copied from the source folder hirerarchy
// Check if the other files were copied from the source folder hierarchy
for entry in WalkDir::new(at_src.as_string()) {
let entry = entry.unwrap();
let relative_src = entry

View file

@ -904,7 +904,7 @@ fn test_no_match() {
}
#[test]
fn test_too_small_linenum() {
fn test_too_small_line_num() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/", "10", "/40/"])
.succeeds()
@ -921,7 +921,7 @@ fn test_too_small_linenum() {
}
#[test]
fn test_too_small_linenum_equal() {
fn test_too_small_line_num_equal() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/", "20"])
.succeeds()
@ -937,7 +937,7 @@ fn test_too_small_linenum_equal() {
}
#[test]
fn test_too_small_linenum_elided() {
fn test_too_small_line_num_elided() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "-z", "/20/", "10", "/40/"])
.succeeds()
@ -953,7 +953,7 @@ fn test_too_small_linenum_elided() {
}
#[test]
fn test_too_small_linenum_negative_offset() {
fn test_too_small_line_num_negative_offset() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/-5", "10", "/40/"])
.succeeds()
@ -970,7 +970,7 @@ fn test_too_small_linenum_negative_offset() {
}
#[test]
fn test_too_small_linenum_twice() {
fn test_too_small_line_num_twice() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/", "10", "15", "/40/"])
.succeeds()
@ -988,7 +988,7 @@ fn test_too_small_linenum_twice() {
}
#[test]
fn test_too_small_linenum_repeat() {
fn test_too_small_line_num_repeat() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}"])
.fails()
@ -1020,7 +1020,7 @@ fn test_too_small_linenum_repeat() {
}
#[test]
fn test_linenum_out_of_range1() {
fn test_line_num_out_of_range1() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "100"])
.fails()
@ -1046,7 +1046,7 @@ fn test_linenum_out_of_range1() {
}
#[test]
fn test_linenum_out_of_range2() {
fn test_line_num_out_of_range2() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "100"])
.fails()
@ -1073,7 +1073,7 @@ fn test_linenum_out_of_range2() {
}
#[test]
fn test_linenum_out_of_range3() {
fn test_line_num_out_of_range3() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "40", "{2}"])
.fails()
@ -1100,7 +1100,7 @@ fn test_linenum_out_of_range3() {
}
#[test]
fn test_linenum_out_of_range4() {
fn test_line_num_out_of_range4() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "40", "{*}"])
.fails()
@ -1141,7 +1141,7 @@ fn test_skip_to_match_negative_offset_before_a_match() {
}
#[test]
fn test_skip_to_match_negative_offset_before_a_linenum() {
fn test_skip_to_match_negative_offset_before_a_line_num() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/-10", "15"])
.succeeds()
@ -1247,7 +1247,7 @@ fn test_up_to_match_context_underflow() {
// the offset is out of range because of the first pattern
// NOTE: output different than gnu's: the empty split is written but the rest of the input file is not
#[test]
fn test_linenum_range_with_up_to_match1() {
fn test_line_num_range_with_up_to_match1() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-5"])
.fails()
@ -1277,7 +1277,7 @@ fn test_linenum_range_with_up_to_match1() {
// the offset is out of range because more lines are needed than physically available
// NOTE: output different than gnu's: the empty split is not written but the rest of the input file is
#[test]
fn test_linenum_range_with_up_to_match2() {
fn test_line_num_range_with_up_to_match2() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-15"])
.fails()
@ -1306,7 +1306,7 @@ fn test_linenum_range_with_up_to_match2() {
// NOTE: output different than gnu's: the pattern /10/ is matched but should not
#[test]
fn test_linenum_range_with_up_to_match3() {
fn test_line_num_range_with_up_to_match3() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/10/", "-k"])
.fails()

View file

@ -181,7 +181,7 @@ fn test_date_set_valid_2() {
if get_effective_uid() == 0 {
let result = new_ucmd!()
.arg("--set")
.arg("Sat 20 Mar 2021 14:53:01 AWST")
.arg("Sat 20 Mar 2021 14:53:01 AWST") // spell-checker:disable-line
.fails();
result.no_stdout();
assert!(result.stderr_str().starts_with("date: invalid date "));

View file

@ -30,14 +30,14 @@ fn test_shell_syntax() {
}
#[test]
fn test_strutils() {
fn test_str_utils() {
let s = " asd#zcv #hk\t\n ";
assert_eq!("asd#zcv", s.purify());
let s = "con256asd";
assert!(s.fnmatch("*[2][3-6][5-9]?sd"));
assert!(s.fnmatch("*[2][3-6][5-9]?sd")); // spell-checker:disable-line
let s = "zxc \t\nqwe jlk hjl";
let s = "zxc \t\nqwe jlk hjl"; // spell-checker:disable-line
let (k, v) = s.split_two();
assert_eq!("zxc", k);
assert_eq!("qwe jlk hjl", v);

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (paths) sublink subwords
use crate::common::util::*;
const SUB_DIR: &str = "subdir/deeper";

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) araba merci
use crate::common::util::*;
#[test]
@ -185,9 +187,9 @@ fn test_multiple_hyphen_values() {
#[test]
fn test_hyphen_values_inside_string() {
new_ucmd!()
.arg("'\"\n'CXXFLAGS=-g -O2'\n\"'")
.arg("'\"\n'CXXFLAGS=-g -O2'\n\"'") // spell-checker:disable-line
.succeeds()
.stdout_contains("CXXFLAGS");
.stdout_contains("CXXFLAGS"); // spell-checker:disable-line
}
#[test]

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) bamf chdir
#[cfg(not(windows))]
use std::fs;

View file

@ -6,6 +6,8 @@
// that was distributed with this source code.
#![allow(clippy::unreadable_literal)]
// spell-checker:ignore (methods) hexdigest
use crate::common::util::*;
use std::time::SystemTime;
@ -27,13 +29,13 @@ fn test_first_100000_integers() {
extern crate sha1;
let n_integers = 100_000;
let mut instring = String::new();
let mut input_string = String::new();
for i in 0..=n_integers {
instring.push_str(&(format!("{} ", i))[..]);
input_string.push_str(&(format!("{} ", i))[..]);
}
println!("STDIN='{}'", instring);
let result = new_ucmd!().pipe_in(instring.as_bytes()).succeeds();
println!("STDIN='{}'", input_string);
let result = new_ucmd!().pipe_in(input_string.as_bytes()).succeeds();
// `seq 0 100000 | factor | sha1sum` => "4ed2d8403934fa1c76fe4b84c5d4b8850299c359"
let hash_check = sha1::Sha1::from(result.stdout()).hexdigest();
@ -95,20 +97,20 @@ fn test_random() {
};
// build an input and expected output string from factor
let mut instring = String::new();
let mut outstring = String::new();
let mut input_string = String::new();
let mut output_string = String::new();
for _ in 0..NUM_TESTS {
let (product, factors) = rand_gt(1 << 63);
instring.push_str(&(format!("{} ", product))[..]);
input_string.push_str(&(format!("{} ", product))[..]);
outstring.push_str(&(format!("{}:", product))[..]);
output_string.push_str(&(format!("{}:", product))[..]);
for factor in factors {
outstring.push_str(&(format!(" {}", factor))[..]);
output_string.push_str(&(format!(" {}", factor))[..]);
}
outstring.push('\n');
output_string.push('\n');
}
run(instring.as_bytes(), outstring.as_bytes());
run(input_string.as_bytes(), output_string.as_bytes());
}
#[test]
@ -120,30 +122,30 @@ fn test_random_big() {
println!("rng_seed={:?}", rng_seed);
let mut rng = SmallRng::seed_from_u64(rng_seed);
let bitrange_1 = Uniform::new(14_usize, 51);
let bit_range_1 = Uniform::new(14_usize, 51);
let mut rand_64 = move || {
// first, choose a random number of bits for the first factor
let f_bit_1 = bitrange_1.sample(&mut rng);
let f_bit_1 = bit_range_1.sample(&mut rng);
// how many more bits do we need?
let rem = 64 - f_bit_1;
// we will have a number of additional factors equal to nfacts + 1
// where nfacts is in [0, floor(rem/14) ) NOTE half-open interval
// we will have a number of additional factors equal to n_facts + 1
// where n_facts is in [0, floor(rem/14) ) NOTE half-open interval
// Each prime factor is at least 14 bits, hence floor(rem/14)
let nfacts = Uniform::new(0_usize, rem / 14).sample(&mut rng);
// we have to distribute extrabits among the (nfacts + 1) values
let extrabits = rem - (nfacts + 1) * 14;
let n_factors = Uniform::new(0_usize, rem / 14).sample(&mut rng);
// we have to distribute extra_bits among the (n_facts + 1) values
let extra_bits = rem - (n_factors + 1) * 14;
// (remember, a Range is a half-open interval)
let extrarange = Uniform::new(0_usize, extrabits + 1);
let extra_range = Uniform::new(0_usize, extra_bits + 1);
// to generate an even split of this range, generate n-1 random elements
// in the range, add the desired total value to the end, sort this list,
// and then compute the sequential differences.
let mut f_bits = Vec::new();
for _ in 0..nfacts {
f_bits.push(extrarange.sample(&mut rng));
for _ in 0..n_factors {
f_bits.push(extra_range.sample(&mut rng));
}
f_bits.push(extrabits);
f_bits.push(extra_bits);
f_bits.sort_unstable();
// compute sequential differences here. We leave off the +14 bits
@ -160,59 +162,59 @@ fn test_random_big() {
f_bits.push(f_bit_1 - 14); // index of f_bit_1 in PRIMES_BY_BITS
let f_bits = f_bits;
let mut nbits = 0;
let mut n_bits = 0;
let mut product = 1_u64;
let mut factors = Vec::new();
for bit in f_bits {
assert!(bit < 37);
nbits += 14 + bit;
n_bits += 14 + bit;
let elm = Uniform::new(0, PRIMES_BY_BITS[bit].len()).sample(&mut rng);
let factor = PRIMES_BY_BITS[bit][elm];
factors.push(factor);
product *= factor;
}
assert_eq!(nbits, 64);
assert_eq!(n_bits, 64);
factors.sort_unstable();
(product, factors)
};
let mut instring = String::new();
let mut outstring = String::new();
let mut input_string = String::new();
let mut output_string = String::new();
for _ in 0..NUM_TESTS {
let (product, factors) = rand_64();
instring.push_str(&(format!("{} ", product))[..]);
input_string.push_str(&(format!("{} ", product))[..]);
outstring.push_str(&(format!("{}:", product))[..]);
output_string.push_str(&(format!("{}:", product))[..]);
for factor in factors {
outstring.push_str(&(format!(" {}", factor))[..]);
output_string.push_str(&(format!(" {}", factor))[..]);
}
outstring.push('\n');
output_string.push('\n');
}
run(instring.as_bytes(), outstring.as_bytes());
run(input_string.as_bytes(), output_string.as_bytes());
}
#[test]
fn test_big_primes() {
let mut instring = String::new();
let mut outstring = String::new();
let mut input_string = String::new();
let mut output_string = String::new();
for prime in PRIMES64 {
instring.push_str(&(format!("{} ", prime))[..]);
outstring.push_str(&(format!("{0}: {0}\n", prime))[..]);
input_string.push_str(&(format!("{} ", prime))[..]);
output_string.push_str(&(format!("{0}: {0}\n", prime))[..]);
}
run(instring.as_bytes(), outstring.as_bytes());
run(input_string.as_bytes(), output_string.as_bytes());
}
fn run(instring: &[u8], outstring: &[u8]) {
println!("STDIN='{}'", String::from_utf8_lossy(instring));
println!("STDOUT(expected)='{}'", String::from_utf8_lossy(outstring));
fn run(input_string: &[u8], output_string: &[u8]) {
println!("STDIN='{}'", String::from_utf8_lossy(input_string));
println!("STDOUT(expected)='{}'", String::from_utf8_lossy(output_string));
// now run factor
new_ucmd!()
.pipe_in(instring)
.pipe_in(input_string)
.run()
.stdout_is(String::from_utf8(outstring.to_owned()).unwrap());
.stdout_is(String::from_utf8(output_string.to_owned()).unwrap());
}
const PRIMES_BY_BITS: &[&[u64]] = &[

View file

@ -282,7 +282,7 @@ fn test_backspace_is_not_word_boundary() {
.args(&["-w10", "-s"])
.pipe_in("foobar\x086789abcdef")
.succeeds()
.stdout_is("foobar\x086789a\nbcdef");
.stdout_is("foobar\x086789a\nbcdef"); // spell-checker:disable-line
}
#[test]
@ -291,7 +291,7 @@ fn test_carriage_return_should_be_preserved() {
}
#[test]
fn test_carriage_return_overwrriten_char_should_be_preserved() {
fn test_carriage_return_overwritten_char_should_be_preserved() {
new_ucmd!().pipe_in("x\ry").succeeds().stdout_is("x\ry");
}
@ -308,9 +308,9 @@ fn test_carriage_return_should_reset_column_count() {
fn test_carriage_return_is_not_word_boundary() {
new_ucmd!()
.args(&["-w6", "-s"])
.pipe_in("fizz\rbuzz\rfizzbuzz")
.pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line
.succeeds()
.stdout_is("fizz\rbuzz\rfizzbu\nzz");
.stdout_is("fizz\rbuzz\rfizzbu\nzz"); // spell-checker:disable-line
}
//
@ -496,7 +496,7 @@ fn test_bytewise_backspace_is_not_word_boundary() {
.args(&["-w10", "-s", "-b"])
.pipe_in("foobar\x0889abcdef")
.succeeds()
.stdout_is("foobar\x0889a\nbcdef");
.stdout_is("foobar\x0889a\nbcdef"); // spell-checker:disable-line
}
#[test]
@ -509,7 +509,7 @@ fn test_bytewise_carriage_return_should_be_preserved() {
}
#[test]
fn test_bytewise_carriage_return_overwrriten_char_should_be_preserved() {
fn test_bytewise_carriage_return_overwritten_char_should_be_preserved() {
new_ucmd!()
.arg("-b")
.pipe_in("x\ry")
@ -530,9 +530,9 @@ fn test_bytewise_carriage_return_should_not_reset_column_count() {
fn test_bytewise_carriage_return_is_not_word_boundary() {
new_ucmd!()
.args(&["-w6", "-s", "-b"])
.pipe_in("fizz\rbuzz\rfizzbuzz")
.pipe_in("fizz\rbuzz\rfizzbuzz") // spell-checker:disable-line
.succeeds()
.stdout_is("fizz\rb\nuzz\rfi\nzzbuzz");
.stdout_is("fizz\rb\nuzz\rfi\nzzbuzz"); // spell-checker:disable-line
}
#[test]
fn test_obsolete_syntax() {

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) bogusfile emptyfile
use crate::common::util::*;
static INPUT: &str = "lorem_ipsum.txt";

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) helloworld objdump
use crate::common::util::*;
use filetime::FileTime;
use rust_users::*;

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) autoformat
use crate::common::util::*;
#[test]
@ -141,7 +143,7 @@ fn new_line_separated() {
}
#[test]
fn multitab_character() {
fn tab_multi_character() {
new_ucmd!()
.arg("semicolon_fields_1.txt")
.arg("semicolon_fields_2.txt")

View file

@ -79,9 +79,10 @@ fn test_kill_list_one_signal_from_name() {
#[test]
fn test_kill_set_bad_signal_name() {
// spell-checker:disable-line
new_ucmd!()
.arg("-s")
.arg("IAMNOTASIGNAL")
.arg("IAMNOTASIGNAL") // spell-checker:disable-line
.fails()
.stderr_contains("unknown signal");
}

View file

@ -65,10 +65,10 @@ fn test_symlink_circular() {
}
#[test]
fn test_symlink_dont_overwrite() {
fn test_symlink_do_not_overwrite() {
let (at, mut ucmd) = at_and_ucmd!();
let file = "test_symlink_dont_overwrite";
let link = "test_symlink_dont_overwrite_link";
let file = "test_symlink_do_not_overwrite";
let link = "test_symlink_do_not_overwrite_link";
at.touch(file);
at.touch(link);
@ -120,7 +120,7 @@ fn test_symlink_interactive() {
scene
.ucmd()
.args(&["-i", "-s", file, link])
.pipe_in("Yesh")
.pipe_in("Yesh") // spell-checker:disable-line
.succeeds()
.no_stderr();

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup somefile somegroup somehiddenbackup somehiddenfile
#[cfg(unix)]
extern crate unix_socket;
use crate::common::util::*;
@ -939,7 +941,7 @@ fn test_ls_color() {
let a_with_colors = "\x1b[1;34ma\x1b[0m";
let z_with_colors = "\x1b[1;34mz\x1b[0m";
let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m";
let nested_dir_with_colors = "\x1b[1;34mnested_dir\x1b[0m"; // spell-checker:disable-line
// Color is disabled by default
let result = scene.ucmd().succeeds();

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) gpghome
use crate::common::util::*;
use std::path::PathBuf;
@ -8,8 +10,8 @@ static TEST_TEMPLATE2: &str = "temp";
static TEST_TEMPLATE3: &str = "tempX";
static TEST_TEMPLATE4: &str = "tempXX";
static TEST_TEMPLATE5: &str = "tempXXX";
static TEST_TEMPLATE6: &str = "tempXXXlate";
static TEST_TEMPLATE7: &str = "XXXtemplate";
static TEST_TEMPLATE6: &str = "tempXXXlate"; // spell-checker:disable-line
static TEST_TEMPLATE7: &str = "XXXtemplate"; // spell-checker:disable-line
#[cfg(unix)]
static TEST_TEMPLATE8: &str = "tempXXXl/ate";
#[cfg(windows)]

View file

@ -10,7 +10,7 @@ fn test_more_no_arg() {
#[test]
fn test_more_dir_arg() {
// Run the test only if there's a valud terminal, else do nothing
// Run the test only if there's a valid terminal, else do nothing
// Maybe we could capture the error, i.e. "Device not found" in that case
// but I am leaving this for later
if atty::is(atty::Stream::Stdout) {

View file

@ -171,7 +171,7 @@ fn test_mv_interactive() {
.arg("-i")
.arg(file_a)
.arg(file_b)
.pipe_in("Yesh")
.pipe_in("Yesh") // spell-checker:disable-line
.succeeds()
.no_stderr();

View file

@ -17,7 +17,7 @@ fn test_negative_adjustment() {
let res = new_ucmd!().args(&["-n", "-1", "true"]).run();
assert!(res
.stderr_str()
.starts_with("nice: warning: setpriority: Permission denied"));
.starts_with("nice: warning: setpriority: Permission denied")); // spell-checker:disable-line
}
#[test]

View file

@ -1,7 +1,7 @@
use crate::common::util::*;
#[test]
fn test_stdin_nonewline() {
fn test_stdin_no_newline() {
new_ucmd!()
.pipe_in("No Newline")
.run()
@ -41,6 +41,7 @@ fn test_padding_with_overflow() {
#[test]
fn test_sections_and_styles() {
// spell-checker:disable
for &(fixture, output) in &[
(
"section.txt",
@ -63,4 +64,5 @@ fn test_sections_and_styles() {
.run()
.stdout_is(output);
}
// spell-checker:enable
}

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (paths) gnutest
use crate::common::util::*;
#[test]
@ -231,7 +233,7 @@ fn test_should_skip_leading_space_from_stdin() {
.run()
.stdout_is("2048\n");
// multiline
// multi-line
new_ucmd!()
.args(&["--from=auto"])
.pipe_in("\t1Ki\n 2K")

View file

@ -8,7 +8,7 @@ use std::fs::File;
use std::io::Write;
use std::path::Path;
// octal dump of 'abcdefghijklmnopqrstuvwxyz\n'
// octal dump of 'abcdefghijklmnopqrstuvwxyz\n' // spell-checker:disable-line
static ALPHA_OUT: &str = "
0000000 061141 062143 063145 064147 065151 066153 067155 070157
0000020 071161 072163 073165 074167 075171 000012
@ -16,7 +16,7 @@ static ALPHA_OUT: &str = "
";
// 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 proc's leftovers.
// not a general one full of other process leftovers.
// Test that od can read one file and dump with default format
#[test]
@ -29,6 +29,7 @@ fn test_file() {
{
let mut f = File::create(&file).unwrap();
// spell-checker:disable-next-line
if f.write_all(b"abcdefghijklmnopqrstuvwxyz\n").is_err() {
panic!("Test setup failed - could not write file");
}
@ -55,6 +56,7 @@ fn test_2files() {
println!("number: {} letter:{}", n, a);
}
// spell-checker:disable-next-line
for &(path, data) in &[(&file1, "abcdefghijklmnop"), (&file2, "qrstuvwxyz\n")] {
let mut f = File::create(&path).unwrap();
if f.write_all(data.as_bytes()).is_err() {
@ -79,7 +81,7 @@ fn test_2files() {
fn test_no_file() {
let temp = env::temp_dir();
let tmpdir = Path::new(&temp);
let file = tmpdir.join("}surely'none'would'thus'a'file'name");
let file = tmpdir.join("}surely'none'would'thus'a'file'name"); // spell-checker:disable-line
new_ucmd!().arg(file.as_os_str()).fails();
}
@ -87,7 +89,7 @@ fn test_no_file() {
// Test that od reads from stdin instead of a file
#[test]
fn test_from_stdin() {
let input = "abcdefghijklmnopqrstuvwxyz\n";
let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line
new_ucmd!()
.arg("--endian=little")
.run_piped_stdin(input.as_bytes())
@ -104,6 +106,7 @@ fn test_from_mixed() {
let file1 = tmpdir.join("test-1");
let file3 = tmpdir.join("test-3");
// spell-checker:disable-next-line
let (data1, data2, data3) = ("abcdefg", "hijklmnop", "qrstuvwxyz\n");
for &(path, data) in &[(&file1, data1), (&file3, data3)] {
let mut f = File::create(&path).unwrap();
@ -125,7 +128,7 @@ fn test_from_mixed() {
#[test]
fn test_multiple_formats() {
let input = "abcdefghijklmnopqrstuvwxyz\n";
let input = "abcdefghijklmnopqrstuvwxyz\n"; // spell-checker:disable-line
new_ucmd!()
.arg("-c")
.arg("-b")
@ -145,6 +148,7 @@ fn test_multiple_formats() {
#[test]
fn test_dec() {
// spell-checker:ignore (words) 0xffu8 xffu
let input = [
0u8, 0u8, 1u8, 0u8, 2u8, 0u8, 3u8, 0u8, 0xffu8, 0x7fu8, 0x00u8, 0x80u8, 0x01u8, 0x80u8,
];
@ -166,12 +170,14 @@ fn test_dec() {
#[test]
fn test_hex16() {
let input: [u8; 9] = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xff];
// spell-checker:disable
let expected_output = unindent(
"
0000000 2301 6745 ab89 efcd 00ff
0000011
",
);
// spell-checker:enable
new_ucmd!()
.arg("--endian=little")
.arg("-x")
@ -288,7 +294,7 @@ fn test_multibyte() {
new_ucmd!()
.arg("-c")
.arg("-w12")
.run_piped_stdin("Universität Tübingen \u{1B000}".as_bytes())
.run_piped_stdin("Universität Tübingen \u{1B000}".as_bytes()) // spell-checker:disable-line
.success()
.no_stderr()
.stdout_is(unindent(
@ -487,7 +493,7 @@ fn test_alignment_Fx() {
}
#[test]
fn test_maxuint() {
fn test_max_uint() {
let input = [0xFFu8; 8];
let expected_output = unindent(
"
@ -505,7 +511,7 @@ fn test_maxuint() {
new_ucmd!()
.arg("--format=o8")
.arg("-Oobtu8")
.arg("-Oobtu8") // spell-checker:disable-line
.arg("-Dd")
.arg("--format=u1")
.run_piped_stdin(&input[..])
@ -583,7 +589,7 @@ fn test_invalid_offset() {
#[test]
fn test_skip_bytes() {
let input = "abcdefghijklmnopq";
let input = "abcdefghijklmnopq"; // spell-checker:disable-line
new_ucmd!()
.arg("-c")
.arg("--skip-bytes=5")
@ -609,7 +615,7 @@ fn test_skip_bytes_error() {
#[test]
fn test_read_bytes() {
let input = "abcdefghijklmnopqrstuvwxyz\n12345678";
let input = "abcdefghijklmnopqrstuvwxyz\n12345678"; // spell-checker:disable-line
new_ucmd!()
.arg("--endian=little")
.arg("--read-bytes=27")
@ -626,7 +632,7 @@ fn test_ascii_dump() {
0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff,
];
new_ucmd!()
.arg("-tx1zacz")
.arg("-tx1zacz") // spell-checker:disable-line
.run_piped_stdin(&input[..])
.no_stderr()
.success()
@ -645,7 +651,7 @@ fn test_ascii_dump() {
#[test]
fn test_filename_parsing() {
// files "a" and "x" both exists, but are no filenames in the commandline below
// files "a" and "x" both exists, but are no filenames in the command line below
// "-f" must be treated as a filename, it contains the text: minus lowercase f
// so "-f" should not be interpreted as a formatting option.
new_ucmd!()
@ -668,7 +674,7 @@ fn test_filename_parsing() {
#[test]
fn test_stdin_offset() {
let input = "abcdefghijklmnopq";
let input = "abcdefghijklmnopq"; // spell-checker:disable-line
new_ucmd!()
.arg("-c")
.arg("+5")
@ -703,7 +709,7 @@ fn test_file_offset() {
#[test]
fn test_traditional() {
// note gnu od does not align both lines
let input = "abcdefghijklmnopq";
let input = "abcdefghijklmnopq"; // spell-checker:disable-line
new_ucmd!()
.arg("--traditional")
.arg("-a")
@ -726,7 +732,7 @@ fn test_traditional() {
#[test]
fn test_traditional_with_skip_bytes_override() {
// --skip-bytes is ignored in this case
let input = "abcdefghijklmnop";
let input = "abcdefghijklmnop"; // spell-checker:disable-line
new_ucmd!()
.arg("--traditional")
.arg("--skip-bytes=10")
@ -746,7 +752,7 @@ fn test_traditional_with_skip_bytes_override() {
#[test]
fn test_traditional_with_skip_bytes_non_override() {
// no offset specified in the traditional way, so --skip-bytes is used
let input = "abcdefghijklmnop";
let input = "abcdefghijklmnop"; // spell-checker:disable-line
new_ucmd!()
.arg("--traditional")
.arg("--skip-bytes=10")
@ -776,7 +782,7 @@ fn test_traditional_error() {
#[test]
fn test_traditional_only_label() {
let input = "abcdefghijklmnopqrstuvwxyz";
let input = "abcdefghijklmnopqrstuvwxyz"; // spell-checker:disable-line
new_ucmd!()
.arg("-An")
.arg("--traditional")

View file

@ -9,24 +9,24 @@ pub use self::pinky::*;
#[test]
fn test_capitalize() {
assert_eq!("Zbnmasd", "zbnmasd".capitalize());
assert_eq!("Abnmasd", "Abnmasd".capitalize());
assert_eq!("1masd", "1masd".capitalize());
assert_eq!("Zbnmasd", "zbnmasd".capitalize()); // spell-checker:disable-line
assert_eq!("Abnmasd", "Abnmasd".capitalize()); // spell-checker:disable-line
assert_eq!("1masd", "1masd".capitalize()); // spell-checker:disable-line
assert_eq!("", "".capitalize());
}
#[test]
fn test_long_format() {
let ulogin = "root";
let pw: Passwd = Passwd::locate(ulogin).unwrap();
let login = "root";
let pw: Passwd = Passwd::locate(login).unwrap();
let real_name = pw.user_info().replace("&", &pw.name().capitalize());
new_ucmd!()
.arg("-l")
.arg(ulogin)
.arg(login)
.succeeds()
.stdout_is(format!(
"Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n\n",
ulogin,
login,
real_name,
pw.user_dir(),
pw.user_shell()
@ -34,11 +34,11 @@ fn test_long_format() {
new_ucmd!()
.arg("-lb")
.arg(ulogin)
.arg(login)
.succeeds()
.stdout_is(format!(
"Login name: {:<28}In real life: {1}\n\n",
ulogin, real_name
login, real_name
));
}

View file

@ -43,12 +43,12 @@ fn escaped_octal() {
}
#[test]
fn escaped_unicode_fourdigit() {
fn escaped_unicode_four_digit() {
new_ucmd!().args(&["\\u0125"]).succeeds().stdout_only("ĥ");
}
#[test]
fn escaped_unicode_eightdigit() {
fn escaped_unicode_eight_digit() {
new_ucmd!()
.args(&["\\U00000125"])
.succeeds()
@ -77,7 +77,7 @@ fn sub_string() {
}
#[test]
fn sub_multifield() {
fn sub_multi_field() {
new_ucmd!()
.args(&["%s %s", "hello", "world"])
.succeeds()
@ -85,7 +85,7 @@ fn sub_multifield() {
}
#[test]
fn sub_repeat_formatstr() {
fn sub_repeat_format_str() {
new_ucmd!()
.args(&["%s.", "hello", "world"])
.succeeds()
@ -101,7 +101,7 @@ fn sub_string_ignore_escapes() {
}
#[test]
fn sub_bstring_handle_escapes() {
fn sub_b_string_handle_escapes() {
new_ucmd!()
.args(&["hello %b", "\\tworld"])
.succeeds()
@ -109,7 +109,7 @@ fn sub_bstring_handle_escapes() {
}
#[test]
fn sub_bstring_ignore_subs() {
fn sub_b_string_ignore_subs() {
new_ucmd!()
.args(&["hello %b", "world %% %i"])
.succeeds()
@ -133,7 +133,7 @@ fn sub_num_int() {
}
#[test]
fn sub_num_int_minwidth() {
fn sub_num_int_min_width() {
new_ucmd!()
.args(&["twenty is %1i", "20"])
.succeeds()
@ -181,11 +181,11 @@ fn sub_num_int_hex_in_neg() {
}
#[test]
fn sub_num_int_charconst_in() {
fn sub_num_int_char_const_in() {
new_ucmd!()
.args(&["ninetyseven is %i", "'a"])
.args(&["ninety seven is %i", "'a"])
.succeeds()
.stdout_only("ninetyseven is 97");
.stdout_only("ninety seven is 97");
}
#[test]
@ -287,7 +287,7 @@ fn sub_num_hex_float_upper() {
}
#[test]
fn sub_minwidth() {
fn sub_min_width() {
new_ucmd!()
.args(&["hello %7s", "world"])
.succeeds()
@ -295,7 +295,7 @@ fn sub_minwidth() {
}
#[test]
fn sub_minwidth_negative() {
fn sub_min_width_negative() {
new_ucmd!()
.args(&["hello %-7s", "world"])
.succeeds()
@ -327,7 +327,7 @@ fn sub_int_leading_zeroes() {
}
#[test]
fn sub_int_leading_zeroes_prio() {
fn sub_int_leading_zeroes_padded() {
new_ucmd!()
.args(&["%5.4i", "11"])
.succeeds()
@ -359,7 +359,7 @@ fn sub_float_no_octal_in() {
}
#[test]
fn sub_any_asterisk_firstparam() {
fn sub_any_asterisk_first_param() {
new_ucmd!()
.args(&["%*i", "3", "11", "4", "12"])
.succeeds()
@ -401,7 +401,7 @@ fn sub_any_asterisk_hex_arg() {
#[test]
fn sub_any_specifiers_no_params() {
new_ucmd!()
.args(&["%ztlhLji", "3"])
.args(&["%ztlhLji", "3"]) //spell-checker:disable-line
.succeeds()
.stdout_only("3");
}
@ -409,7 +409,7 @@ fn sub_any_specifiers_no_params() {
#[test]
fn sub_any_specifiers_after_first_param() {
new_ucmd!()
.args(&["%0ztlhLji", "3"])
.args(&["%0ztlhLji", "3"]) //spell-checker:disable-line
.succeeds()
.stdout_only("3");
}
@ -417,7 +417,7 @@ fn sub_any_specifiers_after_first_param() {
#[test]
fn sub_any_specifiers_after_period() {
new_ucmd!()
.args(&["%0.ztlhLji", "3"])
.args(&["%0.ztlhLji", "3"]) //spell-checker:disable-line
.succeeds()
.stdout_only("3");
}
@ -425,7 +425,7 @@ fn sub_any_specifiers_after_period() {
#[test]
fn sub_any_specifiers_after_second_param() {
new_ucmd!()
.args(&["%0.0ztlhLji", "3"])
.args(&["%0.0ztlhLji", "3"]) //spell-checker:disable-line
.succeeds()
.stdout_only("3");
}

View file

@ -1,43 +1,43 @@
use crate::common::util::*;
#[test]
fn gnu_ext_disabled_roff_no_ref() {
fn gnu_ext_disabled_rightward_no_ref() {
new_ucmd!()
.args(&["-G", "-R", "input"])
.succeeds()
.stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected");
.stdout_only_fixture("gnu_ext_disabled_rightward_no_ref.expected");
}
#[test]
fn gnu_ext_disabled_roff_no_ref_empty_word_regexp() {
fn gnu_ext_disabled_rightward_no_ref_empty_word_regexp() {
new_ucmd!()
.args(&["-G", "-R", "-W", "", "input"])
.succeeds()
.stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected");
.stdout_only_fixture("gnu_ext_disabled_rightward_no_ref.expected");
}
#[test]
fn gnu_ext_disabled_roff_no_ref_word_regexp_exc_space() {
fn gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space() {
new_ucmd!()
.args(&["-G", "-R", "-W", "[^\t\n]+", "input"])
.succeeds()
.stdout_only_fixture("gnu_ext_disabled_roff_no_ref_word_regexp_exc_space.expected");
.stdout_only_fixture("gnu_ext_disabled_rightward_no_ref_word_regexp_exc_space.expected");
}
#[test]
fn gnu_ext_disabled_roff_input_ref() {
fn gnu_ext_disabled_rightward_input_ref() {
new_ucmd!()
.args(&["-G", "-r", "-R", "input"])
.succeeds()
.stdout_only_fixture("gnu_ext_disabled_roff_input_ref.expected");
.stdout_only_fixture("gnu_ext_disabled_rightward_input_ref.expected");
}
#[test]
fn gnu_ext_disabled_roff_auto_ref() {
fn gnu_ext_disabled_rightward_auto_ref() {
new_ucmd!()
.args(&["-G", "-A", "-R", "input"])
.succeeds()
.stdout_only_fixture("gnu_ext_disabled_roff_auto_ref.expected");
.stdout_only_fixture("gnu_ext_disabled_rightward_auto_ref.expected");
}
#[test]

View file

@ -9,5 +9,5 @@ fn test_default() {
#[test]
fn test_failed() {
let (_at, mut ucmd) = at_and_ucmd!();
ucmd.arg("willfail").fails();
ucmd.arg("will-fail").fails();
}

View file

@ -115,12 +115,12 @@ fn test_relpath_with_from_with_d() {
#[cfg(not(windows))]
assert!(Path::new(&_result_stdout).is_relative());
// d is not part of subpath -> expect absolut path
// d is not part of subpath -> expect absolute path
_result_stdout = scene
.ucmd()
.arg(to)
.arg(from)
.arg("-dnon_existing")
.arg("-dnon_existing") // spell-checker:disable-line
.succeeds()
.stdout_move_str();
assert!(Path::new(&_result_stdout).is_absolute());
@ -166,11 +166,11 @@ fn test_relpath_no_from_with_d() {
#[cfg(not(windows))]
assert!(Path::new(&_result_stdout).is_relative());
// d is not part of subpath -> expect absolut path
// d is not part of subpath -> expect absolute path
let result_stdout = scene
.ucmd()
.arg(to)
.arg("-dnon_existing")
.arg("-dnon_existing") // spell-checker:disable-line
.succeeds()
.stdout_move_str();
assert!(Path::new(&result_stdout).is_absolute());

View file

@ -65,7 +65,7 @@ fn test_rm_interactive() {
.arg("-i")
.arg(file_a)
.arg(file_b)
.pipe_in("Yesh")
.pipe_in("Yesh") // spell-checker:disable-line
.succeeds();
assert!(!at.file_exists(file_a));

View file

@ -19,7 +19,7 @@ fn test_output_is_random_permutation() {
.map(|x| x.parse().unwrap())
.collect();
result_seq.sort_unstable();
assert_ne!(result.stdout_str(), input, "Output is not randomised");
assert_ne!(result.stdout_str(), input, "Output is not randomized");
assert_eq!(result_seq, input_seq, "Output is not a permutation");
}

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (words) ints
use crate::common::util::*;
fn test_helper(file_name: &str, possible_args: &[&str]) {
@ -61,7 +63,7 @@ fn test_ext_sort_stable() {
}
#[test]
fn test_extsort_zero_terminated() {
fn test_ext_sort_zero_terminated() {
new_ucmd!()
.arg("-z")
.arg("-S")
@ -96,7 +98,7 @@ fn test_human_numeric_whitespace() {
// This tests where serde often fails when reading back JSON
// if it finds a null value
#[test]
fn test_extsort_as64_bailout() {
fn test_ext_sort_as64_bailout() {
new_ucmd!()
.arg("-g")
.arg("-S 5K")
@ -290,10 +292,10 @@ fn test_dictionary_order() {
fn test_dictionary_order2() {
for non_dictionary_order2_param in &["-d"] {
new_ucmd!()
.pipe_in("a👦🏻aa b\naaaa b")
.arg(non_dictionary_order2_param)
.pipe_in("a👦🏻aa b\naaaa b") // spell-checker:disable-line
.arg(non_dictionary_order2_param) // spell-checker:disable-line
.succeeds()
.stdout_only("a👦🏻aa b\naaaa b\n");
.stdout_only("a👦🏻aa b\naaaa b\n"); // spell-checker:disable-line
}
}
@ -301,10 +303,10 @@ fn test_dictionary_order2() {
fn test_non_printing_chars() {
for non_printing_chars_param in &["-i"] {
new_ucmd!()
.pipe_in("a👦🏻aa\naaaa")
.arg(non_printing_chars_param)
.pipe_in("a👦🏻aa\naaaa") // spell-checker:disable-line
.arg(non_printing_chars_param) // spell-checker:disable-line
.succeeds()
.stdout_only("a👦🏻aa\naaaa\n");
.stdout_only("a👦🏻aa\naaaa\n"); // spell-checker:disable-line
}
}
@ -592,7 +594,7 @@ fn test_keys_ignore_flag() {
}
#[test]
fn test_doesnt_inherit_key_settings() {
fn test_does_not_inherit_key_settings() {
let input = " 1
2
10

View file

@ -242,7 +242,7 @@ fn test_filter() {
.succeeds();
// assert all characters are 'i' / no character is not 'i'
// (assert that command succeded)
// (assert that command succeeded)
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
assert!(
glob.collate().iter().find(|&&c| {
@ -265,7 +265,7 @@ fn test_filter_with_env_var_set() {
let n_lines = 3;
RandomFile::new(&at, name).add_lines(n_lines);
let env_var_value = "somevalue";
let env_var_value = "some-value";
env::set_var("FILE", &env_var_value);
ucmd.args(&[format!("--filter={}", "cat > $FILE").as_str(), name])
.succeeds();

View file

@ -6,20 +6,20 @@ extern crate stat;
pub use self::stat::*;
#[test]
fn test_scanutil() {
fn test_scanners() {
assert_eq!(Some((-5, 2)), "-5zxc".scan_num::<i32>());
assert_eq!(Some((51, 2)), "51zxc".scan_num::<u32>());
assert_eq!(Some((192, 4)), "+192zxc".scan_num::<i32>());
assert_eq!(None, "z192zxc".scan_num::<i32>());
assert_eq!(Some(('a', 3)), "141zxc".scan_char(8));
assert_eq!(Some(('\n', 2)), "12qzxc".scan_char(8));
assert_eq!(Some(('\r', 1)), "dqzxc".scan_char(16));
assert_eq!(None, "z2qzxc".scan_char(8));
assert_eq!(Some(('\n', 2)), "12qzxc".scan_char(8)); // spell-checker:disable-line
assert_eq!(Some(('\r', 1)), "dqzxc".scan_char(16)); // spell-checker:disable-line
assert_eq!(None, "z2qzxc".scan_char(8)); // spell-checker:disable-line
}
#[test]
fn test_groupnum() {
fn test_group_num() {
assert_eq!("12,379,821,234", group_num("12379821234"));
assert_eq!("21,234", group_num("21234"));
assert_eq!("821,234", group_num("821234"));
@ -97,13 +97,13 @@ fn test_invalid_option() {
}
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
const NORMAL_FMTSTR: &str =
const NORMAL_FORMAT_STR: &str =
"%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s %u %U %x %X %y %Y %z %Z"; // avoid "%w %W" (birth/creation) due to `stat` limitations and linux kernel & rust version capability variations
#[cfg(any(target_os = "linux"))]
const DEV_FMTSTR: &str =
const DEV_FORMAT_STR: &str =
"%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s (%t/%T) %u %U %w %W %x %X %y %Y %z %Z";
#[cfg(target_os = "linux")]
const FS_FMTSTR: &str = "%b %c %i %l %n %s %S %t %T"; // avoid "%a %d %f" which can cause test failure due to race conditions
const FS_FORMAT_STR: &str = "%b %c %i %l %n %s %S %t %T"; // avoid "%a %d %f" which can cause test failure due to race conditions
#[test]
#[cfg(target_os = "linux")]
@ -118,7 +118,7 @@ fn test_terse_fs_format() {
#[test]
#[cfg(target_os = "linux")]
fn test_fs_format() {
let args = ["-f", "-c", FS_FMTSTR, "/dev/shm"];
let args = ["-f", "-c", FS_FORMAT_STR, "/dev/shm"];
new_ucmd!()
.args(&args)
.run()
@ -207,7 +207,7 @@ fn test_format_created_seconds() {
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
#[test]
fn test_normal_format() {
let args = ["-c", NORMAL_FMTSTR, "/bin"];
let args = ["-c", NORMAL_FORMAT_STR, "/bin"];
new_ucmd!()
.args(&args)
.succeeds()
@ -231,14 +231,14 @@ fn test_symlinks() {
] {
if at.file_exists(file) && at.is_symlink(file) {
tested = true;
let args = ["-c", NORMAL_FMTSTR, file];
let args = ["-c", NORMAL_FORMAT_STR, file];
scene
.ucmd()
.args(&args)
.succeeds()
.stdout_is(expected_result(&args));
// -L, --dereference follow links
let args = ["-L", "-c", NORMAL_FMTSTR, file];
let args = ["-L", "-c", NORMAL_FORMAT_STR, file];
scene
.ucmd()
.args(&args)
@ -261,7 +261,7 @@ fn test_char() {
let args = [
"-c",
#[cfg(target_os = "linux")]
DEV_FMTSTR,
DEV_FORMAT_STR,
#[cfg(target_os = "linux")]
"/dev/pts/ptmx",
#[cfg(any(target_vendor = "apple"))]
@ -280,7 +280,7 @@ fn test_char() {
fn test_multi_files() {
let args = [
"-c",
NORMAL_FMTSTR,
NORMAL_FORMAT_STR,
"/dev",
"/usr/lib",
#[cfg(target_os = "linux")]

View file

@ -78,7 +78,7 @@ fn test_follow_multiple() {
at.append(FOOBAR_2_TXT, first_append);
assert_eq!(read_size(&mut child, first_append.len()), first_append);
let second_append = "doce\ntrece\n";
let second_append = "twenty\nthirty\n";
let expected = at.read("foobar_follow_multiple_appended.expected");
at.append(FOOBAR_TXT, second_append);
assert_eq!(read_size(&mut child, expected.len()), expected);
@ -95,7 +95,7 @@ fn test_follow_stdin() {
.stdout_is_fixture("follow_stdin.expected");
}
// FixME: test PASSES for usual windows builds, but fails for coverage testing builds (likely related to the specific RUSTFLAGS '-Zpanic_abort_tests -Cpanic=abort') This test also breaks tty settings under bash requiring a 'stty sane' or reset.
// FixME: test PASSES for usual windows builds, but fails for coverage testing builds (likely related to the specific RUSTFLAGS '-Zpanic_abort_tests -Cpanic=abort') This test also breaks tty settings under bash requiring a 'stty sane' or reset. // spell-checker:disable-line
#[cfg(disable_until_fixed)]
#[test]
fn test_follow_with_pid() {
@ -130,7 +130,7 @@ fn test_follow_with_pid() {
at.append(FOOBAR_2_TXT, first_append);
assert_eq!(read_size(&mut child, first_append.len()), first_append);
let second_append = "doce\ntrece\n";
let second_append = "twenty\nthirty\n";
let expected = at.read("foobar_follow_multiple_appended.expected");
at.append(FOOBAR_TXT, second_append);
assert_eq!(read_size(&mut child, expected.len()), expected);
@ -268,7 +268,7 @@ fn test_parse_size() {
assert!(parse_size("1Y").is_err());
// Bad number
assert!(parse_size("328hdsf3290").is_err());
assert!(parse_size("328hdsf3290").is_err()); // spell-checker:disable-line
}
#[test]

View file

@ -8,6 +8,8 @@
// file that was distributed with this source code.
//
// spell-checker:ignore (words) pseudofloat
use crate::common::util::*;
#[test]
@ -73,13 +75,13 @@ fn test_negated_or() {
}
#[test]
fn test_strlen_of_nothing() {
fn test_string_length_of_nothing() {
// odd but matches GNU, which must interpret -n as a literal here
new_ucmd!().arg("-n").succeeds();
}
#[test]
fn test_strlen_of_empty() {
fn test_string_length_of_empty() {
new_ucmd!().args(&["-n", ""]).run().status_code(1);
// STRING equivalent to -n STRING
@ -98,7 +100,7 @@ fn test_zero_len_of_empty() {
}
#[test]
fn test_solo_paren_is_literal() {
fn test_solo_parenthesis_is_literal() {
let scenario = TestScenario::new(util_name!());
let tests = [["("], [")"]];
@ -167,7 +169,7 @@ fn test_dangling_string_comparison_is_error() {
}
#[test]
fn test_stringop_is_literal_after_bang() {
fn test_string_operator_is_literal_after_bang() {
let scenario = TestScenario::new(util_name!());
let tests = [
["!", "="],
@ -208,7 +210,7 @@ fn test_pseudofloat_not_equal() {
#[test]
fn test_negative_arg_is_a_string() {
new_ucmd!().arg("-12345").succeeds();
new_ucmd!().arg("--qwert").succeeds();
new_ucmd!().arg("--qwert").succeeds(); // spell-checker:disable-line
}
#[test]
@ -475,12 +477,12 @@ fn test_nonexistent_file_is_not_symlink() {
}
#[test]
fn test_op_prec_and_or_1() {
fn test_op_precedence_and_or_1() {
new_ucmd!().args(&[" ", "-o", "", "-a", ""]).succeeds();
}
#[test]
fn test_op_prec_and_or_1_overridden_by_parentheses() {
fn test_op_precedence_and_or_1_overridden_by_parentheses() {
new_ucmd!()
.args(&["(", " ", "-o", "", ")", "-a", ""])
.run()
@ -488,14 +490,14 @@ fn test_op_prec_and_or_1_overridden_by_parentheses() {
}
#[test]
fn test_op_prec_and_or_2() {
fn test_op_precedence_and_or_2() {
new_ucmd!()
.args(&["", "-a", "", "-o", " ", "-a", " "])
.succeeds();
}
#[test]
fn test_op_prec_and_or_2_overridden_by_parentheses() {
fn test_op_precedence_and_or_2_overridden_by_parentheses() {
new_ucmd!()
.args(&["", "-a", "(", "", "-o", " ", ")", "-a", " "])
.run()
@ -529,7 +531,7 @@ fn test_negated_boolean_precedence() {
}
#[test]
fn test_bang_boolop_precedence() {
fn test_bang_bool_op_precedence() {
// For a Boolean combination of two literals, bang inverts the entire expression
new_ucmd!().args(&["!", "", "-a", ""]).succeeds();
new_ucmd!().args(&["!", "", "-o", ""]).succeeds();
@ -564,7 +566,7 @@ fn test_bang_boolop_precedence() {
}
#[test]
fn test_inverted_parenthetical_boolop_precedence() {
fn test_inverted_parenthetical_bool_op_precedence() {
// For a Boolean combination of two literals, bang inverts the entire expression
new_ucmd!()
.args(&["!", "a value", "-o", "another value"])
@ -618,6 +620,6 @@ fn test_or_as_filename() {
#[test]
#[ignore = "GNU considers this an error"]
fn test_strlen_and_nothing() {
fn test_string_length_and_nothing() {
new_ucmd!().args(&["-n", "a", "-a"]).run().status_code(2);
}

View file

@ -4,7 +4,7 @@ use crate::common::util::*;
// 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)
#[test]
fn test_subcommand_retcode() {
fn test_subcommand_return_code() {
new_ucmd!().arg("1").arg("true").succeeds();
new_ucmd!().arg("1").arg("false").run().status_code(1);

View file

@ -1,3 +1,5 @@
// spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms
extern crate touch;
use self::touch::filetime::{self, FileTime};
@ -383,13 +385,13 @@ fn is_dst_switch_hour(ts: time::Timespec) -> bool {
tm_after.tm_hour == tm.tm_hour + 2
}
// get_dstswitch_hour returns date string for which touch -m -t fails.
// get_dst_switch_hour returns date string for which touch -m -t fails.
// For example, in EST (UTC-5), that will be "202003080200" so
// touch -m -t 202003080200 somefile
// touch -m -t 202003080200 file
// fails (that date/time does not exist).
// In other locales it will be a different date/time, and in some locales
// it doesn't exist at all, in which case this function will return None.
fn get_dstswitch_hour() -> Option<String> {
fn get_dst_switch_hour() -> Option<String> {
let now = time::now();
// Start from January 1, 2020, 00:00.
let mut tm = time::strptime("20200101-0000", "%Y%m%d-%H%M").unwrap();
@ -415,7 +417,7 @@ fn test_touch_mtime_dst_fails() {
let (_at, mut ucmd) = at_and_ucmd!();
let file = "test_touch_set_mtime_dst_fails";
if let Some(s) = get_dstswitch_hour() {
if let Some(s) = get_dst_switch_hour() {
ucmd.args(&["-m", "-t", &s, file]).fails();
}
}

View file

@ -1,7 +1,7 @@
use crate::common::util::*;
#[test]
fn test_toupper() {
fn test_to_upper() {
new_ucmd!()
.args(&["a-z", "A-Z"])
.pipe_in("!abcd!")
@ -80,10 +80,10 @@ fn test_complement2() {
#[test]
fn test_complement3() {
new_ucmd!()
.args(&["-c", "abcdefgh", "123"])
.args(&["-c", "abcdefgh", "123"]) // spell-checker:disable-line
.pipe_in("the cat and the bat")
.run()
.stdout_is("3he3ca33a3d33he3ba3");
.stdout_is("3he3ca33a3d33he3ba3"); // spell-checker:disable-line
}
#[test]
@ -140,9 +140,9 @@ fn test_translate_and_squeeze() {
fn test_translate_and_squeeze_multiple_lines() {
new_ucmd!()
.args(&["-s", "x", "y"])
.pipe_in("xxaax\nxaaxx")
.pipe_in("xxaax\nxaaxx") // spell-checker:disable-line
.run()
.stdout_is("yaay\nyaay");
.stdout_is("yaay\nyaay"); // spell-checker:disable-line
}
#[test]
@ -169,7 +169,7 @@ fn test_set1_longer_than_set2() {
.args(&["abc", "xy"])
.pipe_in("abcde")
.run()
.stdout_is("xyyde");
.stdout_is("xyyde"); // spell-checker:disable-line
}
#[test]
@ -178,7 +178,7 @@ fn test_set1_shorter_than_set2() {
.args(&["ab", "xyz"])
.pipe_in("abcde")
.run()
.stdout_is("xycde");
.stdout_is("xycde"); // spell-checker:disable-line
}
#[test]
@ -187,7 +187,7 @@ fn test_truncate() {
.args(&["-t", "abc", "xy"])
.pipe_in("abcde")
.run()
.stdout_is("xycde");
.stdout_is("xycde"); // spell-checker:disable-line
}
#[test]
@ -196,7 +196,7 @@ fn test_truncate_with_set1_shorter_than_set2() {
.args(&["-t", "ab", "xyz"])
.pipe_in("abcde")
.run()
.stdout_is("xycde");
.stdout_is("xycde"); // spell-checker:disable-line
}
#[test]
@ -216,8 +216,8 @@ fn missing_required_second_arg_fails() {
#[test]
fn test_interpret_backslash_escapes() {
new_ucmd!()
.args(&["abfnrtv", r"\a\b\f\n\r\t\v"])
.pipe_in("abfnrtv")
.args(&["abfnrtv", r"\a\b\f\n\r\t\v"]) // spell-checker:disable-line
.pipe_in("abfnrtv") // spell-checker:disable-line
.succeeds()
.stdout_is("\u{7}\u{8}\u{c}\n\r\t\u{b}");
}

View file

@ -1,15 +1,15 @@
use crate::common::util::*;
use std::io::{Seek, SeekFrom, Write};
static TFILE1: &str = "truncate_test_1";
static TFILE2: &str = "truncate_test_2";
static FILE1: &str = "truncate_test_1";
static FILE2: &str = "truncate_test_2";
#[test]
fn test_increase_file_size() {
let expected = 5 * 1024;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE1);
ucmd.args(&["-s", "+5K", TFILE1]).succeeds();
let mut file = at.make_file(FILE1);
ucmd.args(&["-s", "+5K", FILE1]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
@ -25,8 +25,8 @@ fn test_increase_file_size() {
fn test_increase_file_size_kb() {
let expected = 5 * 1000;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE1);
ucmd.args(&["-s", "+5KB", TFILE1]).succeeds();
let mut file = at.make_file(FILE1);
ucmd.args(&["-s", "+5KB", FILE1]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
@ -43,15 +43,15 @@ fn test_reference() {
let expected = 5 * 1000;
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
scene.ucmd().arg("-s").arg("+5KB").arg(TFILE1).run();
scene.ucmd().arg("-s").arg("+5KB").arg(FILE1).run();
scene
.ucmd()
.arg("--reference")
.arg(TFILE1)
.arg(TFILE2)
.arg(FILE1)
.arg(FILE2)
.run();
file.seek(SeekFrom::End(0)).unwrap();
@ -68,9 +68,9 @@ fn test_reference() {
fn test_decrease_file_size() {
let expected = 6;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
file.write_all(b"1234567890").unwrap();
ucmd.args(&["--size=-4", TFILE2]).succeeds();
ucmd.args(&["--size=-4", FILE2]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
assert!(
@ -85,9 +85,9 @@ fn test_decrease_file_size() {
fn test_space_in_size() {
let expected = 4;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
file.write_all(b"1234567890").unwrap();
ucmd.args(&["--size", " 4", TFILE2]).succeeds();
ucmd.args(&["--size", " 4", FILE2]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
assert!(
@ -106,22 +106,22 @@ fn test_failed() {
#[test]
fn test_failed_2() {
let (_at, mut ucmd) = at_and_ucmd!();
ucmd.args(&[TFILE1]).fails();
ucmd.args(&[FILE1]).fails();
}
#[test]
fn test_failed_incorrect_arg() {
let (_at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-s", "+5A", TFILE1]).fails();
ucmd.args(&["-s", "+5A", FILE1]).fails();
}
#[test]
fn test_at_most_shrinks() {
let expected = 4;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
file.write_all(b"1234567890").unwrap();
ucmd.args(&["--size", "<4", TFILE2]).succeeds();
ucmd.args(&["--size", "<4", FILE2]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
assert!(
@ -136,9 +136,9 @@ fn test_at_most_shrinks() {
fn test_at_most_no_change() {
let expected = 10;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
file.write_all(b"1234567890").unwrap();
ucmd.args(&["--size", "<40", TFILE2]).succeeds();
ucmd.args(&["--size", "<40", FILE2]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
assert!(
@ -153,9 +153,9 @@ fn test_at_most_no_change() {
fn test_at_least_grows() {
let expected = 15;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
file.write_all(b"1234567890").unwrap();
ucmd.args(&["--size", ">15", TFILE2]).succeeds();
ucmd.args(&["--size", ">15", FILE2]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
assert!(
@ -170,9 +170,9 @@ fn test_at_least_grows() {
fn test_at_least_no_change() {
let expected = 10;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
file.write_all(b"1234567890").unwrap();
ucmd.args(&["--size", ">4", TFILE2]).succeeds();
ucmd.args(&["--size", ">4", FILE2]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
assert!(
@ -187,9 +187,9 @@ fn test_at_least_no_change() {
fn test_round_down() {
let expected = 8;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
file.write_all(b"1234567890").unwrap();
ucmd.args(&["--size", "/4", TFILE2]).succeeds();
ucmd.args(&["--size", "/4", FILE2]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
assert!(
@ -204,9 +204,9 @@ fn test_round_down() {
fn test_round_up() {
let expected = 12;
let (at, mut ucmd) = at_and_ucmd!();
let mut file = at.make_file(TFILE2);
let mut file = at.make_file(FILE2);
file.write_all(b"1234567890").unwrap();
ucmd.args(&["--size", "%4", TFILE2]).succeeds();
ucmd.args(&["--size", "%4", FILE2]).succeeds();
file.seek(SeekFrom::End(0)).unwrap();
let actual = file.seek(SeekFrom::Current(0)).unwrap();
assert!(
@ -221,10 +221,10 @@ fn test_round_up() {
fn test_size_and_reference() {
let expected = 15;
let (at, mut ucmd) = at_and_ucmd!();
let mut file1 = at.make_file(TFILE1);
let mut file2 = at.make_file(TFILE2);
let mut file1 = at.make_file(FILE1);
let mut file2 = at.make_file(FILE2);
file1.write_all(b"1234567890").unwrap();
ucmd.args(&["--reference", TFILE1, "--size", "+5", TFILE2])
ucmd.args(&["--reference", FILE1, "--size", "+5", FILE2])
.succeeds();
file2.seek(SeekFrom::End(0)).unwrap();
let actual = file2.seek(SeekFrom::Current(0)).unwrap();

View file

@ -17,7 +17,7 @@ fn test_uname_processor() {
}
#[test]
fn test_uname_hwplatform() {
fn test_uname_hardware_platform() {
let result = new_ucmd!().arg("-i").succeeds();
assert_eq!(result.stdout_str().trim_end(), "unknown");
}

View file

@ -38,7 +38,7 @@ fn unexpand_init_list_1() {
}
#[test]
fn unexpand_aflag_0() {
fn unexpand_flag_a_0() {
new_ucmd!()
.args(&["--"])
.pipe_in("e E\nf F\ng G\nh H\n")
@ -47,7 +47,7 @@ fn unexpand_aflag_0() {
}
#[test]
fn unexpand_aflag_1() {
fn unexpand_flag_a_1() {
new_ucmd!()
.args(&["-a"])
.pipe_in("e E\nf F\ng G\nh H\n")
@ -56,7 +56,7 @@ fn unexpand_aflag_1() {
}
#[test]
fn unexpand_aflag_2() {
fn unexpand_flag_a_2() {
new_ucmd!()
.args(&["-t8"])
.pipe_in("e E\nf F\ng G\nh H\n")

View file

@ -22,5 +22,5 @@ fn test_uptime_since() {
#[test]
fn test_failed() {
new_ucmd!().arg("willfail").fails();
new_ucmd!().arg("will-fail").fails();
}

View file

@ -1,7 +1,7 @@
use crate::common::util::*;
#[test]
fn test_users_noarg() {
fn test_users_no_arg() {
new_ucmd!().succeeds();
}

View file

@ -1,5 +1,7 @@
use crate::common::util::*;
// spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword
#[test]
fn test_count_bytes_large_stdin() {
for &n in &[

View file

@ -1,5 +1,7 @@
use crate::common::util::*;
// spell-checker:ignore (flags) runlevel mesg
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
#[test]
fn test_count() {

View file

@ -632,7 +632,7 @@ impl TestScenario {
let tmpd = Rc::new(TempDir::new().unwrap());
let ts = TestScenario {
bin_path: {
// Instead of hardcoding the path relative to the current
// Instead of hard coding the path relative to the current
// directory, use Cargo's OUT_DIR to find path to executable.
// This allows tests to be run using profiles other than debug.
let target_dir = path_concat!(env!("OUT_DIR"), "..", "..", "..", PROGNAME);
@ -722,9 +722,10 @@ impl UCommand {
cmd.current_dir(curdir.as_ref());
if env_clear {
if cfg!(windows) {
// spell-checker:ignore (dll) rsaenh
// %SYSTEMROOT% is required on Windows to initialize crypto provider
// ... and crypto provider is required for std::rand
// From procmon: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path
// From `procmon`: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path
// SUCCESS Type: REG_SZ, Length: 66, Data: %SystemRoot%\system32\rsaenh.dll"
for (key, _) in env::vars_os() {
if key.as_os_str() != "SYSTEMROOT" {
@ -802,7 +803,7 @@ impl UCommand {
self
}
/// provides stdinput to feed in to the command when spawned
/// provides standard input to feed in to the command when spawned
pub fn pipe_in<T: Into<Vec<u8>>>(&mut self, input: T) -> &mut UCommand {
if self.bytes_into_stdin.is_some() {
panic!("{}", MULTIPLE_STDIN_MEANINGLESS);
@ -934,6 +935,7 @@ pub fn vec_of_size(n: usize) -> Vec<u8> {
/// Sanity checks for test utils
#[cfg(test)]
mod tests {
// spell-checker:ignore (tests) asdfsadfa
use super::*;
#[test]
@ -1012,7 +1014,7 @@ mod tests {
}
#[test]
fn test_no_std_errout() {
fn test_no_stderr_output() {
let res = CmdResult {
tmpd: None,
code: None,

View file

@ -1,5 +1,5 @@
cat: test_directory3/test_directory4: Is a directory
cat: filewhichdoesnotexist.txt: No such file or directory (os error 2)
cat: file_which_does_not_exist.txt: No such file or directory (os error 2)
cat: test_directory3/test_directory5: Is a directory
cat: test_directory3/../test_directory3/test_directory5: Is a directory
cat: test_directory3: Is a directory

View file

@ -1,4 +1,4 @@
==> foobar.txt <==
doce
trece
twenty
thirty