1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 20:47:46 +00:00

Merge pull request #2106 from miDeb/sort-debug

sort: implement --debug
This commit is contained in:
Sylvestre Ledru 2021-04-24 18:46:58 +02:00 committed by GitHub
commit 2f17bfc14c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 2006 additions and 217 deletions

View file

@ -2,10 +2,17 @@ use crate::common::util::*;
fn test_helper(file_name: &str, args: &str) {
new_ucmd!()
.arg(args)
.arg(format!("{}.txt", file_name))
.args(&args.split(' ').collect::<Vec<&str>>())
.succeeds()
.stdout_is_fixture(format!("{}.expected", file_name));
new_ucmd!()
.arg(format!("{}.txt", file_name))
.arg("--debug")
.args(&args.split(' ').collect::<Vec<&str>>())
.succeeds()
.stdout_is_fixture(format!("{}.expected.debug", file_name));
}
#[test]
@ -29,11 +36,7 @@ fn test_human_numeric_whitespace() {
#[test]
fn test_multiple_decimals_general() {
new_ucmd!()
.arg("-g")
.arg("multiple_decimals_general.txt")
.succeeds()
.stdout_is("\n\n\n\n\n\n\n\nCARAvan\n-2028789030\n-896689\n-8.90880\n-1\n-.05\n000\n00000001\n1\n1.040000000\n1.444\n1.58590\n8.013\n45\n46.89\n576,446.88800000\n576,446.890\n 4567.\n4567.1\n4567.34\n\t\t\t\t\t\t\t\t\t\t4567..457\n\t\t\t\t37800\n\t\t\t\t\t\t45670.89079.098\n\t\t\t\t\t\t45670.89079.1\n4798908.340000000000\n4798908.45\n4798908.8909800\n");
test_helper("multiple_decimals_general", "-g")
}
#[test]
@ -209,13 +212,7 @@ fn test_non_printing_chars() {
#[test]
fn test_exponents_positive_general_fixed() {
for exponents_positive_general_param in vec!["-g"] {
new_ucmd!()
.pipe_in("100E6\n\n50e10\n+100000\n\n10000K78\n10E\n\n\n1000EDKLD\n\n\n100E6\n\n50e10\n+100000\n\n")
.arg(exponents_positive_general_param)
.succeeds()
.stdout_only("\n\n\n\n\n\n\n\n10000K78\n1000EDKLD\n10E\n+100000\n+100000\n100E6\n100E6\n50e10\n50e10\n");
}
test_helper("exponents_general", "-g");
}
#[test]
@ -334,62 +331,32 @@ fn test_numeric_unique_ints2() {
#[test]
fn test_keys_open_ended() {
let input = "aa bb cc\ndd aa ff\ngg aa cc\n";
new_ucmd!()
.args(&["-k", "2.2"])
.pipe_in(input)
.succeeds()
.stdout_only("gg aa cc\ndd aa ff\naa bb cc\n");
test_helper("keys_open_ended", "-k 2.3");
}
#[test]
fn test_keys_closed_range() {
let input = "aa bb cc\ndd aa ff\ngg aa cc\n";
new_ucmd!()
.args(&["-k", "2.2,2.2"])
.pipe_in(input)
.succeeds()
.stdout_only("dd aa ff\ngg aa cc\naa bb cc\n");
test_helper("keys_closed_range", "-k 2.2,2.2");
}
#[test]
fn test_keys_multiple_ranges() {
let input = "aa bb cc\ndd aa ff\ngg aa cc\n";
new_ucmd!()
.args(&["-k", "2,2", "-k", "3,3"])
.pipe_in(input)
.succeeds()
.stdout_only("gg aa cc\ndd aa ff\naa bb cc\n");
test_helper("keys_multiple_ranges", "-k 2,2 -k 3,3");
}
#[test]
fn test_keys_no_field_match() {
let input = "aa aa aa aa\naa bb cc\ndd aa ff\n";
new_ucmd!()
.args(&["-k", "4,4"])
.pipe_in(input)
.succeeds()
.stdout_only("aa bb cc\ndd aa ff\naa aa aa aa\n");
test_helper("keys_no_field_match", "-k 4,4");
}
#[test]
fn test_keys_no_char_match() {
let input = "aaa\nba\nc\n";
new_ucmd!()
.args(&["-k", "1.2"])
.pipe_in(input)
.succeeds()
.stdout_only("c\nba\naaa\n");
test_helper("keys_no_char_match", "-k 1.2");
}
#[test]
fn test_keys_custom_separator() {
let input = "aaxbbxcc\nddxaaxff\nggxaaxcc\n";
new_ucmd!()
.args(&["-k", "2.2,2.2", "-t", "x"])
.pipe_in(input)
.succeeds()
.stdout_only("ddxaaxff\nggxaaxcc\naaxbbxcc\n");
test_helper("keys_custom_separator", "-k 2.2,2.2 -t x");
}
#[test]
@ -416,6 +383,13 @@ fn test_keys_invalid_field_zero() {
.stderr_only("sort: error: field index was 0");
}
#[test]
fn test_keys_invalid_char_zero() {
new_ucmd!().args(&["-k", "1.0"]).fails().stderr_only(
"sort: error: invalid character index 0 in `1.0` for the start position of a field",
);
}
#[test]
fn test_keys_with_options() {
let input = "aa 3 cc\ndd 1 ff\ngg 2 cc\n";

View file

@ -0,0 +1,200 @@
1
_
10
__
100
___
11
__
12
__
13
__
14
__
15
__
16
__
17
__
18
__
19
__
2
_
20
__
21
__
22
__
23
__
24
__
25
__
26
__
27
__
28
__
29
__
3
_
30
__
31
__
32
__
33
__
34
__
35
__
36
__
37
__
38
__
39
__
4
_
40
__
41
__
42
__
43
__
44
__
45
__
46
__
47
__
48
__
49
__
5
_
50
__
51
__
52
__
53
__
54
__
55
__
56
__
57
__
58
__
59
__
6
_
60
__
61
__
62
__
63
__
64
__
65
__
66
__
67
__
68
__
69
__
7
_
70
__
71
__
72
__
73
__
74
__
75
__
76
__
77
__
78
__
79
__
8
_
80
__
81
__
82
__
83
__
84
__
85
__
86
__
87
__
88
__
89
__
9
_
90
__
91
__
92
__
93
__
94
__
95
__
96
__
97
__
98
__
99
__

View file

@ -0,0 +1,9 @@
bbb
___
___
./bbc
_____
_____
bbd
___
___

View file

@ -0,0 +1,36 @@
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
+100000
^ no match for key
_______
10E
__
___
50e10
__
_____
100E6
___
_____
1000EDKLD
____
_________
10000K78
_____
________

View file

@ -0,0 +1,19 @@
5.5.5.5
10E
1000EDKLD
10000K78
+100000
+100000
100E6
100E6
10e10e10e10
50e10
50e10

View file

@ -0,0 +1,57 @@
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
5.5.5.5
___
_______
10E
__
___
1000EDKLD
____
_________
10000K78
_____
________
+100000
_______
_______
+100000
_______
_______
100E6
_____
_____
100E6
_____
_____
10e10e10e10
_____
___________
50e10
_____
_____
50e10
_____
_____

View file

@ -0,0 +1,19 @@
100E6
50e10
+100000
10000K78
10E
1000EDKLD
100E6
50e10
+100000
10e10e10e10
5.5.5.5

View file

@ -0,0 +1,33 @@
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
456K
____
____
4568K
_____
_____
>>>456M
____
_______
6.2G
____
__________________

View file

@ -0,0 +1,33 @@
844K
____
____
981K
____
____
11M
___
___
13M
___
___
14M
___
___
16M
___
___
18M
___
___
19M
___
___
20M
___
___
981T
____
____
20P
___
___

View file

@ -0,0 +1,21 @@
aaa
___
___
BBB
___
___
ccc
___
___
DDD
___
___
eee
___
___
FFF
___
___
ggg
___
___

View file

@ -0,0 +1,6 @@
dd aa ff
gg aa cc
aa bb cc
èè éé èè
👩‍🔬 👩‍🔬 👩‍🔬
💣💣 💣💣 💣💣

View file

@ -0,0 +1,18 @@
dd aa ff
_
________
gg aa cc
_
________
aa bb cc
_
________
èè éé èè
_
________
👩‍🔬 👩‍🔬 👩‍🔬
__
______________
💣💣 💣💣 💣💣
__
______________

View file

@ -0,0 +1,6 @@
aa bb cc
dd aa ff
gg aa cc
èè éé èè
💣💣 💣💣 💣💣
👩‍🔬 👩‍🔬 👩‍🔬

View file

@ -0,0 +1,3 @@
ddxaaxff
ggxaaxcc
aaxbbxcc

View file

@ -0,0 +1,9 @@
ddxaaxff
_
________
ggxaaxcc
_
________
aaxbbxcc
_
________

View file

@ -0,0 +1,3 @@
aaxbbxcc
ddxaaxff
ggxaaxcc

View file

@ -0,0 +1,6 @@
gg aa cc
dd aa ff
aa bb cc
èè éé èè
👩‍🔬 👩‍🔬 👩‍🔬
💣💣 💣💣 💣💣

View file

@ -0,0 +1,24 @@
gg aa cc
___
___
________
dd aa ff
___
___
________
aa bb cc
___
___
________
èè éé èè
___
___
________
👩‍🔬 👩‍🔬 👩‍🔬
_____
_____
______________
💣💣 💣💣 💣💣
_____
_____
______________

View file

@ -0,0 +1,6 @@
aa bb cc
dd aa ff
gg aa cc
èè éé èè
💣💣 💣💣 💣💣
👩‍🔬 👩‍🔬 👩‍🔬

View file

@ -0,0 +1,3 @@
c
ba
aaa

View file

@ -0,0 +1,9 @@
c
^ no match for key
_
ba
_
__
aaa
__
___

View file

@ -0,0 +1,3 @@
aaa
ba
c

View file

@ -0,0 +1,6 @@
aa bb cc
dd aa ff
gg aa cc
èè éé èè
👩‍🔬 👩‍🔬 👩‍🔬
💣💣 💣💣 💣💣

View file

@ -0,0 +1,18 @@
aa bb cc
^ no match for key
________
dd aa ff
^ no match for key
________
gg aa cc
^ no match for key
________
èè éé èè
^ no match for key
________
👩‍🔬 👩‍🔬 👩‍🔬
^ no match for key
______________
💣💣 💣💣 💣💣
^ no match for key
______________

View file

@ -0,0 +1,6 @@
aa bb cc
dd aa ff
gg aa cc
èè éé èè
💣💣 💣💣 💣💣
👩‍🔬 👩‍🔬 👩‍🔬

View file

@ -0,0 +1,6 @@
gg aa cc
dd aa ff
aa bb cc
èè éé èè
👩‍🔬 👩‍🔬 👩‍🔬
💣💣 💣💣 💣💣

View file

@ -0,0 +1,18 @@
gg aa cc
____
________
dd aa ff
____
________
aa bb cc
____
________
èè éé èè
____
________
👩‍🔬 👩‍🔬 👩‍🔬
_______
______________
💣💣 💣💣 💣💣
_______
______________

View file

@ -0,0 +1,6 @@
aa bb cc
dd aa ff
gg aa cc
èè éé èè
💣💣 💣💣 💣💣
👩‍🔬 👩‍🔬 👩‍🔬

View file

@ -0,0 +1,90 @@
-2028789030
___________
___________
-896689
_______
_______
-8.90880
________
________
-1
__
__
-.05
____
____
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
000
___
___
CARAvan
^ no match for key
_______
00000001
________
________
1
_
_
1.040000000
___________
___________
1.444
_____
_____
1.58590
_______
_______
8.013
_____
_____
45
__
__
46.89
_____
_____
4567.
_____
____________________
>>>>37800
_____
_________
576,446.88800000
________________
________________
576,446.890
___________
___________
4798908.340000000000
____________________
____________________
4798908.45
__________
__________
4798908.8909800
_______________
_______________

View file

@ -0,0 +1,60 @@
-2028789030
___________
-896689
_______
-8.90880
________
-1
__
-.05
____
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
CARAvan
^ no match for key
^ no match for key
^ no match for key
^ no match for key
000
___
1
_
00000001
________
1.040000000
___________
1.444
_____
1.58590
_______
8.013
_____
45
__
46.89
_____
4567.
_____
>>>>37800
_____
576,446.88800000
________________
576,446.890
___________
4798908.340000000000
____________________
4798908.45
__________
4798908.8909800
_______________

View file

@ -0,0 +1,40 @@
-2028789030
___________
-896689
_______
-8.90880
________
-1
__
-.05
____
^ no match for key
1
_
1.040000000
___________
1.444
_____
1.58590
_______
8.013
_____
45
__
46.89
_____
4567.
_____
>>>>37800
_____
576,446.88800000
________________
576,446.890
___________
4798908.340000000000
____________________
4798908.45
__________
4798908.8909800
_______________

View file

@ -0,0 +1,40 @@
4798908.8909800
_______________
4798908.45
__________
4798908.340000000000
____________________
576,446.890
___________
576,446.88800000
________________
>>>>37800
_____
4567.
_____
46.89
_____
45
__
8.013
_____
1.58590
_______
1.444
_____
1.040000000
___________
1
_
^ no match for key
-.05
____
-1
__
-8.90880
________
-896689
_______
-2028789030
___________

View file

@ -0,0 +1,30 @@
N/A Ut enim ad minim veniam, quis
^ no match for key
_________________________________
Jan Lorem ipsum dolor sit amet
___
______________________________
mar laboris nisi ut aliquip ex ea
___
_________________________________
May sed do eiusmod tempor incididunt
___
____________________________________
JUN nostrud exercitation ullamco
___
________________________________
Jul 1 should remain 2,1,3
___
_________________________
Jul 2 these three lines
___
_______________________
Jul 3 if --stable is provided
___
_____________________________
Oct ut labore et dolore magna aliqua
___
____________________________________
Dec consectetur adipiscing elit
___
_______________________________

View file

@ -0,0 +1,20 @@
N/A Ut enim ad minim veniam, quis
^ no match for key
Jan Lorem ipsum dolor sit amet
___
mar laboris nisi ut aliquip ex ea
___
May sed do eiusmod tempor incididunt
___
JUN nostrud exercitation ullamco
___
Jul 2 these three lines
___
Jul 1 should remain 2,1,3
___
Jul 3 if --stable is provided
___
Oct ut labore et dolore magna aliqua
___
Dec consectetur adipiscing elit
___

View file

@ -0,0 +1,12 @@
^ no match for key
JAN
___
apr
___
MAY
___
JUNNNN
___
AUG
___

View file

@ -0,0 +1,24 @@
^ no match for key
^ no match for key
^ no match for key
^ no match for key
JAN
___
___
FEb
___
_____
apr
___
____
apr
___
____
>>>JUNNNN
___
_________
AUG
___
____

View file

@ -0,0 +1,37 @@
CARAvan
NaN
-inf
-2028789030
-896689
-8.90880
-1
-.05
000
00000001
1
1.040000000
1.444
1.58590
8.013
45
46.89
576,446.88800000
576,446.890
4567..457
4567.
4567.1
4567.34
37800
45670.89079.098
45670.89079.1
4798908.340000000000
4798908.45
4798908.8909800
inf

View file

@ -0,0 +1,111 @@
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
CARAvan
^ no match for key
_______
NaN
___
_____
>-inf
____
_____
-2028789030
___________
___________
-896689
_______
_______
-8.90880
________
________
-1
__
__
-.05
____
____
000
___
___
00000001
________
________
1
_
_
1.040000000
___________
___________
1.444
_____
_____
1.58590
_______
_______
8.013
_____
_____
45
__
__
46.89
_____
_____
576,446.88800000
___
________________
576,446.890
___
___________
>>>>>>>>>>4567..457
_____
___________________
4567.
_____
____________________
4567.1
______
______
4567.34
_______
_______
>>>>37800
_____
_________
>>>>>>45670.89079.098
___________
_____________________
>>>>>>45670.89079.1
___________
___________________
4798908.340000000000
____________________
____________________
4798908.45
__________
__________
4798908.8909800
_______________
_______________
inf
___
___

View file

@ -32,4 +32,6 @@ CARAvan
8.013
000
NaN
inf
-inf

View file

@ -0,0 +1,105 @@
-2028789030
___________
___________
-896689
_______
_______
-8.90880
________
________
-1
__
__
-.05
____
____
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
000
___
___
CARAvan
^ no match for key
_______
00000001
________
________
1
_
_
1.040000000
___________
___________
1.444
_____
_____
1.58590
_______
_______
8.013
_____
_____
45
__
__
46.89
_____
_____
>>>>>>>>>>4567..457
_____
___________________
4567.
_____
____________________
4567.1
______
______
4567.34
_______
_______
>>>>37800
_____
_________
>>>>>>45670.89079.098
___________
_____________________
>>>>>>45670.89079.1
___________
___________________
576,446.88800000
________________
________________
576,446.890
___________
___________
4798908.340000000000
____________________
____________________
4798908.45
__________
__________
4798908.8909800
_______________
_______________

View file

@ -0,0 +1,69 @@
-8.90880
________
________
-.05
____
____
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
^ no match for key
Karma
^ no match for key
_____
1
_
_
1.0/0.0
___
_______
1.040000000
___________
___________
1.2
___
___
1.444
_____
_____
1.58590
_______
_______

View file

@ -0,0 +1,6 @@
.00
___
___
.01
___
___

View file

@ -0,0 +1,6 @@
.02
___
___
.03
___
___

View file

@ -0,0 +1,6 @@
0
_
_
.02
___
___

View file

@ -0,0 +1,9 @@
NaN
^ no match for key
___
.02
___
___
.03
___
___

View file

@ -0,0 +1,6 @@
.000
____
____
.01
___
___

View file

@ -0,0 +1,4 @@
-10 bb
___
aa
^ no match for key

View file

@ -0,0 +1,300 @@
1
_
_
2
_
_
3
_
_
4
_
_
5
_
_
6
_
_
7
_
_
8
_
_
9
_
_
10
__
__
11
__
__
12
__
__
13
__
__
14
__
__
15
__
__
16
__
__
17
__
__
18
__
__
19
__
__
20
__
__
21
__
__
22
__
__
23
__
__
24
__
__
25
__
__
26
__
__
27
__
__
28
__
__
29
__
__
30
__
__
31
__
__
32
__
__
33
__
__
34
__
__
35
__
__
36
__
__
37
__
__
38
__
__
39
__
__
40
__
__
41
__
__
42
__
__
43
__
__
44
__
__
45
__
__
46
__
__
47
__
__
48
__
__
49
__
__
50
__
__
51
__
__
52
__
__
53
__
__
54
__
__
55
__
__
56
__
__
57
__
__
58
__
__
59
__
__
60
__
__
61
__
__
62
__
__
63
__
__
64
__
__
65
__
__
66
__
__
67
__
__
68
__
__
69
__
__
70
__
__
71
__
__
72
__
__
73
__
__
74
__
__
75
__
__
76
__
__
77
__
__
78
__
__
79
__
__
80
__
__
81
__
__
82
__
__
83
__
__
84
__
__
85
__
__
86
__
__
87
__
__
88
__
__
89
__
__
90
__
__
91
__
__
92
__
__
93
__
__
94
__
__
95
__
__
96
__
__
97
__
__
98
__
__
99
__
__
100
___
___

View file

@ -0,0 +1,8 @@
1
_
2
_
3
_
4
_

View file

@ -0,0 +1,12 @@
1.2.3-alpha
___________
___________
1.2.3-alpha2
____________
____________
1.12.4
______
______
11.2.3
______
______

View file

@ -0,0 +1,6 @@
aaa
___
bbb
___
zzz
___

View file

@ -0,0 +1,84 @@
../..
_____
../../by-util
_____________
../../common
____________
../../fixtures
______________
../../fixtures/cat
__________________
../../fixtures/cksum
____________________
../../fixtures/comm
___________________
../../fixtures/cp
_________________
../../fixtures/cp/dir_with_mount
________________________________
../../fixtures/cp/dir_with_mount/copy_me
________________________________________
../../fixtures/cp/hello_dir
___________________________
../../fixtures/cp/hello_dir_with_file
_____________________________________
../../fixtures/csplit
_____________________
../../fixtures/cut
__________________
../../fixtures/cut/sequences
____________________________
../../fixtures/dircolors
________________________
../../fixtures/du
_________________
../../fixtures/du/subdir
________________________
../../fixtures/du/subdir/deeper
_______________________________
../../fixtures/du/subdir/links
______________________________
../../fixtures/env
__________________
../../fixtures/expand
_____________________
../../fixtures/fmt
__________________
../../fixtures/fold
___________________
../../fixtures/hashsum
______________________
../../fixtures/head
___________________
../../fixtures/join
___________________
../../fixtures/mv
_________________
../../fixtures/nl
_________________
../../fixtures/numfmt
_____________________
../../fixtures/od
_________________
../../fixtures/paste
____________________
../../fixtures/ptx
__________________
../../fixtures/shuf
___________________
../../fixtures/sort
___________________
../../fixtures/sum
__________________
../../fixtures/tac
__________________
../../fixtures/tail
___________________
../../fixtures/tsort
____________________
../../fixtures/unexpand
_______________________
../../fixtures/uniq
___________________
../../fixtures/wc
_________________