Debian Codegraph @

tests/f/rnd/00-run-funtional-tests.t

raw
1 #!/usr/bin/env bash
2 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
3 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #-------------------------------------------------------------------------------
18 # Test the run-functional-tests --chunk option
19 . "$(dirname "$0")/test_header"
20 set_test_number 16
21 #-------------------------------------------------------------------------------
22
23 CTB="${CYLC_REPO_DIR}/etc/bin/run-functional-tests"
24 unset CHUNK
25
26 # ensure that 'tests/f' is used as the default test base
27 TEST_NAME="${TEST_NAME_BASE}-base"
28 run_ok "${TEST_NAME}-1" "$CTB" --dry
29 run_ok "${TEST_NAME}-2" "$CTB" --dry tests/functional
30 sort -o "${TEST_NAME}-1.stdout" "${TEST_NAME}-1.stdout"
31 sort -o "${TEST_NAME}-2.stdout" "${TEST_NAME}-2.stdout"
32 cmp_ok "${TEST_NAME}-1.stdout" "${TEST_NAME}-2.stdout"
33
34 TEST_NAME="${TEST_NAME_BASE}-chunk-base"
35 run_ok "${TEST_NAME}-1" env CHUNK="1/4" "$CTB" --dry
36 run_ok "${TEST_NAME}-2" env CHUNK="1/4" "$CTB" --dry tests/functional
37 sort -o "${TEST_NAME}-1.stdout" "${TEST_NAME}-1.stdout"
38 sort -o "${TEST_NAME}-2.stdout" "${TEST_NAME}-2.stdout"
39 cmp_ok "${TEST_NAME}-1.stdout" "${TEST_NAME}-2.stdout"
40
41 # ensure that mixing test bases works correctly
42 TEST_NAME="${TEST_NAME_BASE}-testbase"
43 run_ok "${TEST_NAME}-1" "$CTB" --dry tests/f
44 run_ok "${TEST_NAME}-2" "$CTB" --dry tests/k
45 run_ok "${TEST_NAME}-3" "$CTB" --dry tests/f tests/k
46 cat "${TEST_NAME}-2.stdout" >> "${TEST_NAME}-1.stdout"
47 sort -o "${TEST_NAME}-1.stdout" "${TEST_NAME}-1.stdout"
48 sort -o "${TEST_NAME}-3.stdout" "${TEST_NAME}-3.stdout"
49 cmp_ok "${TEST_NAME}-1.stdout" "${TEST_NAME}-3.stdout"
50
51 # ensure that the whole is equal to the sum of its parts
52 N_CHUNKS=4
53 DRY_TEST_NAME="${TEST_NAME_BASE}-all"
54 run_ok "${DRY_TEST_NAME}" "${CTB}" --dry 'tests/f' 'tests/k'
55 # list tests for each chunk (from prove not run-functional-tests)
56 for i_chunk in $(seq "${N_CHUNKS}"); do
57 TEST_NAME="${TEST_NAME_BASE}-chunk_n-${i_chunk}"
58 run_ok "${TEST_NAME}" env CHUNK="${i_chunk}/${N_CHUNKS}" "${CTB}" --dry 'tests/f' 'tests/k'
59 cat "${TEST_NAME}.stdout" >>'chunks.out'
60 done
61 # sort files ($CYLC_REPO_DIR/etc/bin/run-functional-tests uses --shuffle)
62 sort -o "${DRY_TEST_NAME}.stdout" "${DRY_TEST_NAME}.stdout"
63 sort -o 'chunks.out' 'chunks.out'
64 # compare test plan for the full and chunked versions
65 cmp_ok "${DRY_TEST_NAME}.stdout" 'chunks.out'
66
67 exit