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 | # Basic tests for "fcm make". |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | tests 18 |
---|
25 | cp -r $TEST_SOURCE_DIR/$TEST_KEY_BASE/* . |
---|
26 | #------------------------------------------------------------------------------- |
---|
27 | TEST_KEY="$TEST_KEY_BASE" |
---|
28 | run_pass "$TEST_KEY" fcm make |
---|
29 | find .fcm-make build -type f | sed 's/^\(\.fcm-make\/log\).*$/\1/' \ |
---|
30 | | sort >"$TEST_KEY.find" |
---|
31 | sort >"${TEST_KEY}.find.expected" <<'__OUT__' |
---|
32 | .fcm-make/config-as-parsed.cfg |
---|
33 | .fcm-make/config-on-success.cfg |
---|
34 | .fcm-make/ctx.gz |
---|
35 | .fcm-make/log |
---|
36 | build/bin/hello.exe |
---|
37 | build/include/world.mod |
---|
38 | build/o/hello.o |
---|
39 | build/o/world.o |
---|
40 | __OUT__ |
---|
41 | file_cmp "$TEST_KEY.find" "$TEST_KEY.find" "${TEST_KEY}.find.expected" |
---|
42 | file_test "$TEST_KEY.log" fcm-make.log |
---|
43 | file_test "$TEST_KEY.fcm-make-as-parsed.cfg" fcm-make-as-parsed.cfg |
---|
44 | file_test "$TEST_KEY.fcm-make-on-success.cfg" fcm-make-on-success.cfg |
---|
45 | readlink fcm-make.log >"$TEST_KEY.log.readlink" |
---|
46 | file_cmp "$TEST_KEY.log.readlink" "$TEST_KEY.log.readlink" <<<'.fcm-make/log' |
---|
47 | sed '/^\[info\] \(source->target\|target\|required-target\) /!d' \ |
---|
48 | .fcm-make/log >"$TEST_KEY.log.sed" |
---|
49 | file_cmp "$TEST_KEY.log.sed" "$TEST_KEY.log.sed" <<'__LOG__' |
---|
50 | [info] source->target / -> (archive) lib/ libo.a |
---|
51 | [info] source->target hello.f90 -> (link) bin/ hello.exe |
---|
52 | [info] source->target hello.f90 -> (install) include/ hello.f90 |
---|
53 | [info] source->target hello.f90 -> (compile) o/ hello.o |
---|
54 | [info] source->target world.f90 -> (install) include/ world.f90 |
---|
55 | [info] source->target world.f90 -> (compile+) include/ world.mod |
---|
56 | [info] source->target world.f90 -> (compile) o/ world.o |
---|
57 | [info] target hello.exe |
---|
58 | [info] target - hello.o |
---|
59 | [info] target - - world.mod |
---|
60 | [info] target - - - world.o |
---|
61 | [info] target - world.o |
---|
62 | __LOG__ |
---|
63 | file_test "$TEST_KEY-as-parsed.cfg" fcm-make-as-parsed.cfg |
---|
64 | readlink fcm-make-as-parsed.cfg >"$TEST_KEY-as-parsed.cfg.out" |
---|
65 | file_cmp "$TEST_KEY-as-parsed.cfg.out" "$TEST_KEY-as-parsed.cfg.out" \ |
---|
66 | <<<'.fcm-make/config-as-parsed.cfg' |
---|
67 | file_test "$TEST_KEY-on-success.cfg" fcm-make-on-success.cfg |
---|
68 | readlink fcm-make-on-success.cfg >"$TEST_KEY-on-success.cfg.out" |
---|
69 | file_cmp "$TEST_KEY-on-success.cfg.out" "$TEST_KEY-on-success.cfg.out" \ |
---|
70 | <<<'.fcm-make/config-on-success.cfg' |
---|
71 | run_pass "$TEST_KEY.exe" $PWD/build/bin/hello.exe |
---|
72 | file_cmp "$TEST_KEY.exe.out" "$TEST_KEY.exe.out" <<<'Hello Earth' |
---|
73 | #------------------------------------------------------------------------------- |
---|
74 | TEST_KEY="$TEST_KEY_BASE-incr" |
---|
75 | find build -type f -exec stat -c'%Y %n' {} \; | sort >"$TEST_KEY.mtime.old" |
---|
76 | run_pass "$TEST_KEY" fcm make |
---|
77 | find build -type f -exec stat -c'%Y %n' {} \; | sort >"$TEST_KEY.mtime" |
---|
78 | file_cmp "$TEST_KEY.mtime" "$TEST_KEY.mtime.old" "$TEST_KEY.mtime" |
---|
79 | #------------------------------------------------------------------------------- |
---|
80 | TEST_KEY="$TEST_KEY_BASE-incr-fail" |
---|
81 | echo 'build.target=foo' >>fcm-make.cfg |
---|
82 | run_fail "$TEST_KEY" fcm make |
---|
83 | run_fail "$TEST_KEY.config-on-success" test -e .fcm-make/config-on-success |
---|
84 | run_fail "$TEST_KEY.fcm-make-on-success.cfg" test -e fcm-make-on-success.cfg |
---|
85 | #------------------------------------------------------------------------------- |
---|
86 | exit 0 |
---|