1 | #!/bin/bash |
---|
2 | #------------------------------------------------------------------------------- |
---|
3 | # Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
---|
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 | # Test "fcm make", build.target{category} and build.target{task} with namespace. |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . "$(dirname "$0")/test_header" |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | tests 12 |
---|
25 | mkdir 'i0' |
---|
26 | cp -r "${TEST_SOURCE_DIR}/${TEST_KEY_BASE}/"* 'i0' |
---|
27 | #------------------------------------------------------------------------------- |
---|
28 | TEST_KEY="${TEST_KEY_BASE}" |
---|
29 | run_pass "${TEST_KEY}" fcm make -C 'i0' |
---|
30 | |
---|
31 | grep -F 'build.target{category}' 'i0/.fcm-make/config-on-success.cfg' \ |
---|
32 | >'edited-config-on-success.cfg' |
---|
33 | file_cmp "${TEST_KEY}-edited-config-on-success.cfg" \ |
---|
34 | 'edited-config-on-success.cfg' <<'__CFG__' |
---|
35 | build.target{category}[hello] = bin |
---|
36 | __CFG__ |
---|
37 | |
---|
38 | find 'i0/build' -type f | sort >'find-i0-build.out' |
---|
39 | file_cmp "${TEST_KEY}-find-i0-build.out" 'find-i0-build.out' <<'__FIND__' |
---|
40 | i0/build/bin/hello |
---|
41 | i0/build/o/hello.o |
---|
42 | __FIND__ |
---|
43 | |
---|
44 | "${PWD}/i0/build/bin/hello" <<<'&world_nl /' >'hello.out' |
---|
45 | file_cmp "${TEST_KEY}-hello.out" 'hello.out' <<<'Hello World' |
---|
46 | #------------------------------------------------------------------------------- |
---|
47 | TEST_KEY="${TEST_KEY_BASE}-inherit" |
---|
48 | run_pass "${TEST_KEY}" fcm make -C 'i1' \ |
---|
49 | "use=${PWD}/i0" \ |
---|
50 | 'build.target{category}[greet] = etc' |
---|
51 | |
---|
52 | grep -F 'build.target{category}' 'i1/.fcm-make/config-on-success.cfg' \ |
---|
53 | >'edited-config-on-success.cfg' |
---|
54 | file_cmp "${TEST_KEY}-edited-config-on-success.cfg" \ |
---|
55 | 'edited-config-on-success.cfg' <<'__CFG__' |
---|
56 | build.target{category}[greet] = etc |
---|
57 | build.target{category}[hello] = bin |
---|
58 | __CFG__ |
---|
59 | |
---|
60 | find 'i1/build' -type f | sort >'find-i1-build.out' |
---|
61 | file_cmp "${TEST_KEY}-find-i1-build.out" 'find-i1-build.out' <<'__FIND__' |
---|
62 | i1/build/bin/hello |
---|
63 | i1/build/etc/greet/.etc |
---|
64 | i1/build/etc/greet/world.nl |
---|
65 | __FIND__ |
---|
66 | |
---|
67 | "${PWD}/i1/build/bin/hello" <'i1/build/etc/greet/world.nl' >'hello.out' |
---|
68 | file_cmp "${TEST_KEY}-hello.out" 'hello.out' <<<'Hello Earth' |
---|
69 | #------------------------------------------------------------------------------- |
---|
70 | TEST_KEY="${TEST_KEY_BASE}-inherit-incr" |
---|
71 | touch 'before' |
---|
72 | run_pass "${TEST_KEY}" fcm make -C 'i1' \ |
---|
73 | "use=${PWD}/i0" \ |
---|
74 | 'build.target{category}[greet] = bin etc' |
---|
75 | |
---|
76 | grep -F 'build.target{category}' 'i1/.fcm-make/config-on-success.cfg' \ |
---|
77 | >'edited-config-on-success.cfg' |
---|
78 | file_cmp "${TEST_KEY}-edited-config-on-success.cfg" \ |
---|
79 | 'edited-config-on-success.cfg' <<'__CFG__' |
---|
80 | build.target{category}[greet] = bin etc |
---|
81 | build.target{category}[hello] = bin |
---|
82 | __CFG__ |
---|
83 | |
---|
84 | find 'i1/build' -type f -newer 'before' | sort >'find-i1-build.out' |
---|
85 | file_cmp "${TEST_KEY}-find-i1-build.out" 'find-i1-build.out' <<'__FIND__' |
---|
86 | i1/build/bin/greet |
---|
87 | i1/build/o/greet.o |
---|
88 | __FIND__ |
---|
89 | |
---|
90 | "${PWD}/i1/build/bin/greet" <'i1/build/etc/greet/world.nl' >'greet.out' |
---|
91 | file_cmp "${TEST_KEY}-greet.out" 'greet.out' <<<'Greet Earth' |
---|
92 | #------------------------------------------------------------------------------- |
---|
93 | exit 0 |
---|