Debian Codegraph @

tests/functional/cli/01-help.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 # cylc help and basic invocation.
19
20 . "$(dirname "$0")/test_header"
21 # Number of tests depends on the number of 'cylc' commands.
22 set_test_number 37
23
24 # Top help
25 run_ok "${TEST_NAME_BASE}-0" cylc
26 run_ok "${TEST_NAME_BASE}-help" cylc help
27 run_ok "${TEST_NAME_BASE}-help-id" cylc help id
28 run_ok "${TEST_NAME_BASE}-help-all" cylc help all
29 grep_ok 'trigger ...' "${TEST_NAME_BASE}-help-all.stdout"
30 run_ok "${TEST_NAME_BASE}---help" cylc --help
31 for FILE in \
32 "${TEST_NAME_BASE}-help.stdout" \
33 "${TEST_NAME_BASE}---help.stdout"
34 do
35 cmp_ok "${FILE}" "${TEST_NAME_BASE}-0.stdout"
36 done
37
38 # Sub-command - no match
39 run_fail "${TEST_NAME_BASE}-aardvark" cylc aardvark
40 cmp_ok "${TEST_NAME_BASE}-aardvark.stderr" <<'__STDERR__'
41 cylc aardvark: unknown utility. Abort.
42 Type "cylc help all" for a list of utilities.
43 __STDERR__
44
45 # Sub-command - many matches
46 run_fail "${TEST_NAME_BASE}-get" cylc get
47 cmp_ok "${TEST_NAME_BASE}-get.stderr" <<'__STDERR__'
48 cylc get: is ambiguous for:
49 cylc get-resources
50 cylc get-workflow-contact
51 cylc get-workflow-version
52 __STDERR__
53
54 # Sub-command help
55 run_ok "${TEST_NAME_BASE}-validate--help" cylc validate --help
56 run_ok "${TEST_NAME_BASE}-validate-h" cylc validate -h
57 run_ok "${TEST_NAME_BASE}-help-validate" cylc help validate
58 run_ok "${TEST_NAME_BASE}-help-va" cylc help va
59 for FILE in \
60 "${TEST_NAME_BASE}-validate--help.stdout" \
61 "${TEST_NAME_BASE}-validate-h.stdout" \
62 "${TEST_NAME_BASE}-help-validate.stdout" \
63 "${TEST_NAME_BASE}-help-va.stdout"
64 do
65 cmp_ok "${FILE}" "${TEST_NAME_BASE}-validate--help.stdout"
66 done
67
68 # Alias help
69 run_ok "${TEST_NAME_BASE}-broadcast-h" cylc broadcast -h
70 run_ok "${TEST_NAME_BASE}-bcast-h" cylc bcast -h
71 cmp_ok "${TEST_NAME_BASE}-broadcast-h.stdout" "${TEST_NAME_BASE}-bcast-h.stdout"
72
73 # Dead end
74 run_fail "${TEST_NAME_BASE}-broadcast-h" cylc check-software
75
76 # Help with IDs and the Licence
77 run_ok "${TEST_NAME_BASE}-help-id" cylc help id
78 grep_ok 'Every Installed Cylc workflow has an ID' "${TEST_NAME_BASE}-help-id.stdout"
79 run_ok "${TEST_NAME_BASE}-help-licence" cylc help licence
80 grep_ok 'GNU GENERAL PUBLIC LICENSE' "${TEST_NAME_BASE}-help-licence.stdout"
81
82 # Version
83 run_ok "${TEST_NAME_BASE}-version" cylc version
84 run_ok "${TEST_NAME_BASE}---version" cylc --version
85 run_ok "${TEST_NAME_BASE}-V" cylc -V
86 run_ok "${TEST_NAME_BASE}-version.stdout" \
87 test -n "${TEST_NAME_BASE}-version.stdout"
88 cmp_ok "${TEST_NAME_BASE}-version.stdout" "${TEST_NAME_BASE}---version.stdout"
89 cmp_ok "${TEST_NAME_BASE}-version.stdout" "${TEST_NAME_BASE}-V.stdout"
90
91 # Supplementary help
92 run_ok "${TEST_NAME_BASE}-all" cylc help all
93 run_ok "${TEST_NAME_BASE}-id" cylc help id
94
95 # Check "cylc version --long" output is correct.
96 cylc version --long | head -n 1 > long1
97 echo "$(cylc version) ($(command -v cylc))" > long2
98 cmp_ok long1 long2
99
100 # --help with no DISPLAY
101 while read -r ITEM; do
102 run_ok "${TEST_NAME_BASE}-no-display-${ITEM}--help" \
103 env DISPLAY= cylc "${ITEM#cylc-}" --help
104 done < <(cd "${CYLC_REPO_DIR}/bin" && ls 'cylc-'*)
105
106 exit