
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng ChangeLog: 2008-09-02 Maxime van Noppen <yabo@lrde.epita.fr> Add tests for scool's translator. * config: Add test configuration for Scool's translator. * check.sh: Various fixes to properly handle multiple tests. --- check.sh | 28 +++++++++++++++++++++------- config | 20 +++++++++++++++++++- 2 files changed, 40 insertions(+), 8 deletions(-) Index: branches/scool-ng/tests/config =================================================================== --- branches/scool-ng/tests/config (revision 69) +++ branches/scool-ng/tests/config (revision 70) @@ -1,13 +1,31 @@ -number_of_tests=1 +number_of_tests=2 test_1 () { + desc="Scool parser" cmd='sglri -p ../../src/scl-syn/Scool.tbl -i $input_file' cmp='diff -EwbB -u $ref $output' print_input_cmd='cat $input_file' print_output_cmd='pp-aterm -i $input_file' input_files="scool_src/*.scl" + input_extension=".scl" + ref_dir="scool_ast" ref_extension=".aterm" } + +test_2 () +{ + desc="Scool AST -> C++ AST" + cmd='../../src/scoolt/scoolt -i $input_file' + cmp='diff -EwbB -u $ref $output' + print_input_cmd='pp-aterm -i $input_file' + print_output_cmd='pp-aterm -i $input_file' + + input_files="scool_ast/*.aterm" + input_extension=".aterm" + + ref_dir="cxx_ast" + ref_extension=".aterm" +} Index: branches/scool-ng/tests/check.sh =================================================================== --- branches/scool-ng/tests/check.sh (revision 69) +++ branches/scool-ng/tests/check.sh (revision 70) @@ -27,19 +27,19 @@ perform_test() { cexit_val=0 - test_name=`basename "$1" .scl` + test_name=`basename "$1" "$2"` input_file="$1" - ref=${2}/${test_name}${3} + ref=${3}/${test_name}${4} cmd_log=`mktemp` cmd_err=`mktemp` cmp_log=`mktemp` cmp_err=`mktemp` - rcmd=`echo $4 | sed s#'$input_file'#$input_file#g` + rcmd=`echo $5 | sed s#'$input_file'#$input_file#g` - rcmp=`echo $5 | sed s#'$ref'#$ref#g` + rcmp=`echo $6 | sed s#'$ref'#$ref#g` rcmp=`echo $rcmp | sed s#'$output'#$cmd_log#g` indent $utest_name_indent @@ -91,7 +91,7 @@ else echo -ne "${byell}sk"; fi - echo -e " $bblue]" + echo -n -e " $bblue]" } print_output() @@ -129,9 +129,12 @@ test_config="test_$testnb" eval $test_config + echo -e "${bgreen} Test $testnb : $desc" + if [ "`echo $input_files`" = "$input_files" ]; then echo ; cd ..; return; fi + for input_file in `ls $input_files` do - perform_test "$input_file" "$ref_dir" "$ref_extension" "$cmd" "$cmp" + perform_test "$input_file" "$input_extension" "$ref_dir" "$ref_extension" "$cmd" "$cmp" exit_val=$? indent $test_result_indent @@ -146,6 +149,7 @@ print_test_result "ko" if [ $print_diff -eq 1 ]; then + echo if [ $exit_val -eq 2 ]; then echo -ne $grey; cat $cmd_log $cmd_err echo -n @@ -155,6 +159,9 @@ fi fi + if [ $print_cmd -eq 1 ]; then echo -n -e ${grey} "$rcmd"; fi + echo + # Print the input if the -p option was provided if [ $print -eq 1 ]; then if [ $flush_sk -eq 1 ]; then @@ -176,6 +183,7 @@ print_output $cmd_log fi done + echo done cd .. @@ -192,6 +200,7 @@ -sk | --flush-skip Print the command output (if any) on successful tests -p | --print Print the input of the command -pa | --print-all Print all inputs + -pc | --print-command Prints the command used for the test -h | --help Print this help message " } @@ -200,6 +209,7 @@ gen_ref=0 flush_sk=0 print_all=0 +print_cmd=0 print=0 # Parse command line options while [ $# -gt 0 ] @@ -221,10 +231,14 @@ print=1 ;; - -pa | --pall) + -pa | --print-all) print_all=1 ;; + -pc | --print-command) + print_cmd=1 + ;; + -h | --help) print_help exit 0