]> git.proxmox.com Git - rustc.git/blob - src/grammar/check.sh
New upstream version 1.15.0+dfsg1
[rustc.git] / src / grammar / check.sh
1 #!/bin/sh
2
3 # ignore-license
4
5 # Run the reference lexer against libsyntax and compare the tokens and spans.
6 # If "// ignore-lexer-test" is present in the file, it will be ignored.
7
8
9 # Argument $1 is the file to check, $2 is the classpath to use, $3 is the path
10 # to the grun binary, $4 is the path to the verify binary, $5 is the path to
11 # RustLexer.tokens
12 if [ "${VERBOSE}" == "1" ]; then
13 set -x
14 fi
15
16 passed=0
17 failed=0
18 skipped=0
19
20 check() {
21 grep --silent "// ignore-lexer-test" "$1";
22
23 # if it is *not* found...
24 if [ $? -eq 1 ]; then
25 cd $2 # This `cd` is so java will pick up RustLexer.class. I could not
26 # figure out how to wrangle the CLASSPATH, just adding build/grammar
27 # did not seem to have any effect.
28 if $3 RustLexer tokens -tokens < $1 | $4 $1 $5; then
29 echo "pass: $1"
30 passed=`expr $passed + 1`
31 else
32 echo "fail: $1"
33 failed=`expr $failed + 1`
34 fi
35 else
36 echo "skip: $1"
37 skipped=`expr $skipped + 1`
38 fi
39 }
40
41 for file in $(find $1 -iname '*.rs' ! -path '*/test/compile-fail*'); do
42 check "$file" $2 $3 $4 $5
43 done
44
45 printf "\ntest result: "
46
47 if [ $failed -eq 0 ]; then
48 printf "ok. $passed passed; $failed failed; $skipped skipped\n\n"
49 else
50 printf "failed. $passed passed; $failed failed; $skipped skipped\n\n"
51 exit 1
52 fi