[10669] | 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", config as relative paths |
---|
| 21 | #------------------------------------------------------------------------------- |
---|
| 22 | . $(dirname $0)/test_header |
---|
| 23 | |
---|
| 24 | clean() { |
---|
| 25 | rm -fr \ |
---|
| 26 | .fcm-make \ |
---|
| 27 | build \ |
---|
| 28 | fcm-make-as-parsed.cfg \ |
---|
| 29 | fcm-make-on-success.cfg \ |
---|
| 30 | fcm-make.log |
---|
| 31 | } |
---|
| 32 | #------------------------------------------------------------------------------- |
---|
| 33 | tests 11 |
---|
| 34 | #------------------------------------------------------------------------------- |
---|
| 35 | TEST_KEY="$TEST_KEY_BASE" |
---|
| 36 | |
---|
| 37 | mkdir etc |
---|
| 38 | cat >etc/fcm-make.cfg <<'__CFG__' |
---|
| 39 | steps=build |
---|
| 40 | build.source=$HERE/../src |
---|
| 41 | build.target=hello.exe |
---|
| 42 | __CFG__ |
---|
| 43 | |
---|
| 44 | mkdir src |
---|
| 45 | cat >src/hello.f90 <<'__FORTRAN__' |
---|
| 46 | program hello |
---|
| 47 | write(*, '(a)') 'Hello World!' |
---|
| 48 | end program hello |
---|
| 49 | __FORTRAN__ |
---|
| 50 | |
---|
| 51 | #------------------------------------------------------------------------------- |
---|
| 52 | clean |
---|
| 53 | run_fail "$TEST_KEY-control" fcm make |
---|
| 54 | file_cmp "$TEST_KEY-control.err" "$TEST_KEY-control.err" <<'__ERROR__' |
---|
| 55 | [FAIL] no configuration specified or found |
---|
| 56 | |
---|
| 57 | __ERROR__ |
---|
| 58 | #------------------------------------------------------------------------------- |
---|
| 59 | clean |
---|
| 60 | run_pass "$TEST_KEY-pwd" fcm make -f etc/fcm-make.cfg |
---|
| 61 | file_test "$TEST_KEY.hello.exe" $PWD/build/bin/hello.exe |
---|
| 62 | $PWD/build/bin/hello.exe >"$TEST_KEY.hello.exe.out" |
---|
| 63 | file_cmp "$TEST_KEY.hello.exe.out" "$TEST_KEY.hello.exe.out" <<'__OUT__' |
---|
| 64 | Hello World! |
---|
| 65 | __OUT__ |
---|
| 66 | #------------------------------------------------------------------------------- |
---|
| 67 | clean |
---|
| 68 | run_pass "$TEST_KEY-path" fcm make -F $PWD/etc |
---|
| 69 | file_test "$TEST_KEY.hello.exe" $PWD/build/bin/hello.exe |
---|
| 70 | $PWD/build/bin/hello.exe >"$TEST_KEY.hello.exe.out" |
---|
| 71 | file_cmp "$TEST_KEY.hello.exe.out" "$TEST_KEY.hello.exe.out" <<'__OUT__' |
---|
| 72 | Hello World! |
---|
| 73 | __OUT__ |
---|
| 74 | #------------------------------------------------------------------------------- |
---|
| 75 | clean |
---|
| 76 | cd src |
---|
| 77 | run_pass "$TEST_KEY-path" fcm make -C .. -f etc/fcm-make.cfg |
---|
| 78 | file_test "$TEST_KEY.hello.exe" ../build/bin/hello.exe |
---|
| 79 | ../build/bin/hello.exe >"$TEST_KEY.hello.exe.out" |
---|
| 80 | file_cmp "$TEST_KEY.hello.exe.out" "$TEST_KEY.hello.exe.out" <<'__OUT__' |
---|
| 81 | Hello World! |
---|
| 82 | __OUT__ |
---|
| 83 | cd .. |
---|
| 84 | #------------------------------------------------------------------------------- |
---|
| 85 | exit 0 |
---|