From 24813c78fb4d1233bf0bd81bfce4b33ad8cb5e6a Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 11 Oct 2021 16:38:05 +0300 Subject: [PATCH] Natural ordering of @goal @glob is broken #64 --- makesure.awk | 5 +++-- tests/22_nat_order.tush | 25 +++++++++++++++++++++++++ tests/22_nat_order/Makesurefile | 6 ++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/22_nat_order/Makesurefile diff --git a/makesure.awk b/makesure.awk index e91597a..c7808ab 100755 --- a/makesure.awk +++ b/makesure.awk @@ -109,7 +109,8 @@ function prepareArgs( i,arg) { Options["timing"] } -#function dbgA(name, arr, i) { print "--- " name ": "; for (i in arr) print i " : " arr[i] } +#function dbgA(name, arr, i) { print "--- " name ": "; for (i in arr) printf "%2s : %s\n", i, arr[i] } +#function dbgAO(name, arr, i) { print "--- " name ": "; for (i=0;i in arr;i++) printf "%2s : %s\n", i, arr[i] } function splitKV(arg, kv, n) { n = index(arg, "=") @@ -660,7 +661,7 @@ function natOrder(s1,s2, i1,i2, c1, c2, n1,n2) { } # consume till equal substrings - while ((c1 = substr(s1,i1,1)) == (c2 = substr(s2,i2,1)) && c1 != "") { + while ((c1 = substr(s1,i1,1)) == (c2 = substr(s2,i2,1)) && c1 != "" && !_digit(c1)) { i1++; i2++ } diff --git a/tests/22_nat_order.tush b/tests/22_nat_order.tush index f7cc22e..542475b 100644 --- a/tests/22_nat_order.tush +++ b/tests/22_nat_order.tush @@ -22,3 +22,28 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/22_nat_order.sh nat_order_test | 19_optimize_goals.tush | 20_list_goals.tush | 21_parsing.tush + +$ cd "$MYDIR"; ./$MAKESURE -f tests/22_nat_order nat_order_test +| ../0_basic.tush +| ../1_goals.tush +| ../2_mydir.tush +| ../3_loop.tush +| ../4_trace.tush +| ../5_shell.tush +| ../6_reached_if.tush +| ../7_options.tush +| ../8_timing.tush +| ../9_prelude.tush +| ../10_define.tush +| ../11_goal_glob.tush +| ../12_errors.tush +| ../13_doc.tush +| ../14_private.tush +| ../15_lib.tush +| ../16_prelude_fail.tush +| ../17_empty_prelude.tush +| ../18_vars_priority.tush +| ../19_optimize_goals.tush +| ../20_list_goals.tush +| ../21_parsing.tush + diff --git a/tests/22_nat_order/Makesurefile b/tests/22_nat_order/Makesurefile new file mode 100644 index 0000000..75bf4c3 --- /dev/null +++ b/tests/22_nat_order/Makesurefile @@ -0,0 +1,6 @@ + +@options silent + +@goal nat_order_test @glob ../*.tush +@reached_if [[ $INDEX -ge 22 ]] # only check the correct order on first 22 tests + echo "$ITEM"