]> git.lizzy.rs Git - rust.git/blob - src/grammar/check.sh
rollup merge of #20350: fhahn/issue-20340-rustdoc-version
[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 passed=0
15 failed=0
16 skipped=0
17
18 check() {
19     grep --silent "// ignore-lexer-test" $1;
20
21     # if it's *not* found...
22     if [ $? -eq 1 ]; then
23         cd $2 # This `cd` is so java will pick up RustLexer.class. I couldn't
24         # figure out how to wrangle the CLASSPATH, just adding build/grammr didn't
25         # seem to have anny effect.
26         if $3 RustLexer tokens -tokens < $1 | $4 $1 $5; then
27             echo "pass: $1"
28             passed=`expr $passed + 1`
29         else
30             echo "fail: $1"
31             failed=`expr $failed + 1`
32         fi
33     else
34         echo "skip: $1"
35         skipped=`expr $skipped + 1`
36     fi
37 }
38
39 for file in $(find $1 -iname '*.rs' ! -path '*/test/compile-fail*'); do
40     check $file $2 $3 $4 $5
41 done
42
43 printf "\ntest result: "
44
45 if [ $failed -eq 0 ]; then
46     printf "ok. $passed passed; $failed failed; $skipped skipped\n\n"
47 else
48     printf "failed. $passed passed; $failed failed; $skipped skipped\n\n"
49     exit 1
50 fi
51