|
39 | 39 | TESTS_RUN=0 |
40 | 40 | TESTS_PASSED=0 |
41 | 41 | TESTS_FAILED=0 |
42 | | -TEST_FAILURES="" |
43 | 42 |
|
44 | 43 | run_test() { |
45 | 44 | # Parse arguments: |
@@ -74,16 +73,20 @@ run_test() { |
74 | 73 | ;; |
75 | 74 | esac |
76 | 75 | done |
| 76 | + |
77 | 77 | # Print test pre-amble: |
78 | 78 | TESTS_RUN=$((TESTS_RUN + 1)) |
| 79 | + |
79 | 80 | # Run command and capture its stdout, stderr and exit code: |
80 | 81 | _stdout_file="$(mktemp)" |
81 | 82 | _stderr_file="$(mktemp)" |
82 | 83 | _exit_code=0 |
83 | 84 | eval "$_test_command" >"$_stdout_file" 2>"$_stderr_file" || _exit_code=$? |
| 85 | + |
84 | 86 | # Check the command's output: |
85 | | - _test_stdout="$(cat "$_stdout_file")" |
| 87 | + _test_stdout="$(LC_COLLATE=C sort < "$_stdout_file")" |
86 | 88 | _test_stderr="$(cat "$_stderr_file")" |
| 89 | + |
87 | 90 | _test_passed=true |
88 | 91 | _failure_reason="" |
89 | 92 | # Check stdout - either exact match or pattern match: |
@@ -183,39 +186,39 @@ cleanup_test_dir() { |
183 | 186 | test_basic_functionality() { |
184 | 187 | run_test "List specific file" "$FF_PATH file1.txt" --stdout "./file1.txt" |
185 | 188 | run_test "Simple pattern - just script files" "$FF_PATH script" --stdout "./script.sh" |
186 | | - run_test "Pattern with extension" "$FF_PATH '*.py'" --stdout "./file2.py |
187 | | -./dir1/subdir1/deep_file.py" |
| 189 | + run_test "Pattern with extension" "$FF_PATH '*.py'" --stdout "./dir1/subdir1/deep_file.py |
| 190 | +./file2.py" |
188 | 191 | run_test "Pattern with glob" "$FF_PATH 'config*'" --stdout "./config" |
189 | | - run_test "All files with 'file' in name" "$FF_PATH -d 2 file" --stdout "./file1.txt |
190 | | -./file2.py |
191 | | -./file3.log |
| 192 | + run_test "All files with 'file' in name" "$FF_PATH -d 2 file" --stdout "./dir1/nested_file.txt |
| 193 | +./dir2/another_file.log |
192 | 194 | ./file with spaces.txt |
193 | 195 | ./file-with-dashes.txt |
| 196 | +./file1.txt |
| 197 | +./file2.py |
| 198 | +./file3.log |
194 | 199 | ./file_with_underscores.txt |
195 | | -./dir1/nested_file.txt |
196 | | -./dir2/another_file.log |
197 | 200 | ./link_to_file1" |
198 | 201 | } |
199 | 202 |
|
200 | 203 | test_options() { |
201 | | - run_test "Hidden files included" "$FF_PATH -H hidden" --stdout "./.hidden_file |
202 | | -./.hidden_dir" |
| 204 | + run_test "Hidden files included" "$FF_PATH -H hidden" --stdout "./.hidden_dir |
| 205 | +./.hidden_file" |
203 | 206 | run_test "Hidden files excluded by default" "$FF_PATH hidden" --stdout "" |
204 | 207 | run_test "Type file - limited to specific files" "$FF_PATH -t f -e txt file1" --stdout "./file1.txt" |
205 | 208 | run_test "Type directory" "$FF_PATH -t d dir" --stdout "./dir1 |
206 | 209 | ./dir1/subdir1 |
207 | 210 | ./dir2 |
208 | 211 | ./dir2/subdir2" |
209 | | - run_test "Extension py" "$FF_PATH -e py" --stdout "./file2.py |
210 | | -./dir1/subdir1/deep_file.py" |
| 212 | + run_test "Extension py" "$FF_PATH -e py" --stdout "./dir1/subdir1/deep_file.py |
| 213 | +./file2.py" |
211 | 214 | run_test "Extension txt" "$FF_PATH -e txt file1" --stdout "./file1.txt" |
212 | 215 | run_test "Max depth 1" "$FF_PATH -d 1 -t f script" --stdout "./script.sh" |
213 | | - run_test "Max depth 2" "$FF_PATH -d 2 nested" --stdout "./dir1/nested_file.txt |
214 | | -./deep/nested" |
| 216 | + run_test "Max depth 2" "$FF_PATH -d 2 nested" --stdout "./deep/nested |
| 217 | +./dir1/nested_file.txt" |
215 | 218 | run_test "Full path matching" "$FF_PATH -p dir1" --stdout "./dir1 |
| 219 | +./dir1/nested_file.txt |
216 | 220 | ./dir1/subdir1 |
217 | 221 | ./dir1/subdir1/deep_file.py |
218 | | -./dir1/nested_file.txt |
219 | 222 | ./link_to_dir1" |
220 | 223 | run_test "Exclude pattern - log files" "$FF_PATH -E '*log*' script" --stdout "./script.sh" |
221 | 224 | run_test "Follow links" "$FF_PATH -L -t f link" --stdout "./link_to_file1" |
@@ -243,8 +246,8 @@ test_color_options() { |
243 | 246 |
|
244 | 247 | test_path_formats() { |
245 | 248 | run_test "Absolute paths" "$FF_PATH -a file1.txt" --stdout "$TEST_DIR/file1.txt" |
246 | | - run_test "Specific search path" "$FF_PATH file dir1" --stdout "dir1/subdir1/deep_file.py |
247 | | -dir1/nested_file.txt" |
| 249 | + run_test "Specific search path" "$FF_PATH file dir1" --stdout "dir1/nested_file.txt |
| 250 | +dir1/subdir1/deep_file.py" |
248 | 251 | } |
249 | 252 |
|
250 | 253 | test_complex_scenarios() { |
|
0 commit comments