@@ -170,30 +170,9 @@ process_file() {
170
170
DEBUG " ==========================================================================="
171
171
172
172
# #########################################################
173
- # Decide (Well try to Guess) which is the hyperon_results (.answers file)
173
+ # The hyperon_results (.answers file)
174
174
# #########################################################
175
- export hyperon_results=(${file} \. .* ) # gets any other names as well
176
- # List of excluded extensions
177
- # (because now that any file can be an answer file we need to still be able to use test directories for test that
178
- # use things besides metta files such as
179
- # buffer_test.metta.md uses_config_test.metta.mettalogrc )
180
- # We really need a naming convertion for those generate file names that doenst already conflict with the test framework names
181
- # current conflicts are
182
- #
183
- # transpile_test.metta.pl (the prolog version of the transpilation)
184
- # test.metta.html (created on test output for web results . (stored elsewhere most of the time))
185
- # large_file.metta.datalog - Created for test files larger than 20mb
186
- # uses_config_test.metta.mettalogrc currently used for configs
187
- # a_mork_test.metta.xml ( XML translated metta files )
188
- # a_jetta_test.metta.js ( Tests created by Adam )
189
- # test.metta.bak (file backups)
190
- #
191
- # Perhaps Stassa might use a predicatable naming convention that can be filtered
192
- # test_error -> result_test_error
193
- # unknown_error -> result_unknown_error
194
- excluded_extensions=( " tmp" " bak" " html" " ~" " sav" " ansi" " pl" " csv"
195
- " py" " txt" " md" " tee" " o" " dll" " so" " exe" " sh" " text" " rc"
196
- " mettalogrc" " bat" " c" " java" " datalog" " in" " out" " xml" " obo" )
175
+ export hyperon_results=(${file} \. answers) # gets any other names as well
197
176
198
177
local base_name=" $absfile "
199
178
test_local_dir=$( dirname " $base_name " )
@@ -217,49 +196,18 @@ process_file() {
217
196
esac
218
197
done < " $rcfile "
219
198
fi
220
-
199
+
221
200
# #########################################################
222
201
# Decide whether or not to run hyperon test
223
202
# #########################################################
224
203
local take_hyperon_test=false
225
- if [[ " $no_regen " -eq 1 ]]; then
204
+ if [[ " $regen_hyperon_results " -eq 0 ]]; then
226
205
take_hyperon_test=false
227
- DEBUG_H_E " --no- regen flag is set. Disabling generation of $file .answers"
206
+ DEBUG_H_E " --regen flag is not set. Disabling generation of $file .answers"
228
207
else
229
- local file_found=false
230
- # Loop over all potential files matching the base pattern
231
- for potential_file in " ${base_name} \." .* ; do
232
- # Extract the extension of the file
233
- extension=" ${potential_file##* .} "
234
- exclude_item=false
235
-
236
- # Check if the extracted extension is in the excluded list
237
- for excluded in " ${excluded_extensions[@]} " ; do
238
- if [[ " $extension " == " $excluded " ]]; then
239
- exclude_item=true
240
- break
241
- fi
242
- done
243
-
244
- # If the extension is not in the excluded list, use the file
245
- if [ -f " $potential_file " ]; then
246
- if [[ " $exclude_item " == true ]]; then
247
- DEBUG_H_E " Skipped $potential_file "
248
- else
249
- DEBUG_H_E " Found $potential_file "
250
- export hyperon_results=$potential_file
251
- file_found=true
252
- break # break if you only need the first match
253
- fi
254
- fi
255
- if [[ " $file_found " == true ]]; then
256
- break
257
- fi
258
- done
259
208
260
209
# Check if no file was found
261
- if [[ " $file_found " == false ]]; then
262
- export hyperon_results=" ${base_name} .answers"
210
+ if [[ ! -f " ${hyperon_results} " ]]; then
263
211
DEBUG_H_E " No alternate answer file extension: defaulting to ${hyperon_results} file."
264
212
take_hyperon_test=true
265
213
else
@@ -382,11 +330,8 @@ process_file() {
382
330
383
331
if [ -f " ${hyperon_results} " ]; then
384
332
if grep -q " Got" " ${hyperon_results} " ; then
385
- DEBUG_H_E " ${RED} Failures in Rust Answers ${hyperon_results} assumed should be ${file} .test_error ${NC} "
386
- if [[ " ${hyperon_results} " != " ${file} .test_error" ]]; then
387
- cat " ${hyperon_results} " > " ${file} .test_error"
388
- export hyperon_results=" ${file} .test_error"
389
- fi
333
+ DEBUG_H_E " ${RED} Failures in Rust Answers ${hyperon_results}${NC} "
334
+ echo ERROR_INFO >> " ${hyperon_results} "
390
335
fi
391
336
echo INFO >> " ${hyperon_results} "
392
337
fi
@@ -598,7 +543,7 @@ run_tests_auto_reply=""
598
543
generate_report_auto_reply=" "
599
544
METTALOG_OUTPUT=" $METTALOG_DIR /reports/tests_output/testrun_$( date +%Y%m%d_%H%M%S) "
600
545
fresh=0
601
- no_regen =0
546
+ regen_hyperon_results =0
602
547
clean=0 # 0 means don't clean, 1 means do clean
603
548
if_failures=0
604
549
if_regressions=0
@@ -745,7 +690,7 @@ find_test_masks() {
745
690
files_with_exclamation+=(" $subfile " )
746
691
fi
747
692
fi
748
- done < <( find " $file " -type f -print0)
693
+ done < <( find -L " $file " -type f -print0)
749
694
fi
750
695
fi
751
696
done
@@ -762,15 +707,15 @@ function add_test_units_dir() {
762
707
763
708
# set +v
764
709
DEBUG " Finding files with 'test' in their name and apply $EXTRA_FIND_ARGS ..."
765
- mapfile -t test_files < <( find " ${BASE_DIR} " $EXTRA_FIND_ARGS -type f -iname " *test*.metta" )
710
+ mapfile -t test_files < <( find -L " ${BASE_DIR} " $EXTRA_FIND_ARGS -type f -iname " *test*.metta" )
766
711
DEBUG " 'Test' files found: ${# test_files[@]} "
767
712
768
713
DEBUG " Finding files containing 'assert' keyword and apply $MUST_HAVE ..."
769
- mapfile -t assert_files < <( find " ${BASE_DIR} " $EXTRA_FIND_ARGS -type f -name ' *.metta' -print0 | xargs -0 grep -rl ' assert' -- $GREP_ARGS )
714
+ mapfile -t assert_files < <( find -L " ${BASE_DIR} " $EXTRA_FIND_ARGS -type f -name ' *.metta' -print0 | xargs -0 grep -rl ' assert' -- $GREP_ARGS )
770
715
DEBUG " Assert<*> files found: ${# assert_files[@]} "
771
716
772
717
DEBUG " Finding files containing execution directive (lines starting with '!') and apply $MUST_HAVE ..."
773
- mapfile -t has_tests < <( find " ${BASE_DIR} " $EXTRA_FIND_ARGS -type f -name ' *.metta' -print0 | xargs -0 grep -rl ' ^!\([^!]*\)$' -- $GREP_ARGS )
718
+ mapfile -t has_tests < <( find -L " ${BASE_DIR} " $EXTRA_FIND_ARGS -type f -name ' *.metta' -print0 | xargs -0 grep -rl ' ^!\([^!]*\)$' -- $GREP_ARGS )
774
719
DEBUG " Test directive files found: ${# has_tests[@]} "
775
720
776
721
@@ -923,7 +868,7 @@ show_help() {
923
868
echo " -y|--yes Automatically choose 'y' for rerunning all tests"
924
869
echo " -n|--no Automatically choose 'n'"
925
870
echo " --fresh Clean up by deleting any .answers files under directory"
926
- echo " --no- regen Do not create/recreate .answers files"
871
+ echo " --regen Update missing or stale .answers files"
927
872
echo " --clean Clean up by deleting all .html files under directory"
928
873
echo " --continue The default. Continue running tests (Generating any missing html files)"
929
874
echo " --failures Rerun Unsuccessful tests"
@@ -1031,7 +976,7 @@ while [ "$#" -gt 0 ]; do
1031
976
--dry-run) dry_run=1 ;;
1032
977
--test) dry_run=0 ; add_to_list " $1 " passed_along_to_mettalog ;;
1033
978
--fresh) fresh=1 ;;
1034
- --no- regen* ) no_regen =1 ;;
979
+ --regen* ) regen_hyperon_results =1 ;;
1035
980
--v=* ) PYSWIP_VERSION=" ${1#* =} " ; add_to_list " $1 " passed_along_to_mettalog ;;
1036
981
--exclude=* ) EXTRA_FIND_ARGS+=" ! -path ${1#* =} " ; CANT_HAVE=" ${1#* =} " ;;
1037
982
--include=* ) EXTRA_FIND_ARGS+=" -path ${1#* =} " ; MUST_HAVE=" ${1#* =} " ;;
0 commit comments