From c3c88aa65d906c13c93e1bca2667871adb749d4f Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Sat, 29 Dec 2018 14:17:31 +0000 Subject: [PATCH] More tests for include directive. --- re2c/run_tests.sh.in | 27 ++- .../include/{include001a.c => include001.c} | 18 +- re2c/test/include/include001.re | 6 + re2c/test/include/include001.re.b.inc | 5 + .../{include001c.re => include001.re.c.inc} | 0 re2c/test/include/include001a.re | 6 - re2c/test/include/include001b.c | 8 - re2c/test/include/include001b.re | 5 - re2c/test/include/include001c.c | 4 - re2c/test/include/include002.c | 184 ++++++++++++++++++ re2c/test/include/include002.re | 15 ++ re2c/test/include/include003.c | 38 ++++ re2c/test/include/include003.re | 8 + re2c/test/include/include003.re.b.inc | 3 + re2c/test/include/include003.re.c.inc | 3 + re2c/test/include/nested/include002.re.b.inc | 16 ++ re2c/test/include/nested/include002.re.c.inc | 17 ++ .../nested/nested/include002.re.bd.inc | 3 + .../nested/nested/include002.re.be.inc | 3 + .../nested/nested/include002.re.cd.inc | 3 + .../nested/nested/include002.re.ce.inc | 3 + 21 files changed, 329 insertions(+), 46 deletions(-) rename re2c/test/include/{include001a.c => include001.c} (53%) create mode 100644 re2c/test/include/include001.re create mode 100644 re2c/test/include/include001.re.b.inc rename re2c/test/include/{include001c.re => include001.re.c.inc} (100%) delete mode 100644 re2c/test/include/include001a.re delete mode 100644 re2c/test/include/include001b.c delete mode 100644 re2c/test/include/include001b.re delete mode 100644 re2c/test/include/include001c.c create mode 100644 re2c/test/include/include002.c create mode 100644 re2c/test/include/include002.re create mode 100644 re2c/test/include/include003.c create mode 100644 re2c/test/include/include003.re create mode 100644 re2c/test/include/include003.re.b.inc create mode 100644 re2c/test/include/include003.re.c.inc create mode 100644 re2c/test/include/nested/include002.re.b.inc create mode 100644 re2c/test/include/nested/include002.re.c.inc create mode 100644 re2c/test/include/nested/nested/include002.re.bd.inc create mode 100644 re2c/test/include/nested/nested/include002.re.be.inc create mode 100644 re2c/test/include/nested/nested/include002.re.cd.inc create mode 100644 re2c/test/include/nested/nested/include002.re.ce.inc diff --git a/re2c/run_tests.sh.in b/re2c/run_tests.sh.in index cf51be74..981f0666 100644 --- a/re2c/run_tests.sh.in +++ b/re2c/run_tests.sh.in @@ -24,13 +24,6 @@ lc_run() { LANG=C LC_ALL=C "$@" } -abspath() { - case "$1" in - /*) echo "$1";; - *) echo "$PWD/$1";; - esac -} - valgrind="" skeleton=0 keep_tmp_files=0 @@ -65,14 +58,16 @@ test_blddir="test_"`date +%y%m%d%H%M%S` rm -rf $test_blddir && mkdir $test_blddir # preserve directory structure unless given explicit args +testdirs= if [ ${#tests[@]} -eq 0 ]; then - cp -R "@top_srcdir@/test"/* "@top_srcdir@/examples"/* $test_blddir - incpaths=`find "@top_srcdir@/test" "@top_srcdir@/examples" -type d -exec echo "-I $(abspath {})" \;` + for d in "@top_srcdir@/test" "@top_srcdir@/examples" ; do + testdirs="$testdirs $(find $d -type d)" + cp -R $d/* $test_blddir + done else - incpaths= for f in ${tests[@]}; do cp $f ${f%.re}.c $test_blddir - incpaths="$incpaths -I $(abspath $(dirname $f))" + testdirs="$testdirs $(dirname $f)" done fi chmod -R u+w $test_blddir @@ -141,7 +136,7 @@ run_pack() { # file extensions are case-insensitive on some platforms printf "%s" "$switches" | lc_run grep -q "[A-Z]" \ && { echo "bad file extension: '$outx' (uppercase letters are not allowed)"; exit 1; } - local switches="$switches $incpaths -o $outc --no-version --no-generation-date" + local switches="$switches -o $outc --no-version --no-generation-date" # enable warnings globally local switches="$switches -W" @@ -149,9 +144,11 @@ run_pack() { then rm -f "$outc" + incpaths=; for d in $testdirs; do incpaths="$incpaths -I ../$d"; done + local switches="$switches --skeleton -Werror-undefined-control-flow" - ${valgrind} ${wine} ../${re2c} $switches "../$x" 2>"$outc.stderr" + ${valgrind} ${wine} ../${re2c} $incpaths $switches "../$x" 2>"$outc.stderr" local status=$(echo $?) [ $status -eq 0 ] && { @CC@ -Wall -Wextra -o "$outc.out" "$outc" 2>>"$outc.stderr" || status=2; } [ $status -eq 0 ] && { ./"$outc.out" 2>>"$outc.stderr" || status=3; } @@ -174,6 +171,8 @@ run_pack() { local c="${outx%.re}.c.orig" mv "$outc" "$c" + incpaths=; for d in $testdirs; do incpaths="$incpaths -I ../../$d"; done + # create sandbox tmpdir="tmp_$log" \ && mkdir "$tmpdir" \ @@ -181,7 +180,7 @@ run_pack() { && mkdir -p `dirname "$outx"` \ && cp "../../$x" "$outx" # run re2c - $valgrind $wine ../../$re2c $switches "$outx" 2>"$outc.stderr" 1>&2 + $valgrind $wine ../../$re2c $incpaths $switches "$outx" 2>"$outc.stderr" 1>&2 # on windows output contains CR LF, cut CR to match test results for f in "$outc" "$outc.stderr"; do [ -f "$f" ] \ diff --git a/re2c/test/include/include001a.c b/re2c/test/include/include001.c similarity index 53% rename from re2c/test/include/include001a.c rename to re2c/test/include/include001.c index b0c1c25b..c1a634ed 100644 --- a/re2c/test/include/include001a.c +++ b/re2c/test/include/include001.c @@ -1,15 +1,15 @@ /* Generated by re2c */ -#line 1 "include/include001a.re" -#line 3 "include001c.re" +#line 1 "include/include001.re" +#line 3 "../../../test/include/include001.re.c.inc" -#line 5 "include001b.re" +#line 5 "../../../test/include/include001.re.b.inc" -#line 13 "include/include001a.c" +#line 13 "include/include001.c" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -22,15 +22,15 @@ yy2: yy3: ++YYCURSOR; -#line 4 "include/include001a.re" +#line 4 "include/include001.re" {} -#line 28 "include/include001a.c" +#line 28 "include/include001.c" yy5: ++YYCURSOR; -#line 5 "include/include001a.re" +#line 5 "include/include001.re" {} -#line 33 "include/include001a.c" +#line 33 "include/include001.c" } -#line 6 "include/include001a.re" +#line 6 "include/include001.re" re2c: warning: line 6: control flow is undefined for strings that match '[\x0-\x61\x64-\xFF]', use default rule '*' [-Wundefined-control-flow] diff --git a/re2c/test/include/include001.re b/re2c/test/include/include001.re new file mode 100644 index 00000000..70e610ff --- /dev/null +++ b/re2c/test/include/include001.re @@ -0,0 +1,6 @@ +/*!include:re2c "include001.re.b.inc" */ + +/*!re2c + b {} + c {} +*/ diff --git a/re2c/test/include/include001.re.b.inc b/re2c/test/include/include001.re.b.inc new file mode 100644 index 00000000..30ec4771 --- /dev/null +++ b/re2c/test/include/include001.re.b.inc @@ -0,0 +1,5 @@ +/*!include:re2c "include001.re.c.inc" */ + +/*!re2c + b = "b"; +*/ diff --git a/re2c/test/include/include001c.re b/re2c/test/include/include001.re.c.inc similarity index 100% rename from re2c/test/include/include001c.re rename to re2c/test/include/include001.re.c.inc diff --git a/re2c/test/include/include001a.re b/re2c/test/include/include001a.re deleted file mode 100644 index 21e4b1f7..00000000 --- a/re2c/test/include/include001a.re +++ /dev/null @@ -1,6 +0,0 @@ -/*!include:re2c "include001b.re" */ - -/*!re2c - b {} - c {} -*/ diff --git a/re2c/test/include/include001b.c b/re2c/test/include/include001b.c deleted file mode 100644 index b7ac2a55..00000000 --- a/re2c/test/include/include001b.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Generated by re2c */ -#line 1 "include/include001b.re" -#line 3 "include001c.re" - - - -#line 5 "include/include001b.re" - diff --git a/re2c/test/include/include001b.re b/re2c/test/include/include001b.re deleted file mode 100644 index 54dca6fd..00000000 --- a/re2c/test/include/include001b.re +++ /dev/null @@ -1,5 +0,0 @@ -/*!include:re2c "include001c.re" */ - -/*!re2c - b = "b"; -*/ diff --git a/re2c/test/include/include001c.c b/re2c/test/include/include001c.c deleted file mode 100644 index a757504a..00000000 --- a/re2c/test/include/include001c.c +++ /dev/null @@ -1,4 +0,0 @@ -/* Generated by re2c */ -#line 1 "include/include001c.re" -#line 3 "include/include001c.re" - diff --git a/re2c/test/include/include002.c b/re2c/test/include/include002.c new file mode 100644 index 00000000..224e3d91 --- /dev/null +++ b/re2c/test/include/include002.c @@ -0,0 +1,184 @@ +/* Generated by re2c */ +#line 1 "include/include002.re" + +#line 3 "../../../test/include/nested/nested/include002.re.bd.inc" + + + + +#line 10 "include/include002.c" +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'B': + case 'd': goto yy4; + default: goto yy2; + } +yy2: + ++YYCURSOR; +#line 7 "../../../test/include/nested/include002.re.b.inc" + {} +#line 24 "include/include002.c" +yy4: + ++YYCURSOR; +#line 6 "../../../test/include/nested/include002.re.b.inc" + {} +#line 29 "include/include002.c" +} +#line 8 "../../../test/include/nested/include002.re.b.inc" + + +#line 3 "../../../test/include/nested/nested/include002.re.be.inc" + + + + +#line 39 "include/include002.c" +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'B': + case 'e': goto yy10; + default: goto yy8; + } +yy8: + ++YYCURSOR; +#line 15 "../../../test/include/nested/include002.re.b.inc" + {} +#line 53 "include/include002.c" +yy10: + ++YYCURSOR; +#line 14 "../../../test/include/nested/include002.re.b.inc" + {} +#line 58 "include/include002.c" +} +#line 16 "../../../test/include/nested/include002.re.b.inc" + + + + +#line 65 "include/include002.c" +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '1': + case 'b': goto yy16; + case '2': goto yy18; + default: goto yy14; + } +yy14: + ++YYCURSOR; +#line 6 "include/include002.re" + {} +#line 80 "include/include002.c" +yy16: + ++YYCURSOR; +#line 4 "include/include002.re" + {} +#line 85 "include/include002.c" +yy18: + ++YYCURSOR; +#line 5 "include/include002.re" + {} +#line 90 "include/include002.c" +} +#line 7 "include/include002.re" + + + + +#line 3 "../../../test/include/nested/nested/include002.re.cd.inc" + + + + +#line 102 "include/include002.c" +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'C': + case 'd': goto yy24; + default: goto yy22; + } +yy22: + ++YYCURSOR; +#line 8 "../../../test/include/nested/include002.re.c.inc" + {} +#line 116 "include/include002.c" +yy24: + ++YYCURSOR; +#line 7 "../../../test/include/nested/include002.re.c.inc" + {} +#line 121 "include/include002.c" +} +#line 9 "../../../test/include/nested/include002.re.c.inc" + + +#line 3 "../../../test/include/nested/nested/include002.re.ce.inc" + + + + +#line 131 "include/include002.c" +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'C': + case 'e': goto yy30; + default: goto yy28; + } +yy28: + ++YYCURSOR; +#line 16 "../../../test/include/nested/include002.re.c.inc" + {} +#line 145 "include/include002.c" +yy30: + ++YYCURSOR; +#line 15 "../../../test/include/nested/include002.re.c.inc" + {} +#line 150 "include/include002.c" +} +#line 17 "../../../test/include/nested/include002.re.c.inc" + + + + +#line 157 "include/include002.c" +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case '1': + case 'c': goto yy36; + case '2': goto yy38; + default: goto yy34; + } +yy34: + ++YYCURSOR; +#line 14 "include/include002.re" + {} +#line 172 "include/include002.c" +yy36: + ++YYCURSOR; +#line 12 "include/include002.re" + {} +#line 177 "include/include002.c" +yy38: + ++YYCURSOR; +#line 13 "include/include002.re" + {} +#line 182 "include/include002.c" +} +#line 15 "include/include002.re" + diff --git a/re2c/test/include/include002.re b/re2c/test/include/include002.re new file mode 100644 index 00000000..9ca12162 --- /dev/null +++ b/re2c/test/include/include002.re @@ -0,0 +1,15 @@ +/*!include:re2c "nested/include002.re.b.inc" */ + +/*!re2c + b1 {} + b2 {} + * {} +*/ + +/*!include:re2c "nested/include002.re.c.inc" */ + +/*!re2c + c1 {} + c2 {} + * {} +*/ diff --git a/re2c/test/include/include003.c b/re2c/test/include/include003.c new file mode 100644 index 00000000..3fdef907 --- /dev/null +++ b/re2c/test/include/include003.c @@ -0,0 +1,38 @@ +/* Generated by re2c */ +#line 1 "include/include003.re" +#line 3 "../../../test/include/include003.re.b.inc" + + +#line 3 "../../../test/include/include003.re.c.inc" + + + + +#line 12 "include/include003.c" +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'b': goto yy4; + case 'c': goto yy6; + default: goto yy2; + } +yy2: + ++YYCURSOR; +#line 7 "include/include003.re" + {} +#line 26 "include/include003.c" +yy4: + ++YYCURSOR; +#line 5 "include/include003.re" + {} +#line 31 "include/include003.c" +yy6: + ++YYCURSOR; +#line 6 "include/include003.re" + {} +#line 36 "include/include003.c" +} +#line 8 "include/include003.re" + diff --git a/re2c/test/include/include003.re b/re2c/test/include/include003.re new file mode 100644 index 00000000..ece6e129 --- /dev/null +++ b/re2c/test/include/include003.re @@ -0,0 +1,8 @@ +/*!include:re2c "include003.re.b.inc" */ +/*!include:re2c "include003.re.c.inc" */ + +/*!re2c + b {} + c {} + * {} +*/ diff --git a/re2c/test/include/include003.re.b.inc b/re2c/test/include/include003.re.b.inc new file mode 100644 index 00000000..7d36c8b0 --- /dev/null +++ b/re2c/test/include/include003.re.b.inc @@ -0,0 +1,3 @@ +/*!re2c + b = "b"; +*/ diff --git a/re2c/test/include/include003.re.c.inc b/re2c/test/include/include003.re.c.inc new file mode 100644 index 00000000..a49fce0d --- /dev/null +++ b/re2c/test/include/include003.re.c.inc @@ -0,0 +1,3 @@ +/*!re2c + c = "c"; +*/ diff --git a/re2c/test/include/nested/include002.re.b.inc b/re2c/test/include/nested/include002.re.b.inc new file mode 100644 index 00000000..e623ee2c --- /dev/null +++ b/re2c/test/include/nested/include002.re.b.inc @@ -0,0 +1,16 @@ + +/*!include:re2c "nested/include002.re.bd.inc" */ + +/*!re2c + b1 = [b1]; + bd {} + * {} +*/ + +/*!include:re2c "nested/include002.re.be.inc" */ + +/*!re2c + b2 = [b2]; + be {} + * {} +*/ diff --git a/re2c/test/include/nested/include002.re.c.inc b/re2c/test/include/nested/include002.re.c.inc new file mode 100644 index 00000000..53c4316c --- /dev/null +++ b/re2c/test/include/nested/include002.re.c.inc @@ -0,0 +1,17 @@ + + +/*!include:re2c "nested/include002.re.cd.inc" */ + +/*!re2c + c1 = [c1]; + cd {} + * {} +*/ + +/*!include:re2c "nested/include002.re.ce.inc" */ + +/*!re2c + c2 = [c2]; + ce {} + * {} +*/ diff --git a/re2c/test/include/nested/nested/include002.re.bd.inc b/re2c/test/include/nested/nested/include002.re.bd.inc new file mode 100644 index 00000000..9562a1a8 --- /dev/null +++ b/re2c/test/include/nested/nested/include002.re.bd.inc @@ -0,0 +1,3 @@ +/*!re2c + bd = [Bd]; +*/ diff --git a/re2c/test/include/nested/nested/include002.re.be.inc b/re2c/test/include/nested/nested/include002.re.be.inc new file mode 100644 index 00000000..aeda5873 --- /dev/null +++ b/re2c/test/include/nested/nested/include002.re.be.inc @@ -0,0 +1,3 @@ +/*!re2c + be = [Be]; +*/ diff --git a/re2c/test/include/nested/nested/include002.re.cd.inc b/re2c/test/include/nested/nested/include002.re.cd.inc new file mode 100644 index 00000000..b8f04641 --- /dev/null +++ b/re2c/test/include/nested/nested/include002.re.cd.inc @@ -0,0 +1,3 @@ +/*!re2c + cd = [Cd]; +*/ diff --git a/re2c/test/include/nested/nested/include002.re.ce.inc b/re2c/test/include/nested/nested/include002.re.ce.inc new file mode 100644 index 00000000..a6ba6df2 --- /dev/null +++ b/re2c/test/include/nested/nested/include002.re.ce.inc @@ -0,0 +1,3 @@ +/*!re2c + ce = [Ce]; +*/ -- 2.40.0