@@ -74,16 +74,20 @@ run_test() {
7474 ;;
7575 esac
7676 done
77+
7778 # Print test pre-amble:
7879 TESTS_RUN=$(( TESTS_RUN + 1 ))
80+
7981 # Run command and capture its stdout, stderr and exit code:
8082 _stdout_file=" $( mktemp) "
8183 _stderr_file=" $( mktemp) "
8284 _exit_code=0
8385 eval " $_test_command " > " $_stdout_file " 2> " $_stderr_file " || _exit_code=$?
86+
8487 # Check the command's output:
85- _test_stdout=" $( cat " $_stdout_file " ) "
88+ _test_stdout=" $( sort < " $_stdout_file " ) "
8689 _test_stderr=" $( cat " $_stderr_file " ) "
90+
8791 _test_passed=true
8892 _failure_reason=" "
8993 # Check stdout - either exact match or pattern match:
@@ -183,39 +187,39 @@ cleanup_test_dir() {
183187test_basic_functionality () {
184188 run_test " List specific file" " $FF_PATH file1.txt" --stdout " ./file1.txt"
185189 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"
190+ run_test " Pattern with extension" " $FF_PATH '*.py'" --stdout " ./dir1/subdir1/deep_file .py
191+ ./file2 .py"
188192 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
193+ run_test " All files with 'file' in name" " $FF_PATH -d 2 file" --stdout " ./dir1/nested_file.txt
194+ ./dir2/another_file.log
195+ ./file1.txt
190196./file2.py
191197./file3.log
192- ./file with spaces.txt
193198./file-with-dashes.txt
199+ ./file with spaces.txt
194200./file_with_underscores.txt
195- ./dir1/nested_file.txt
196- ./dir2/another_file.log
197201./link_to_file1"
198202}
199203
200204test_options () {
201- run_test " Hidden files included" " $FF_PATH -H hidden" --stdout " ./.hidden_file
202- ./.hidden_dir "
205+ run_test " Hidden files included" " $FF_PATH -H hidden" --stdout " ./.hidden_dir
206+ ./.hidden_file "
203207 run_test " Hidden files excluded by default" " $FF_PATH hidden" --stdout " "
204208 run_test " Type file - limited to specific files" " $FF_PATH -t f -e txt file1" --stdout " ./file1.txt"
205209 run_test " Type directory" " $FF_PATH -t d dir" --stdout " ./dir1
206210./dir1/subdir1
207211./dir2
208212./dir2/subdir2"
209- run_test " Extension py" " $FF_PATH -e py" --stdout " ./file2 .py
210- ./dir1/subdir1/deep_file .py"
213+ run_test " Extension py" " $FF_PATH -e py" --stdout " ./dir1/subdir1/deep_file .py
214+ ./file2 .py"
211215 run_test " Extension txt" " $FF_PATH -e txt file1" --stdout " ./file1.txt"
212216 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 "
217+ run_test " Max depth 2" " $FF_PATH -d 2 nested" --stdout " ./deep/nested
218+ ./dir1/nested_file.txt "
215219 run_test " Full path matching" " $FF_PATH -p dir1" --stdout " ./dir1
220+ ./dir1/nested_file.txt
216221./dir1/subdir1
217222./dir1/subdir1/deep_file.py
218- ./dir1/nested_file.txt
219223./link_to_dir1"
220224 run_test " Exclude pattern - log files" " $FF_PATH -E '*log*' script" --stdout " ./script.sh"
221225 run_test " Follow links" " $FF_PATH -L -t f link" --stdout " ./link_to_file1"
@@ -243,8 +247,8 @@ test_color_options() {
243247
244248test_path_formats () {
245249 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 "
250+ run_test " Specific search path" " $FF_PATH file dir1" --stdout " dir1/nested_file.txt
251+ dir1/subdir1/deep_file.py "
248252}
249253
250254test_complex_scenarios () {
0 commit comments