1 | #!/bin/bash |
---|
2 | #------------------------------------------------------------------------------- |
---|
3 | # (C) British Crown Copyright 2006-17 Met Office. |
---|
4 | # |
---|
5 | # This file is part of FCM, tools for managing and building source code. |
---|
6 | # |
---|
7 | # FCM is free software: you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation, either version 3 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # FCM is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | #------------------------------------------------------------------------------- |
---|
20 | # Tests "fcm make", build, continue on failure. |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | |
---|
24 | task_lines_from_log() { |
---|
25 | sed ' |
---|
26 | /\[\(info\|FAIL\)\] \(compile\+\?\|ext-iface\|install\|link\) *\(----\|[0-9][0-9]*\.[0-9][0-9]*\) /!d |
---|
27 | s/ [0-9][0-9]*\.[0-9][0-9]* / ???? / |
---|
28 | ' fcm-make.log |
---|
29 | } |
---|
30 | |
---|
31 | fail_lines_from_log() { |
---|
32 | sed '/\[FAIL\] !/!d' fcm-make.log |
---|
33 | } |
---|
34 | |
---|
35 | #------------------------------------------------------------------------------- |
---|
36 | tests 12 |
---|
37 | #------------------------------------------------------------------------------- |
---|
38 | cp -r $TEST_SOURCE_DIR/$TEST_KEY_BASE/* . |
---|
39 | #------------------------------------------------------------------------------- |
---|
40 | # Break hello1 and hello2 |
---|
41 | TEST_KEY="$TEST_KEY_BASE-1-2-bad" |
---|
42 | sed -i 's/implicit none/implicit non/' src/greet_mod.f90 # introduce typo |
---|
43 | run_fail "$TEST_KEY" fcm make --new |
---|
44 | task_lines_from_log >"$TEST_KEY-log-tasks" |
---|
45 | file_cmp "$TEST_KEY-log-tasks" "$TEST_KEY-log-tasks" <<'__LOG__' |
---|
46 | [info] compile ???? M world_mod.o <- world_mod.f90 |
---|
47 | [FAIL] compile ???? ! greet_mod.o <- greet_mod.f90 |
---|
48 | [FAIL] compile ---- ! hello2.o <- hello2.f90 |
---|
49 | [info] compile ???? M hello_sub.o <- hello_sub.f90 |
---|
50 | [info] ext-iface ???? M hello_sub.interface <- hello_sub.f90 |
---|
51 | [info] compile ???? M hello3.o <- hello3.f90 |
---|
52 | [info] link ???? M hello3 <- hello3.f90 |
---|
53 | [info] compile ???? M hello4.o <- hello4.f90 |
---|
54 | [info] link ???? M hello4 <- hello4.f90 |
---|
55 | __LOG__ |
---|
56 | fail_lines_from_log >"$TEST_KEY-log-fails" |
---|
57 | file_cmp "$TEST_KEY-log-fails" "$TEST_KEY-log-fails" <<'__LOG__' |
---|
58 | [FAIL] ! greet_mod.mod : depends on failed target: greet_mod.o |
---|
59 | [FAIL] ! greet_mod.o : update task failed |
---|
60 | [FAIL] ! hello2 : depends on failed target: hello2.o |
---|
61 | [FAIL] ! hello2.o : depends on failed target: greet_mod.mod |
---|
62 | __LOG__ |
---|
63 | |
---|
64 | TEST_KEY="$TEST_KEY_BASE-1-2-fix" |
---|
65 | sed -i 's/implicit non/implicit none/' src/greet_mod.f90 # fix typo |
---|
66 | run_pass "$TEST_KEY" fcm make |
---|
67 | task_lines_from_log >"$TEST_KEY-log-tasks" |
---|
68 | file_cmp "$TEST_KEY-log-tasks" "$TEST_KEY-log-tasks" <<'__LOG__' |
---|
69 | [info] compile ---- U world_mod.o <- world_mod.f90 |
---|
70 | [info] compile ???? M greet_mod.o <- greet_mod.f90 |
---|
71 | [info] compile ???? M hello.o <- hello.f90 |
---|
72 | [info] link ???? M hello <- hello.f90 |
---|
73 | [info] compile ???? M hello2.o <- hello2.f90 |
---|
74 | [info] link ???? M hello2 <- hello2.f90 |
---|
75 | [info] compile ---- U hello_sub.o <- hello_sub.f90 |
---|
76 | [info] ext-iface ---- U hello_sub.interface <- hello_sub.f90 |
---|
77 | [info] compile ---- U hello3.o <- hello3.f90 |
---|
78 | [info] link ---- U hello3 <- hello3.f90 |
---|
79 | [info] compile ---- U hello4.o <- hello4.f90 |
---|
80 | [info] link ---- U hello4 <- hello4.f90 |
---|
81 | __LOG__ |
---|
82 | fail_lines_from_log >"$TEST_KEY-log-fails" |
---|
83 | file_cmp "$TEST_KEY-log-fails" "$TEST_KEY-log-fails" </dev/null |
---|
84 | #------------------------------------------------------------------------------- |
---|
85 | # Break hello3 and hello4 |
---|
86 | TEST_KEY="$TEST_KEY_BASE-3-4-bad" |
---|
87 | sed -i 's/implicit none/implicit non/' src/hello_sub.f90 # introduce typo |
---|
88 | run_fail "$TEST_KEY" fcm make --new |
---|
89 | task_lines_from_log >"$TEST_KEY-log-tasks" |
---|
90 | file_cmp "$TEST_KEY-log-tasks" "$TEST_KEY-log-tasks" <<'__LOG__' |
---|
91 | [info] compile ???? M world_mod.o <- world_mod.f90 |
---|
92 | [info] compile ???? M greet_mod.o <- greet_mod.f90 |
---|
93 | [info] compile ???? M hello.o <- hello.f90 |
---|
94 | [info] link ???? M hello <- hello.f90 |
---|
95 | [info] compile ???? M hello2.o <- hello2.f90 |
---|
96 | [info] link ???? M hello2 <- hello2.f90 |
---|
97 | [FAIL] compile ???? ! hello_sub.o <- hello_sub.f90 |
---|
98 | [info] ext-iface ???? M hello_sub.interface <- hello_sub.f90 |
---|
99 | [info] compile ???? M hello3.o <- hello3.f90 |
---|
100 | [FAIL] link ---- ! hello3 <- hello3.f90 |
---|
101 | [info] compile ???? M hello4.o <- hello4.f90 |
---|
102 | [FAIL] link ---- ! hello4 <- hello4.f90 |
---|
103 | __LOG__ |
---|
104 | fail_lines_from_log >"$TEST_KEY-log-fails" |
---|
105 | file_cmp "$TEST_KEY-log-fails" "$TEST_KEY-log-fails" <<'__LOG__' |
---|
106 | [FAIL] ! hello3 : depends on failed target: hello_sub.o |
---|
107 | [FAIL] ! hello4 : depends on failed target: hello_sub.o |
---|
108 | [FAIL] ! hello_sub.o : update task failed |
---|
109 | __LOG__ |
---|
110 | |
---|
111 | TEST_KEY="$TEST_KEY_BASE-3-4-fix" |
---|
112 | sed -i 's/implicit non/implicit none/' src/hello_sub.f90 # fix typo |
---|
113 | run_pass "$TEST_KEY" fcm make |
---|
114 | task_lines_from_log >"$TEST_KEY-log-tasks" |
---|
115 | file_cmp "$TEST_KEY-log-tasks" "$TEST_KEY-log-tasks" <<'__LOG__' |
---|
116 | [info] compile ---- U world_mod.o <- world_mod.f90 |
---|
117 | [info] compile ---- U greet_mod.o <- greet_mod.f90 |
---|
118 | [info] compile ---- U hello.o <- hello.f90 |
---|
119 | [info] link ---- U hello <- hello.f90 |
---|
120 | [info] compile ---- U hello2.o <- hello2.f90 |
---|
121 | [info] link ---- U hello2 <- hello2.f90 |
---|
122 | [info] compile ???? M hello_sub.o <- hello_sub.f90 |
---|
123 | [info] ext-iface ???? U hello_sub.interface <- hello_sub.f90 |
---|
124 | [info] compile ---- U hello3.o <- hello3.f90 |
---|
125 | [info] link ???? M hello3 <- hello3.f90 |
---|
126 | [info] compile ---- U hello4.o <- hello4.f90 |
---|
127 | [info] link ???? M hello4 <- hello4.f90 |
---|
128 | __LOG__ |
---|
129 | fail_lines_from_log >"$TEST_KEY-log-fails" |
---|
130 | file_cmp "$TEST_KEY-log-fails" "$TEST_KEY-log-fails" </dev/null |
---|
131 | #------------------------------------------------------------------------------- |
---|
132 | exit 0 |
---|