Files
clang-p2996/flang/test/Semantics/test_errors.sh
Tim Keith 99aa87a5b5 [flang][NFC] Simplify semantics test scripts
There were several different ways of handling the option to f18 to
find predefined modules:
- test_errors.sh was created by cmake substituting
  FLANG_INTRINSIC_MODULES_DIR into test_errors.sh.in
- some tests used the flang script which has the option built it
- some tests used %f18_with_includes which was replaced by the path
  to f18 plus the -I option
- some included -I../../include/flang in their run command

To make this more consistent, change %f18 to include the
-intrinsic-module-directory option and use it everywhere, including
to replace %flang and %f18_with_includes. This requires changing all
of the invocations of the test scripts to put %f18 at the end so that
it can expand to more than one argument.

This eliminates the need to generate test_errors.sh which means we
don't need flang/test/Semantics/CMakeLists.txt or the %B substitution.
That makes the test_errors.sh command like the others, replacing
%B/test/Semantics/test_errors.sh with %S/test_errors.sh.

Also remove the OPTIONS: functionality as custom options can be included
in the RUN: command. And remove -I/../../include/flang as that is now
always included.

Differential Revision: https://reviews.llvm.org/D79634
2020-05-11 11:49:25 -07:00

40 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Compile a source file and check errors against those listed in the file.
# Change the compiler by setting the F18 environment variable.
F18_OPTIONS="-fdebug-resolve-names -fparse-only"
srcdir=$(dirname $0)
source $srcdir/common.sh
[[ ! -f $src ]] && die "File not found: $src"
log=$temp/log
actual=$temp/actual
expect=$temp/expect
diffs=$temp/diffs
cmd="$F18 $F18_OPTIONS $src"
( cd $temp; $cmd ) > $log 2>&1
if [[ $? -ge 128 ]]; then
cat $log
exit 1
fi
# $actual has errors from the compiler; $expect has them from !ERROR comments in source
# Format both as "<line>: <text>" so they can be diffed.
sed -n 's=^[^:]*:\([^:]*\):[^:]*: error: =\1: =p' $log > $actual
awk '
BEGIN { FS = "!ERROR: "; }
/^ *!ERROR: / { errors[nerrors++] = $2; next; }
{ for (i = 0; i < nerrors; ++i) printf "%d: %s\n", NR, errors[i]; nerrors = 0; }
' $src > $expect
if diff -U0 $actual $expect > $diffs; then
echo PASS
else
echo "$cmd"
< $diffs \
sed -n -e 's/^-\([0-9]\)/actual at \1/p' -e 's/^+\([0-9]\)/expect at \1/p' \
| sort -n -k 3
die FAIL
fi