search_tests.sh: Update to the new format of `listfull.sh`
authorJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Sat, 3 Jun 2017 05:53:37 +0000 (01:53 -0400)
committerJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Sat, 3 Jun 2017 17:56:22 +0000 (13:56 -0400)
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

tests/search_tests.sh

index c4e3593..73844f6 100755 (executable)
@@ -51,13 +51,23 @@ for f in "$@"; do
                        b=`basename -- "$f"`
                        ;;
        esac
+
        # remove bad chars
-       c=`echo "$b" | sed 's/\([\\.*^$]\|\[\|]\)/./g'`
+       c="$(printf '%s\n' "$b" | sed '
+               # POSIX BRE metacharacters -> .
+               s/[\\.*^$]\|\[\|]/./g
+
+               # Escape the apostrophe the same way than `listfull.sh`,
+               # then re-escape in POSIX BRE.
+               # x -> x\\xx (where `x` is the apostrophe)
+               s/'\''/'\''\\\\'\'\''/g
+       ')"
+
        # Remove alts of args test variations
        c=`echo "$c" | sed 's/\(_[0-9]*alt[0-9][0-9]*\)/\\\\(\1\\\\)\\\\?/g;s/\(_args[0-9][0-9]*\)/\\\\(\1\\\\)\\\\?/'`
        b=`echo "$b" | sed 's/_[0-9]*alt[0-9][0-9]*//g;s/_args[0-9][0-9]*//'`
        # Search the orig nit file in the list
-       cat listfull.out | grep -- "\(^\|/\)$c.nit" || {
+       cat listfull.out | grep -- "\(^'\|/\)$c.nit" || {
                res=1
                echo >&2 "No test $b.nit found for $f"
                test "$verbose" == "true" || continue