3 # This script semdiff files with similar names e.g. myfile.1.hhas and
4 # myfile.2.hhas, and compares the result with the corresponding expected
5 # file e.g. myfile.semdiff.exp, or creates it if it does not exists with
6 # a .out extensnion e.g. myfile.semdiff.exp.out
9 echo 'ERROR: unexpected argument'
10 echo 'usage: run_semdiff_tests.sh'
19 BASEDIR
="$HOME/fbsource/fbcode"
20 BUCK
="$BASEDIR/tools/build/buck/bin/buck"
21 DIFF_TMP
=/tmp
/semdiff_tmp.exp
22 DIFF_RESULT
=/tmp
/diff_tmp.result
25 echo "compiling semdiff"
26 "$BUCK" build @mode
/dbgo
//hphp
/hack
/src
/hhbc
/semdiff
:semdiff
2> /dev
/null
27 SEMDIFF_PATH
=$
("$BUCK" targets
--show-output //hphp
/hack
/src
/hhbc
/semdiff
:semdiff
2> /dev
/null | cut
-d' ' -f2)
28 echo "retrieving path: $SEMDIFF_PATH"
30 HHAS_FILES
=$
(find "$BASEDIR"/hphp
/hack
/test
/semdiff
-type f
-name '*.1.hhas')
34 for FILE
in $HHAS_FILES; do
35 basename=${FILE%.1.hhas}
36 test_name
=${basename##*/}
37 "$SEMDIFF_PATH" "$FILE" "$basename.2.hhas" > "$DIFF_TMP"
38 if [ ! -f "$basename.semdiff.exp" ]
40 new_file
="$basename.semdiff.exp.out"
41 echo -e "\tcreating $YELLOW $test_name.semdiff.exp.out $NC"
42 mv "$DIFF_TMP" "$new_file"
44 test_name
=${basename##*/}
45 printf "\tdiff'ing %s:\t" "$test_name"
46 diff "$DIFF_TMP" "$basename.semdiff.exp" > "$DIFF_RESULT"
47 if [ -z "$(cat $DIFF_RESULT)" ]
49 echo -e "$GREEN OK $NC"
50 NUM_SUCCESS
=$
((NUM_SUCCESS
+ 1))
53 NUM_FAIL
=$
((NUM_FAIL
+ 1))
58 echo -e "successes:\t$GREEN $NUM_SUCCESS $NC / $((NUM_SUCCESS + NUM_FAIL))"
59 echo -e "failures:\t$RED $NUM_FAIL $NC / $((NUM_SUCCESS + NUM_FAIL))"