[flang] Port test_any.sh tests to FileCheck: Hand port getdefinition* tests

These tests are sensitive to line numbers in the input and check output.
They also successively write to a temporary file then check that.

Fix the line number issues and replace the temporary file use with successive
calls to FileCheck with different check-prefixes.

Differential Revision: https://reviews.llvm.org/D82165
This commit is contained in:
Richard Barton 2020-06-26 18:47:13 +01:00
parent b4bceb94ee
commit 66c26d93b7
5 changed files with 27 additions and 34 deletions

View File

@ -1,4 +1,3 @@
!RUN: %S/test_any.sh %s %t %f18
! Tests -fget-definition returning source position of symbol definition.
module m1
private :: f
@ -16,13 +15,13 @@ contains
end function
end module
! EXEC: echo %t 1>&2;
! EXEC: ${F18} -fget-definition 7 17 18 -fparse-only %s > %t;
! EXEC: ${F18} -fget-definition 8 20 23 -fparse-only %s >> %t;
! EXEC: ${F18} -fget-definition 15 3 4 -fparse-only %s >> %t;
! EXEC: ${F18} -fget-definition -fparse-only %s >> %t 2>&1;
! EXEC: cat %t | ${FileCheck} %s
! CHECK:x:.*getdefinition01.f90, 6, 21-22
! CHECK:yyy:.*getdefinition01.f90, 6, 24-27
! CHECK:x:.*getdefinition01.f90, 14, 24-25
! CHECK:Invalid argument to -fget-definitions
! RUN and CHECK lines at the bottom as this test is sensitive to line numbers
! RUN: %f18 -fget-definition 6 17 18 -fparse-only %s | FileCheck --check-prefix=CHECK1 %s
! RUN: %f18 -fget-definition 7 20 23 -fparse-only %s | FileCheck --check-prefix=CHECK2 %s
! RUN: %f18 -fget-definition 14 3 4 -fparse-only %s | FileCheck --check-prefix=CHECK3 %s
! CHECK1: x:{{.*}}getdefinition01.f90, 5, 21-22
! CHECK2: yyy:{{.*}}getdefinition01.f90, 5, 24-27
! CHECK3: x:{{.*}}getdefinition01.f90, 13, 24-25
! RUN: not %f18 -fget-definition -fparse-only %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
! CHECK-ERROR: Invalid argument to -fget-definitions

View File

@ -1,4 +1,3 @@
!RUN: %S/test_any.sh %s %t %f18
! Tests -fget-definition with fixed form.
module m2
private :: f
@ -17,10 +16,10 @@
end function
end module
! EXEC: ${F18} -fget-definition 8 9 10 -fparse-only %s > %t;
! EXEC: ${F18} -fget-definition 9 26 29 -fparse-only %s >> %t;
! EXEC: ${F18} -fget-definition 16 9 10 -fparse-only %s >> %t;
! EXEC: cat %t | ${FileCheck} %s
! CHECK:x:.*getdefinition02.f, 6, 27-28
! CHECK:yyy:.*getdefinition02.f, 6, 30-33
! CHECK:x:.*getdefinition02.f, 15, 30-31
! RUN and CHECK lines here as test is sensitive to line numbers
! RUN: %f18 -fget-definition 7 9 10 -fparse-only %s 2>&1 | FileCheck --check-prefix=CHECK1 %s
! RUN: %f18 -fget-definition 8 26 29 -fparse-only %s 2>&1 | FileCheck --check-prefix=CHECK2 %s
! RUN: %f18 -fget-definition 15 9 10 -fparse-only %s 2>&1 | FileCheck --check-prefix=CHECK3 %s
! CHECK1: x:{{.*}}getdefinition02.f, 5, 27-28
! CHECK2: yyy:{{.*}}getdefinition02.f, 5, 30-33
! CHECK3: x:{{.*}}getdefinition02.f, 14, 30-31

View File

@ -1,5 +1,4 @@
! Tests -fget-definition with INCLUDE
!RUN: %S/test_any.sh %s %t %f18
INCLUDE "Inputs/getdefinition03-b.f90"
program main
@ -8,8 +7,7 @@ program main
x = f
end program
! EXEC: ${F18} -fget-definition 8 6 7 -fparse-only %s > %t;
! EXEC: ${F18} -fget-definition 8 2 3 -fparse-only %s >> %t;
! EXEC: cat %t | ${FileCheck} %s;
! CHECK:f:.*getdefinition03-b.f90, 2, 12-13
! CHECK:x:.*getdefinition03-a.f90, 7, 13-14
! RUN: %f18 -fget-definition 7 6 7 -fparse-only %s | FileCheck --check-prefix=CHECK1 %s
! RUN: %f18 -fget-definition 7 2 3 -fparse-only %s | FileCheck --check-prefix=CHECK2 %s
! CHECK1: f:{{.*}}getdefinition03-b.f90, 2, 12-13
! CHECK2: x:{{.*}}getdefinition03-a.f90, 6, 13-14

View File

@ -1,4 +1,3 @@
!RUN: %S/test_any.sh %s %t %f18
! Tests -fget-definition with COMMON block with same name as variable.
program main
integer :: x
@ -7,5 +6,5 @@ program main
x = y
end program
! EXEC: ${F18} -fget-definition 7 3 4 -fparse-only %s | ${FileCheck} %s
! CHECK:x:.*getdefinition04.f90, 4, 14-15
! RUN: %f18 -fget-definition 6 3 4 -fparse-only %s | FileCheck %s
! CHECK: x:{{.*}}getdefinition04.f90, 3, 14-15

View File

@ -1,4 +1,3 @@
!RUN: %S/test_any.sh %s %t %f18
! Tests -fget-symbols-sources with BLOCK that contains same variable name as
! another in an outer scope.
program main
@ -13,9 +12,8 @@ program main
end program
!! Inner x
! EXEC: ${F18} -fget-definition 10 5 6 -fparse-only %s > %t;
! CHECK:x:.*getdefinition05.f90, 8, 16-17
! RUN: %f18 -fget-definition 9 5 6 -fparse-only %s | FileCheck --check-prefix=CHECK1 %s
! CHECK1: x:{{.*}}getdefinition05.f90, 7, 16-17
!! Outer y
! EXEC: ${F18} -fget-definition 12 7 8 -fparse-only %s >> %t;
! CHECK:y:.*getdefinition05.f90, 6, 14-15
! EXEC: cat %t | ${FileCheck} %s;
! RUN: %f18 -fget-definition 11 7 8 -fparse-only %s | FileCheck --check-prefix=CHECK2 %s
! CHECK2: y:{{.*}}getdefinition05.f90, 5, 14-15