exit 1;
}
+# split_objs=""
+# if test $split_iters != "$gen_opt"; then
+# n=0;
+# while test $n -lt $split_iters; do
+# part_root=${root}_`awk 'BEGIN {
+# width = 0;
+# high = '$split_iters' - 1;
+# while ( high > 0 ) {
+# width = width + 1;
+# high = int(high / 10);
+# }
+# suffFormat = "%" width "." width "d\n";
+# printf( suffFormat, '$n' );
+# exit 0;
+# }'`
+# part_src=${part_root}.c
+# part_bin=${part_root}.o
+# echo "$compiler -c $cflags -o $part_bin $part_src"
+# if ! $compiler -c $cflags -o $part_bin $part_src; then
+# test_error;
+# fi
+# split_objs="$split_objs $part_bin"
+# n=$((n+1))
+# done
+# fi
+
+function run_test()
+{
+ echo "$ragel $min_opt $lang_opt $test_case | $codegen $gen_opt -o $code_src"
+ if ! $ragel $min_opt $lang_opt $test_case | $codegen $gen_opt -o $code_src; then
+ test_error;
+ fi
+
+ out_args=""
+ [ $lang != java ] && out_args="-o ${binary}";
+
+ # Ruby doesn't need to be compiled.
+ if [ $lang != ruby ]; then
+ echo "$compiler ${cflags} ${out_args} ${code_src}"
+ if ! $compiler ${cflags} ${out_args} ${code_src}; then
+ test_error;
+ fi
+ fi
+
+ if [ "$compile_only" != "true" ]; then
+ echo -n "running $root ... ";
+
+ exec_cmd=./$binary
+ [ $lang = java ] && exec_cmd="java $root"
+ [ $lang = ruby ] && exec_cmd="ruby ${code_src}"
+
+ $exec_cmd 2>&1 > $output;
+ if diff $expected_out $output > /dev/null; then
+ echo "passed";
+ else
+ echo "FAILED";
+ test_error;
+ fi;
+ fi
+}
+
for test_case; do
root=${test_case%.rl};
allow_minflags=`sed '/@ALLOW_MINFLAGS:/s/^.*: *//p;d' $test_case`
[ -z "$allow_minflags" ] && allow_minflags="-n -m -l -e"
-
- # If we are in java or ruby then we are not interested in genflags
case $lang in
c|c++|objc|d)
# Using genflags, get the allowed gen flags from the test case. If the
# test case doesn't specify assume that all gen flags are allowed.
allow_genflags=`sed '/@ALLOW_GENFLAGS:/s/^.*: *//p;d' $test_case`
[ -z "$allow_genflags" ] && allow_genflags="-T0 -T1 -F0 -F1 -G0 -G1 -G2"
- ;;
- *)
- # Not interested in gen flags.
- allow_genflags=noflags
- genflags=noflags
- ;;
- esac
- for min_opt in $minflags; do
- for gen_opt in $genflags; do
+ for min_opt in $minflags; do
echo "$allow_minflags" | grep -e $min_opt >/dev/null || continue
- grep_gen_opt=${gen_opt}
- split_iters=${gen_opt#-P}
- if test $split_iters != $gen_opt; then
- grep_gen_opt="-P";
- fi
- echo "$allow_genflags" | grep -e $grep_gen_opt >/dev/null || continue
-
- if [ "$genflags" == noflags ]; then
- be_gen_opt=""
- else
- be_gen_opt=$gen_opt
- fi
-
- echo "$ragel $min_opt $lang_opt $test_case | $codegen $be_gen_opt -o $code_src"
- if ! $ragel $min_opt $lang_opt $test_case | $codegen $be_gen_opt -o $code_src; then
- test_error;
- fi
-
- split_objs=""
- if test $split_iters != "$gen_opt"; then
- n=0;
- while test $n -lt $split_iters; do
- part_root=${root}_`awk 'BEGIN {
- width = 0;
- high = '$split_iters' - 1;
- while ( high > 0 ) {
- width = width + 1;
- high = int(high / 10);
- }
- suffFormat = "%" width "." width "d\n";
- printf( suffFormat, '$n' );
- exit 0;
- }'`
- part_src=${part_root}.c
- part_bin=${part_root}.o
- echo "$compiler -c $cflags -o $part_bin $part_src"
- if ! $compiler -c $cflags -o $part_bin $part_src; then
- test_error;
- fi
- split_objs="$split_objs $part_bin"
- n=$((n+1))
- done
- fi
-
- out_args=""
- [ $lang != java ] && out_args="-o ${binary}";
-
- # Ruby doesn't need to be compiled.
- if [ $lang != ruby ]; then
- echo "$compiler ${cflags} ${out_args} ${code_src}"
- if ! $compiler ${cflags} ${out_args} ${code_src}; then
- test_error;
- fi
- fi
-
- if [ "$compile_only" != "true" ]; then
- echo -n "running $root ... ";
-
- exec_cmd=./$binary
- [ $lang = java ] && exec_cmd="java $root"
- [ $lang = ruby ] && exec_cmd="ruby ${code_src}"
-
- $exec_cmd 2>&1 > $output;
- if diff $expected_out $output > /dev/null; then
- echo "passed";
- else
- echo "FAILED";
- test_error;
- fi;
- fi
+ for gen_opt in $genflags; do
+ echo "$allow_genflags" | grep -e $gen_opt >/dev/null || continue
+ run_test
+ done
done
- done
+ ;;
+
+ java|ruby)
+ # Not interested in gen opt.
+ gen_opt=""
+ for min_opt in $minflags; do
+ echo "$allow_minflags" | grep -e $min_opt >/dev/null || continue
+ run_test
+ done
+ ;;
+ esac
+
done