2 # Compile a source file and compare generated .mod files against expected.
5 FLANG_FC1_OPTIONS
="-fsyntax-only"
7 source $srcdir/common.sh
9 actual
=$temp/actual.mod
10 expect
=$temp/expect.mod
11 actual_files
=$temp/actual_files
12 prev_files
=$temp/prev_files
19 [[ ! -f $src ]] && echo "File not found: $src" && exit 1
20 path
=$
(git ls-files
--full-name $src 2>/dev
/null ||
echo $src)
23 ls -1 *.mod
> prev_files
24 $FLANG_FC1 $FLANG_FC1_OPTIONS $src
25 ls -1 *.mod |
comm -13 prev_files
-
27 expected_files
=$
(sed -n 's/^!Expect: \(.*\)/\1/p' $src |
sort)
28 extra_files
=$
(echo "$expected_files" |
comm -23 $actual_files -)
29 if [[ ! -z "$extra_files" ]]; then
30 echo "Unexpected .mod files produced:" $extra_files
33 for mod
in $expected_files; do
34 if [[ ! -f $temp/$mod ]]; then
35 echo "Compilation did not produce expected mod file: $mod"
38 # The first three bytes of the file are a UTF-8 BOM
39 sed '/^[^!]*!mod\$/d' $temp/$mod > $actual
40 sed '1,/^!Expect: '"$mod"'/d' $src |
sed -e '/^$/,$d' -e 's/^!//' > $expect
41 if ! diff -w -U999999 $expect $actual > $diffs; then
42 echo "Module file $mod differs from expected:"