Skip to content

Commit 303ef47

Browse files
committed
Get rid of options in test filenames (part 1).
This commit adds a comment with options to the beginning of each .re file. Because of the added line all test results had to be updated (line numbers in line directives, error messages, warnings, etc. have increased by one). The testing script run_test.sh has been changed to use options in the comments rather than options in the filenames. Conversion has been done almost automatically (except for a few rare tricky cases) with the following horrible Bash script: #!/bin/bash for f in `find . -name '*.re'`; do switches=`basename "$f" | sed \ -e 's/^[^.]*\.re$//g' \ -e 's/^[^.]*\.\(.*\)\.re$/\1/g' \ -e 's,[+],/,g' \ -e 's/^\([^-]\)/-\1/' \ -e 's/--\([^ (-]*\)/ --\1/g' \ -e 's/(\([^)]*\))/ \1/g' \ ` ext=`basename "$f" | grep -q -- '--lang(go)' && echo go || echo c` x="${f%.re}.$ext" ff="$f.mod" xx="$x.mod" linedirs=`egrep -q -- '(#|//)line' "$x" && echo 1 || echo 0` dot=`echo "$switches" | fgrep -q -- ' --emit-dot' && echo 1 || echo 0` skel=`echo "$switches" | fgrep -q -- ' --skeleton' && echo 1 || echo 0` if [ $ext == c ]; then l='// re2c $INPUT -o $OUTPUT '"$switches" else switches=`echo "$switches" | sed 's/ --lang go//'` l='//go:generate re2go $INPUT -o $OUTPUT '"$switches" fi nocomment=0 if [ "$(tail -n 1 $x | fgrep -q 'error: ' ; echo $?)" -eq 0 ]; then nocomment=1 elif [ $dot -eq 1 ]; then nocomment=1 elif [ $skel -eq 1 ]; then nocomment=1 fi echo "$l" > "$ff" cat "$f" >> "$ff" if [ $linedirs -eq 0 ]; then head -n 1 "$x" > "$xx" if [ $nocomment -eq 0 ]; then echo "$l" >> "$xx"; fi tail -n +2 "$x" >> "$xx" else head -n 2 "$x" > "$x.head" tail -n +3 "$x" > "$x.tail" if [ $nocomment -eq 0 ]; then echo "$l" >> "$x.head"; fi if [ $ext == c ]; then e='s/^([ \t]*#line )([0-9]+)(.*\.re"|.*\.c")$/($1).($2+1).($3)/eg' else e='s/^(\/\/line ".*".)([0-9]+)$/($1).($2+1)/eg' fi perl -p -i -e "$e" "$x.tail" cat "$x.head" "$x.tail" > "$xx" rm "$x.head" "$x.tail" fi a="$(basename $f | sed -E -e 's/([()])/\\\1/g' -e 's/\./\\./g')" perl -p -i -e 's/^(.*'"$a"'[:(])([0-9]+)(.*)$/($1).($2+1).($3)/eg' "$xx" perl -p -i -e 's/^(.*shadowed by rule at line )([0-9]+)(.*)$/($1).($2+1).($3)/eg' "$xx" perl -p -i -e 's/^(.* already defined at line )([0-9]+)(.*)$/($1).($2+1).($3)/eg' "$xx" if [ $skel -eq 1 ]; then perl -p -i -e 's/^(.*[_.]line)([0-9]+)(.*)$/($1).($2+1).($3)/eg' "$xx" fi done find . -name '*.re' -o -name '*.c' -o -name '*.go' | xargs rm for f in `find . -name '*.mod'` ; do mv "$f" "${f%.mod}" ; done
1 parent 316c02d commit 303ef47

File tree

3,780 files changed

+17678
-14285
lines changed