| 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 |
#------------------------------------------------------------------------------ |
| 19 |
# Test workflow installation |
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
set_test_number 20 |
| 22 |
|
| 23 |
cat > flow.cylc <<__HERE__ |
| 24 |
# This is definitely not an OK flow.cylc file. |
| 25 |
[cylc] |
| 26 |
[[parameters]] |
| 27 |
__HERE__ |
| 28 |
|
| 29 |
rm etc/global.cylc |
| 30 |
|
| 31 |
TEST_NAME="${TEST_NAME_BASE}.vanilla" |
| 32 |
run_fail "${TEST_NAME}" cylc lint . |
| 33 |
named_grep_ok "check-for-error-code" "S004" "${TEST_NAME}.stdout" |
| 34 |
|
| 35 |
TEST_NAME="${TEST_NAME_BASE}.pick-a-ruleset" |
| 36 |
run_fail "${TEST_NAME}" cylc lint . -r 728 |
| 37 |
named_grep_ok "check-for-error-code" "U998" "${TEST_NAME}.stdout" |
| 38 |
|
| 39 |
TEST_NAME="${TEST_NAME_BASE}.inplace" |
| 40 |
run_fail "${TEST_NAME}" cylc lint . -i |
| 41 |
named_grep_ok "check-for-error-code-in-file" "U998" flow.cylc |
| 42 |
|
| 43 |
rm flow.cylc |
| 44 |
|
| 45 |
cat > suite.rc <<__HERE__ |
| 46 |
# This is definitely not an OK flow.cylc file. |
| 47 |
{{FOO}} |
| 48 |
__HERE__ |
| 49 |
|
| 50 |
TEST_NAME="${TEST_NAME_BASE}.pick-a-ruleset-728" |
| 51 |
run_fail "${TEST_NAME}" cylc lint . -r 728 |
| 52 |
named_grep_ok "do-not-upgrade-check-if-compat-mode" "Lint after renaming" "${TEST_NAME}.stderr" |
| 53 |
|
| 54 |
TEST_NAME="${TEST_NAME_BASE}.pick-a-ruleset-728-exit-zero" |
| 55 |
run_ok "${TEST_NAME}" cylc lint . -r 728 --exit-zero |
| 56 |
|
| 57 |
TEST_NAME="${TEST_NAME_BASE}.pick-a-ruleset-all" |
| 58 |
run_fail "${TEST_NAME}" cylc lint . -r all |
| 59 |
|
| 60 |
TEST_NAME="${TEST_NAME_BASE}.exit-zero" |
| 61 |
run_ok "${TEST_NAME}" cylc lint --exit-zero . |
| 62 |
|
| 63 |
rm suite.rc |
| 64 |
|
| 65 |
cat > flow.cylc <<__HERE__ |
| 66 |
# This one is fine |
| 67 |
[scheduler] |
| 68 |
__HERE__ |
| 69 |
|
| 70 |
TEST_NAME="${TEST_NAME_BASE}.zero-issues" |
| 71 |
run_ok "${TEST_NAME}" cylc lint . |
| 72 |
named_grep_ok "message on no errors" "found no issues" "${TEST_NAME}.stdout" |
| 73 |
|
| 74 |
# It returns an error message if you attempt to lint a non-existant location |
| 75 |
TEST_NAME="it-fails-if-not-target" |
| 76 |
run_fail ${TEST_NAME} cylc lint "a-$(uuidgen)" |
| 77 |
grep_ok "Workflow ID not found" "${TEST_NAME}.stderr" |
| 78 |
|
| 79 |
# It returns a reference in reference mode |
| 80 |
TEST_NAME="it-returns-a-reference" |
| 81 |
run_ok "${TEST_NAME}" cylc lint --list-codes |
| 82 |
named_grep_ok "${TEST_NAME}-contains-style-codes" "^S001:" "${TEST_NAME}.stdout" |
| 83 |
TEST_NAME="it-returns-a-reference-style" |
| 84 |
run_ok "${TEST_NAME}" cylc lint --list-codes -r 'style' |
| 85 |
named_grep_ok "${TEST_NAME}-contains-style-codes" "^S001:" "${TEST_NAME}.stdout" |
| 86 |
grep_fail "^U" "${TEST_NAME}.stdout" |
| 87 |
|
| 88 |
|
| 89 |
rm flow.cylc |