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 for "fcm make", "extract", location reset and base eq diff cases. |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | N_TESTS=34 |
---|
25 | tests $N_TESTS |
---|
26 | #------------------------------------------------------------------------------- |
---|
27 | svnadmin create repos |
---|
28 | T_REPOS=file://$PWD/repos |
---|
29 | mkdir t |
---|
30 | echo "Hello World" >t/hello.txt |
---|
31 | echo "Hi World" >t/hi.txt |
---|
32 | svn import -q -m'Test' t/hello.txt $T_REPOS/trunk/hello.txt |
---|
33 | svn import -q -m'Test' t $T_REPOS/branch |
---|
34 | rm t/hello.txt t/hi.txt |
---|
35 | rmdir t |
---|
36 | #------------------------------------------------------------------------------- |
---|
37 | cat >fcm-make.cfg.0 <<__FCM_MAKE_CFG__ |
---|
38 | steps=extract |
---|
39 | extract.ns=t |
---|
40 | extract.location{primary}[t]=$T_REPOS |
---|
41 | __FCM_MAKE_CFG__ |
---|
42 | #------------------------------------------------------------------------------- |
---|
43 | base_tests() { |
---|
44 | run_pass "$TEST_KEY" fcm make --new |
---|
45 | find extract -type f >"$TEST_KEY.find" |
---|
46 | file_cmp "$TEST_KEY.find" "$TEST_KEY.find" <<<'extract/t/hello.txt' |
---|
47 | sed '/^\[info\] location t: /!d; s/^\[info\] location t: //' \ |
---|
48 | .fcm-make/log > "$TEST_KEY.log" |
---|
49 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
50 | 0: $T_REPOS/trunk@2 (1) |
---|
51 | __LOG__ |
---|
52 | } |
---|
53 | #------------------------------------------------------------------------------- |
---|
54 | diff_tests() { |
---|
55 | run_pass "$TEST_KEY" fcm make --new |
---|
56 | find extract -type f | sort >"$TEST_KEY.find" |
---|
57 | file_cmp "$TEST_KEY.find" "$TEST_KEY.find" <<'__FIND__' |
---|
58 | extract/t/hello.txt |
---|
59 | extract/t/hi.txt |
---|
60 | __FIND__ |
---|
61 | sed '/^\[info\] location t: /!d; s/^\[info\] location t: //' \ |
---|
62 | .fcm-make/log > "$TEST_KEY.log" |
---|
63 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
64 | 0: $T_REPOS/trunk@2 (1) |
---|
65 | 1: $T_REPOS/branch@2 (2) |
---|
66 | __LOG__ |
---|
67 | } |
---|
68 | #------------------------------------------------------------------------------- |
---|
69 | TEST_KEY="$TEST_KEY_BASE-primary" |
---|
70 | { |
---|
71 | cat fcm-make.cfg.0 |
---|
72 | echo "extract.location{primary}[t]=" |
---|
73 | echo "extract.location[t]=$T_REPOS/trunk" |
---|
74 | } >fcm-make.cfg |
---|
75 | base_tests |
---|
76 | #------------------------------------------------------------------------------- |
---|
77 | TEST_KEY="$TEST_KEY_BASE-base-0" |
---|
78 | { |
---|
79 | cat fcm-make.cfg.0 |
---|
80 | echo "extract.location[t]=" |
---|
81 | } >fcm-make.cfg |
---|
82 | base_tests |
---|
83 | #------------------------------------------------------------------------------- |
---|
84 | TEST_KEY="$TEST_KEY_BASE-base-0-with-eq-diff" |
---|
85 | { |
---|
86 | cat fcm-make.cfg.0 |
---|
87 | echo "extract.location{diff}[t]=$T_REPOS/trunk" |
---|
88 | } >fcm-make.cfg |
---|
89 | base_tests |
---|
90 | #------------------------------------------------------------------------------- |
---|
91 | TEST_KEY="$TEST_KEY_BASE-base" |
---|
92 | { |
---|
93 | cat fcm-make.cfg.0 |
---|
94 | echo "extract.location[t]=$T_REPOS/trunk" |
---|
95 | echo "extract.location[t]=" |
---|
96 | } >fcm-make.cfg |
---|
97 | base_tests |
---|
98 | #------------------------------------------------------------------------------- |
---|
99 | TEST_KEY="$TEST_KEY_BASE-base-with-eq-diff" |
---|
100 | { |
---|
101 | cat fcm-make.cfg.0 |
---|
102 | echo "extract.location[t]=$T_REPOS/trunk" |
---|
103 | echo "extract.location{diff}[t]=$T_REPOS/trunk" |
---|
104 | } >fcm-make.cfg |
---|
105 | base_tests |
---|
106 | #------------------------------------------------------------------------------- |
---|
107 | TEST_KEY="$TEST_KEY_BASE-base-with-diff" |
---|
108 | { |
---|
109 | cat fcm-make.cfg.0 |
---|
110 | echo "extract.location[t]=$T_REPOS/trunk" |
---|
111 | echo "extract.location{diff}[t]=$T_REPOS/branch" |
---|
112 | echo "extract.location[t]=" |
---|
113 | } >fcm-make.cfg |
---|
114 | diff_tests |
---|
115 | #------------------------------------------------------------------------------- |
---|
116 | TEST_KEY="$TEST_KEY_BASE-base-with-1-eq-diff" |
---|
117 | { |
---|
118 | cat fcm-make.cfg.0 |
---|
119 | echo "extract.location[t]=$T_REPOS/trunk" |
---|
120 | echo "extract.location{diff}[t]=$T_REPOS/trunk $T_REPOS/branch" |
---|
121 | echo "extract.location[t]=" |
---|
122 | } >fcm-make.cfg |
---|
123 | diff_tests |
---|
124 | #------------------------------------------------------------------------------- |
---|
125 | TEST_KEY="$TEST_KEY_BASE-diff-0" |
---|
126 | { |
---|
127 | cat fcm-make.cfg.0 |
---|
128 | echo "extract.location{diff}[t]=" |
---|
129 | } >fcm-make.cfg |
---|
130 | base_tests |
---|
131 | #------------------------------------------------------------------------------- |
---|
132 | TEST_KEY="$TEST_KEY_BASE-diff" |
---|
133 | { |
---|
134 | cat fcm-make.cfg.0 |
---|
135 | echo "extract.location{diff}[t]=$T_REPOS/branch" |
---|
136 | echo "extract.location{diff}[t]=" |
---|
137 | } >fcm-make.cfg |
---|
138 | base_tests |
---|
139 | #------------------------------------------------------------------------------- |
---|
140 | TEST_KEY="$TEST_KEY_BASE-diff-with-base" |
---|
141 | { |
---|
142 | cat fcm-make.cfg.0 |
---|
143 | echo "extract.location{diff}[t]=$T_REPOS/branch" |
---|
144 | echo "extract.location[t]=$T_REPOS/trunk" |
---|
145 | echo "extract.location{diff}[t]=" |
---|
146 | } >fcm-make.cfg |
---|
147 | base_tests |
---|
148 | #------------------------------------------------------------------------------- |
---|
149 | TEST_KEY="$TEST_KEY_BASE-inherit-base-eq-my-diff" |
---|
150 | mkdir -p i0 i1 |
---|
151 | cat fcm-make.cfg.0 >i0/fcm-make.cfg |
---|
152 | fcm make --new -q -C i0 |
---|
153 | { |
---|
154 | echo 'use=$HERE/../i0' |
---|
155 | echo "extract.location{diff}[t]=$T_REPOS/trunk" |
---|
156 | } >i1/fcm-make.cfg |
---|
157 | run_pass "$TEST_KEY" fcm make --new -C i1 |
---|
158 | sed '/^\[info\] location t: /!d; s/^\[info\] location t: //' \ |
---|
159 | i1/.fcm-make/log > "$TEST_KEY.log" |
---|
160 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
161 | 0: $T_REPOS/trunk@2 (1) |
---|
162 | __LOG__ |
---|
163 | #------------------------------------------------------------------------------- |
---|
164 | TEST_KEY="$TEST_KEY_BASE-inherit-base-eq-1-of-my-diff" |
---|
165 | # N.B. The 3 lines below have been done in the test above. |
---|
166 | # Uncomment them if the above test is removed. |
---|
167 | #mkdir -p i0 i1 |
---|
168 | #cat fcm-make.cfg.0 >i0/fcm-make.cfg |
---|
169 | #fcm make --new -q -C i0 |
---|
170 | { |
---|
171 | echo 'use=$HERE/../i0' |
---|
172 | echo "extract.location{diff}[t]=$T_REPOS/branch $T_REPOS/trunk" |
---|
173 | } >i1/fcm-make.cfg |
---|
174 | run_pass "$TEST_KEY" fcm make --new -C i1 |
---|
175 | sed '/^\[info\] location t: /!d; s/^\[info\] location t: //' \ |
---|
176 | i1/.fcm-make/log > "$TEST_KEY.log" |
---|
177 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
178 | 0: $T_REPOS/trunk@2 (1) |
---|
179 | 1: $T_REPOS/branch@2 (2) |
---|
180 | __LOG__ |
---|
181 | #------------------------------------------------------------------------------- |
---|
182 | exit 0 |
---|