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
+1 -1
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;
+2 -2
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()))
+7 -7
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
);
}
}
+7 -6
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");
}
}
+5 -3
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
}
}
+15 -7
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, "-"])
+2
View File
@@ -1,3 +1,5 @@
// spell-checker:ignore (words) nosuchgroup
use crate::common::util::*;
use rust_users::*;
+13 -11
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"),
+2
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;
+2
View File
@@ -1,3 +1,5 @@
// spell-checker:ignore (words) araba newroot userspec
use crate::common::util::*;
#[test]
+10 -8
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);
+8 -6
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]
+7 -5
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
+14 -14
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()
+1 -1
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 "));
+3 -3
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);
+2
View File
@@ -1,3 +1,5 @@
// spell-checker:ignore (paths) sublink subwords
use crate::common::util::*;
const SUB_DIR: &str = "subdir/deeper";
+4 -2
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]
+2
View File
@@ -1,3 +1,5 @@
// spell-checker:ignore (words) bamf chdir
#[cfg(not(windows))]
use std::fs;
+44 -42
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]] = &[

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