| 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 handling of mixed up sections vs settings |
| 19 |
|
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
|
| 22 |
set_test_number 6 |
| 23 |
|
| 24 |
# 1. section as setting (normal) |
| 25 |
TEST_NAME='section-as-setting-normal' |
| 26 |
cat > 'flow.cylc' <<__HEREDOC__ |
| 27 |
[runtime] |
| 28 |
[[foo]] |
| 29 |
environment = 42 |
| 30 |
__HEREDOC__ |
| 31 |
run_fail "${TEST_NAME}-validate" cylc validate . |
| 32 |
grep_ok \ |
| 33 |
'IllegalItemError: \[runtime\]\[foo\]environment - ("environment" should be a \[section\] not a setting)' \ |
| 34 |
"${TEST_NAME}-validate.stderr" |
| 35 |
|
| 36 |
|
| 37 |
# 2. section as setting (via upgrader) |
| 38 |
# NOTE: if this test fails it is likely because the upgrader for "scheduling" |
| 39 |
# has been removed, convert this to use a new deprecated section |
| 40 |
TEST_NAME='section-as-setting-upgrader' |
| 41 |
cat > 'flow.cylc' <<__HEREDOC__ |
| 42 |
scheduling = 22 |
| 43 |
__HEREDOC__ |
| 44 |
|
| 45 |
run_fail "${TEST_NAME}-validate" cylc validate . |
| 46 |
grep_ok \ |
| 47 |
'UpgradeError: \[scheduling\] ("scheduling" should be a \[section\] not a setting' \ |
| 48 |
"${TEST_NAME}-validate.stderr" |
| 49 |
|
| 50 |
|
| 51 |
# 3. setting as section |
| 52 |
TEST_NAME='setting-as-section' |
| 53 |
cat > 'flow.cylc' <<__HEREDOC__ |
| 54 |
[scheduling] |
| 55 |
[[initial cycle point]] |
| 56 |
__HEREDOC__ |
| 57 |
|
| 58 |
run_fail "${TEST_NAME}-validate" cylc validate . |
| 59 |
grep_ok \ |
| 60 |
'IllegalItemError: \[scheduling\]initial cycle point - ("initial cycle point" should be a setting not a \[section\])' \ |
| 61 |
"${TEST_NAME}-validate.stderr" |