xref: /llvm-project/flang/test/Driver/input-output-file.f90 (revision 49acab3f1408be9439a57833aa7b67678c9a05ba)
1
2!--------------------------
3! FLANG DRIVER (flang)
4!--------------------------
5! NOTE: Use `-E` so that the compiler driver stops after the 1st compilation phase, preprocessing. That's all we need.
6
7! TEST 1: Print to stdout (implicit)
8! RUN: %flang -E %s  2>&1 | FileCheck %s --match-full-lines
9
10! TEST 2: Print to stdout (explicit)
11! RUN: %flang -E -o - %s  2>&1 | FileCheck %s --match-full-lines
12
13! TEST 3: Print to a file
14! RUN: %flang -E -o %t %s 2>&1 && FileCheck %s --match-full-lines --input-file=%t
15
16!----------------------------------------
17! FLANG FRONTEND DRIVER (flang -fc1)
18!----------------------------------------
19! TEST 4: Write to a file (implicit)
20! This particular test case generates an output file in the same directory as the input file. We need to copy the input file into a
21! temporary directory to avoid polluting the source directory.
22! RUN: rm -rf %t-dir && mkdir -p %t-dir && cd %t-dir
23! RUN: cp %s .
24! RUN: %flang_fc1 -test-io input-output-file.f90  2>&1 && FileCheck %s --match-full-lines --input-file=input-output-file.txt
25
26! TEST 5: Write to a file (explicit)
27! RUN: %flang_fc1 -test-io  -o %t %s 2>&1 && FileCheck %s --match-full-lines --input-file=%t
28
29! CHECK-LABEL: Program arithmetic
30! CHECK-NEXT:    Integer :: i, j
31! CHECK-NEXT:    i = 2; j = 3; i= i * j;
32! CHECK-NEXT:  End Program arithmetic
33
34Program arithmetic
35  Integer :: i, j
36  i = 2; j = 3; i= i * j;
37End Program arithmetic
38