-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathglob.rs
121 lines (108 loc) · 2.26 KB
/
glob.rs
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use indoc::indoc;
mod utils;
#[test]
fn glob() {
assert_eq!(
utils::run_cmd(&["--glob", "--pattern", "*.txt", "tests/data"]),
indoc!(
"100 B ┌─ nylarlathotep.txt
161 B ├─ nemesis.txt
83 B ├─ necronomicon.txt
446 B │ ┌─ lipsum.txt
446 B ├─ lipsum
308 B │ ┌─ polaris.txt
308 B ├─ dream_cycle
1098 B data
2 directories, 5 files"
)
);
}
#[test]
fn glob_negative() {
assert_eq!(
utils::run_cmd(&["--glob", "--pattern", "!*.txt", "tests/data"]),
indoc!(
"143 B ┌─ cassildas_song.md
143 B ┌─ the_yellow_king
143 B data
1 directory, 1 file"
)
)
}
#[test]
fn glob_case_insensitive() {
assert_eq!(
utils::run_cmd(&["--iglob", "--pattern", "*.TXT", "tests/data"]),
indoc!(
"100 B ┌─ nylarlathotep.txt
161 B ├─ nemesis.txt
83 B ├─ necronomicon.txt
446 B │ ┌─ lipsum.txt
446 B ├─ lipsum
308 B │ ┌─ polaris.txt
308 B ├─ dream_cycle
1098 B data
2 directories, 5 files"
)
)
}
#[test]
fn glob_with_filetype() {
assert_eq!(
utils::run_cmd(&[
"--glob",
"--pattern",
"dream*",
"--file-type",
"dir",
"tests/data"
]),
indoc!(
"308 B ┌─ polaris.txt
308 B ┌─ dream_cycle
308 B data
1 directory, 1 file"
)
)
}
#[test]
fn negated_glob_with_filetype() {
assert_eq!(
utils::run_cmd(&[
"--glob",
"--pattern",
"!dream*",
"--file-type",
"dir",
"tests/data"
]),
indoc!(
"143 B ┌─ cassildas_song.md
143 B ┌─ the_yellow_king
100 B ├─ nylarlathotep.txt
161 B ├─ nemesis.txt
83 B ├─ necronomicon.txt
446 B │ ┌─ lipsum.txt
446 B ├─ lipsum
933 B data
2 directories, 5 files"
)
)
}
#[test]
#[should_panic]
fn glob_empty_set_dir() {
utils::run_cmd(&[
"--glob",
"--pattern",
"*.txt",
"--file-type",
"dir",
"tests/data",
]);
}
#[test]
#[should_panic]
fn glob_empty_set_file() {
utils::run_cmd(&["--glob", "--pattern", "*weewoo*", "tests/data"]);
}