]> git.lizzy.rs Git - rust.git/blob - src/grammar/check.sh
Shuffle around check-lexer conditions
[rust.git] / src / grammar / check.sh
1 #!/bin/sh
2
3 # Run the reference lexer against libsyntax and compare the tokens and spans.
4 # If "// ignore-lexer-test" is present in the file, it will be ignored.
5
6
7 # Argument $1 is the file to check, $2 is the classpath to use, $3 is the path
8 # to the grun binary, $4 is the path to the verify binary, $5 is the path to
9 # RustLexer.tokens
10 if [ "${VERBOSE}" == "1" ]; then
11     set -x
12 fi
13
14 check() {
15     grep --silent "// ignore-lexer-test" $1;
16
17     # if it's *not* found...
18     if [ $? -eq 1 ]; then
19         cd $2 # This `cd` is so java will pick up RustLexer.class. I couldn't
20         # figure out how to wrangle the CLASSPATH, just adding build/grammr didn't
21         # seem to have anny effect.
22         if $3 RustLexer tokens -tokens < $1 | $4 $1 $5; then
23             echo "pass: $1"
24         else
25             echo "fail: $1"
26         fi
27     else
28         echo "skip: $1"
29     fi
30 }
31
32 for file in $(find $1 -iname '*.rs' ! -path '*/test/compile-fail/*' ); do
33     check $file $2 $3 $4 $5
34 done