[10672] | 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" with mirror to same location, then "fcm make --name=2". |
---|
| 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 '*/mirror/*' -o \ |
---|
| 34 | -path '*/.fcm-make*/c*' ')' \ |
---|
| 35 | | sort |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | tests 11 |
---|
| 39 | |
---|
| 40 | mkdir -p 'src/hello' |
---|
| 41 | cat >'src/hello/hello.f90' <<'__FORTRAN__' |
---|
| 42 | program hello |
---|
| 43 | write(*, '(a)') 'Hello!' |
---|
| 44 | end program hello |
---|
| 45 | __FORTRAN__ |
---|
| 46 | |
---|
| 47 | cat >'fcm-make.cfg' <<'__CFG__' |
---|
| 48 | steps=extract mirror |
---|
| 49 | extract.ns = hello |
---|
| 50 | extract.location[hello]=$HERE/src/hello |
---|
| 51 | mirror.target=$HERE |
---|
| 52 | mirror.prop{config-file.name}=2 |
---|
| 53 | mirror.prop{config-file.steps}=build |
---|
| 54 | build.target{task}=link |
---|
| 55 | __CFG__ |
---|
| 56 | |
---|
| 57 | #------------------------------------------------------------------------------- |
---|
| 58 | run_pass "${TEST_KEY_BASE}-1" fcm make |
---|
| 59 | find_fcm_make_files >"${TEST_KEY_BASE}-1.find.new" |
---|
| 60 | file_cmp_sorted \ |
---|
| 61 | "${TEST_KEY_BASE}-1.find.new" "${TEST_KEY_BASE}-1.find.new" <<'__FIND__' |
---|
| 62 | ./.fcm-make/config-as-parsed.cfg |
---|
| 63 | ./.fcm-make/config-on-success.cfg |
---|
| 64 | ./.fcm-make/ctx.gz |
---|
| 65 | ./extract/hello/hello.f90 |
---|
| 66 | ./mirror/fcm-make2.cfg |
---|
| 67 | ./mirror/fcm-make2.cfg.orig |
---|
| 68 | __FIND__ |
---|
| 69 | |
---|
| 70 | touch 'marker' |
---|
| 71 | sleep 1 |
---|
| 72 | run_pass "${TEST_KEY_BASE}-2" fcm make -f fcm-make2.cfg |
---|
| 73 | find_fcm_make_files '!' -newer 'marker' >"${TEST_KEY_BASE}-2.find.old" |
---|
| 74 | file_cmp "${TEST_KEY_BASE}-2.find.old" \ |
---|
| 75 | "${TEST_KEY_BASE}-2.find.old" "${TEST_KEY_BASE}-1.find.new" |
---|
| 76 | find_fcm_make_files -newer 'marker' >"${TEST_KEY_BASE}-2.find.new" |
---|
| 77 | file_cmp_sorted \ |
---|
| 78 | "${TEST_KEY_BASE}-2.find.new" "${TEST_KEY_BASE}-2.find.new" <<'__FIND__' |
---|
| 79 | ./.fcm-make2/config-as-parsed.cfg |
---|
| 80 | ./.fcm-make2/config-on-success.cfg |
---|
| 81 | ./.fcm-make2/ctx.gz |
---|
| 82 | ./build/bin/hello.exe |
---|
| 83 | ./build/o/hello.o |
---|
| 84 | __FIND__ |
---|
| 85 | |
---|
| 86 | touch 'marker' |
---|
| 87 | sleep 1 |
---|
| 88 | run_pass "${TEST_KEY_BASE}-1-incr" fcm make |
---|
| 89 | find_fcm_make_files '!' -newer 'marker' >"${TEST_KEY_BASE}-1-incr.find.old" |
---|
| 90 | file_cmp_sorted "${TEST_KEY_BASE}-1-incr.find.old" \ |
---|
| 91 | "${TEST_KEY_BASE}-1-incr.find.old" <<'__FIND__' |
---|
| 92 | ./.fcm-make2/config-as-parsed.cfg |
---|
| 93 | ./.fcm-make2/config-on-success.cfg |
---|
| 94 | ./.fcm-make2/ctx.gz |
---|
| 95 | ./build/bin/hello.exe |
---|
| 96 | ./build/o/hello.o |
---|
| 97 | ./extract/hello/hello.f90 |
---|
| 98 | __FIND__ |
---|
| 99 | find_fcm_make_files -newer 'marker' >"${TEST_KEY_BASE}-1-incr.find.new" |
---|
| 100 | file_cmp_sorted "${TEST_KEY_BASE}-1-incr.find.new" \ |
---|
| 101 | "${TEST_KEY_BASE}-1-incr.find.new" <<'__FIND__' |
---|
| 102 | ./.fcm-make/config-as-parsed.cfg |
---|
| 103 | ./.fcm-make/config-on-success.cfg |
---|
| 104 | ./.fcm-make/ctx.gz |
---|
| 105 | ./mirror/fcm-make2.cfg |
---|
| 106 | ./mirror/fcm-make2.cfg.orig |
---|
| 107 | __FIND__ |
---|
| 108 | |
---|
| 109 | touch 'marker' |
---|
| 110 | sleep 1 |
---|
| 111 | run_pass "${TEST_KEY_BASE}-2-incr" fcm make -f fcm-make2.cfg |
---|
| 112 | find_fcm_make_files '!' -newer 'marker' >"${TEST_KEY_BASE}-2-incr.find.old" |
---|
| 113 | file_cmp_sorted "${TEST_KEY_BASE}-2-incr.find.old" \ |
---|
| 114 | "${TEST_KEY_BASE}-2-incr.find.old" <<'__FIND__' |
---|
| 115 | ./.fcm-make/config-as-parsed.cfg |
---|
| 116 | ./.fcm-make/config-on-success.cfg |
---|
| 117 | ./.fcm-make/ctx.gz |
---|
| 118 | ./build/bin/hello.exe |
---|
| 119 | ./build/o/hello.o |
---|
| 120 | ./extract/hello/hello.f90 |
---|
| 121 | ./mirror/fcm-make2.cfg |
---|
| 122 | ./mirror/fcm-make2.cfg.orig |
---|
| 123 | __FIND__ |
---|
| 124 | find_fcm_make_files -newer 'marker' >"${TEST_KEY_BASE}-2-incr.find.new" |
---|
| 125 | file_cmp_sorted "${TEST_KEY_BASE}-2-incr.find.new" \ |
---|
| 126 | "${TEST_KEY_BASE}-2-incr.find.new" <<'__FIND__' |
---|
| 127 | ./.fcm-make2/config-as-parsed.cfg |
---|
| 128 | ./.fcm-make2/config-on-success.cfg |
---|
| 129 | ./.fcm-make2/ctx.gz |
---|
| 130 | __FIND__ |
---|
| 131 | #------------------------------------------------------------------------------- |
---|
| 132 | exit |
---|