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", inherit, with context name, back compat. |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . "$(dirname "$0")/test_header" |
---|
23 | |
---|
24 | file_cmp_sorted() { |
---|
25 | sort - >"${1}.expected" |
---|
26 | file_cmp "$1" "${2}" "${1}.expected" |
---|
27 | } |
---|
28 | |
---|
29 | find_fcm_make_files() { |
---|
30 | find . "$@" -type f \ |
---|
31 | '(' -path '*/build/*' -o \ |
---|
32 | -path '*/extract/*' -o \ |
---|
33 | -path '*/.fcm-make*/c*' ')' \ |
---|
34 | | sort |
---|
35 | } |
---|
36 | |
---|
37 | tests 2 |
---|
38 | |
---|
39 | #------------------------------------------------------------------------------- |
---|
40 | mkdir -p 'hello/src' |
---|
41 | cat >'hello/fcm-make.cfg' <<'__CFG__' |
---|
42 | steps=build |
---|
43 | build.source=$HERE/src |
---|
44 | build.target{task}=link |
---|
45 | __CFG__ |
---|
46 | cat >'hello/src/friend.f90' <<'__FORTRAN__' |
---|
47 | module friend |
---|
48 | character(*), parameter :: name = 'friend' |
---|
49 | end module friend |
---|
50 | __FORTRAN__ |
---|
51 | cat >'hello/src/hello.f90' <<'__FORTRAN__' |
---|
52 | program hello |
---|
53 | use friend, only: name |
---|
54 | write(*, '(a,1x,a)') 'Hello', name |
---|
55 | end program hello |
---|
56 | __FORTRAN__ |
---|
57 | |
---|
58 | fcm make -q -C "${PWD}/hello" |
---|
59 | |
---|
60 | # Remove "name" from make ctx to make it look like a make ctx generated from an |
---|
61 | # old version of "fcm make". |
---|
62 | gunzip "${PWD}/hello/.fcm-make/ctx.gz" |
---|
63 | perl - "${PWD}/hello/.fcm-make/ctx" <<'__PERL__' |
---|
64 | use Storable qw{nstore retrieve}; |
---|
65 | my $m_ctx = retrieve($ARGV[0]); |
---|
66 | delete $m_ctx->{'name'}; |
---|
67 | nstore($m_ctx, $ARGV[0]); |
---|
68 | __PERL__ |
---|
69 | gzip "${PWD}/hello/.fcm-make/ctx" |
---|
70 | #------------------------------------------------------------------------------- |
---|
71 | mkdir -p 'greet/src' |
---|
72 | cat >'greet/fcm-make-friend.cfg' <<'__CFG__' |
---|
73 | use=$HERE/../hello |
---|
74 | name=-friend |
---|
75 | steps=build |
---|
76 | build.source=$HERE/src |
---|
77 | build.target{task}=link |
---|
78 | __CFG__ |
---|
79 | cat >'greet/src/greet.f90' <<'__FORTRAN__' |
---|
80 | program greet |
---|
81 | use friend, only: name |
---|
82 | write(*, '(a,1x,a)') 'Greet', name |
---|
83 | end program greet |
---|
84 | __FORTRAN__ |
---|
85 | |
---|
86 | run_pass "${TEST_KEY_BASE}" fcm make -C "${PWD}/greet" -n '-friend' |
---|
87 | (cd 'greet' && find_fcm_make_files) >"${TEST_KEY_BASE}.find" |
---|
88 | file_cmp_sorted "${TEST_KEY_BASE}.find" "${TEST_KEY_BASE}.find" <<'__FIND__' |
---|
89 | ./.fcm-make-friend/config-as-parsed.cfg |
---|
90 | ./.fcm-make-friend/config-on-success.cfg |
---|
91 | ./.fcm-make-friend/ctx.gz |
---|
92 | ./build/bin/greet.exe |
---|
93 | ./build/bin/hello.exe |
---|
94 | ./build/o/greet.o |
---|
95 | __FIND__ |
---|
96 | #------------------------------------------------------------------------------- |
---|
97 | exit |
---|