| 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 22 |
| 22 |
|
| 23 |
create_test_global_config "" " |
| 24 |
[install] |
| 25 |
source dirs = ${PWD}/cylc-src |
| 26 |
" |
| 27 |
mkdir "cylc-src" |
| 28 |
|
| 29 |
# ----------------------------------------------------------------------------- |
| 30 |
# Test default name: "cylc install" (flow in $PWD, no args) |
| 31 |
TEST_NAME="${TEST_NAME_BASE}-basic" |
| 32 |
make_rnd_workflow |
| 33 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 34 |
run_ok "${TEST_NAME}" cylc install |
| 35 |
|
| 36 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 37 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} |
| 38 |
__OUT__ |
| 39 |
popd || exit 1 |
| 40 |
purge_rnd_workflow |
| 41 |
|
| 42 |
# ----------------------------------------------------------------------------- |
| 43 |
# Test default name: "cylc install WORKFLOW_NAME" (flow in confgured source dir) |
| 44 |
make_rnd_workflow |
| 45 |
# Before adding workflow to ~/cylc-src/, check install fails: |
| 46 |
TEST_NAME="${TEST_NAME_BASE}-WORKFLOW_NAME-fail-no-src-dir" |
| 47 |
run_fail "${TEST_NAME}" cylc install "${RND_WORKFLOW_NAME}" |
| 48 |
# Now add workflow to ~/cylc-src/ and test again |
| 49 |
RND_WORKFLOW_SOURCE="${PWD}/cylc-src/${RND_WORKFLOW_NAME}" |
| 50 |
mv "$RND_WORKFLOW_NAME" "${PWD}/cylc-src/" |
| 51 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 52 |
TEST_NAME="${TEST_NAME_BASE}-WORKFLOW_NAME-install-ok" |
| 53 |
run_ok "${TEST_NAME}" cylc install "${RND_WORKFLOW_NAME}" |
| 54 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 55 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} |
| 56 |
__OUT__ |
| 57 |
popd || exit 1 |
| 58 |
purge_rnd_workflow |
| 59 |
|
| 60 |
# ----------------------------------------------------------------------------- |
| 61 |
# Test cylc install succeeds if suite.rc file in source dir |
| 62 |
# (also tests installing from absolute path) |
| 63 |
TEST_NAME="${TEST_NAME_BASE}-suite.rc" |
| 64 |
make_rnd_workflow |
| 65 |
rm -f "${RND_WORKFLOW_SOURCE}/flow.cylc" |
| 66 |
touch "${RND_WORKFLOW_SOURCE}/suite.rc" |
| 67 |
run_ok "${TEST_NAME}" cylc install "${RND_WORKFLOW_SOURCE}" --workflow-name="${RND_WORKFLOW_NAME}" |
| 68 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 69 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} |
| 70 |
__OUT__ |
| 71 |
|
| 72 |
# Test deprecation message is displayed on installing a suite.rc file |
| 73 |
MSG=$(python -c 'from cylc.flow.workflow_files import SUITERC_DEPR_MSG; |
| 74 |
print(SUITERC_DEPR_MSG)') |
| 75 |
grep_ok "$MSG" "${TEST_NAME}.stderr" |
| 76 |
|
| 77 |
purge_rnd_workflow |
| 78 |
|
| 79 |
# ----------------------------------------------------------------------------- |
| 80 |
# Test default path: "cylc install" --no-run-name (flow in $PWD) |
| 81 |
TEST_NAME="${TEST_NAME_BASE}-pwd-no-run-name" |
| 82 |
make_rnd_workflow |
| 83 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 84 |
run_ok "${TEST_NAME}" cylc install --no-run-name |
| 85 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 86 |
INSTALLED $RND_WORKFLOW_NAME from ${RND_WORKFLOW_SOURCE} |
| 87 |
__OUT__ |
| 88 |
popd || exit 1 |
| 89 |
purge_rnd_workflow |
| 90 |
|
| 91 |
# ----------------------------------------------------------------------------- |
| 92 |
# Test "cylc install" flow-name given (flow in $PWD) |
| 93 |
TEST_NAME="${TEST_NAME_BASE}-flow-name" |
| 94 |
make_rnd_workflow |
| 95 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 96 |
run_ok "${TEST_NAME}" cylc install --workflow-name="${RND_WORKFLOW_NAME}-olaf" |
| 97 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 98 |
INSTALLED ${RND_WORKFLOW_NAME}-olaf/run1 from ${RND_WORKFLOW_SOURCE} |
| 99 |
__OUT__ |
| 100 |
popd || exit 1 |
| 101 |
rm -rf "${RUN_DIR}/${RND_WORKFLOW_NAME}-olaf" |
| 102 |
purge_rnd_workflow |
| 103 |
|
| 104 |
# ----------------------------------------------------------------------------- |
| 105 |
# Test "cylc install" flow-name given, no run name (flow in $PWD) |
| 106 |
TEST_NAME="${TEST_NAME_BASE}-flow-name-no-run-name" |
| 107 |
make_rnd_workflow |
| 108 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 109 |
run_ok "${TEST_NAME}" cylc install --workflow-name="${RND_WORKFLOW_NAME}-olaf" --no-run-name |
| 110 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 111 |
INSTALLED ${RND_WORKFLOW_NAME}-olaf from ${RND_WORKFLOW_SOURCE} |
| 112 |
__OUT__ |
| 113 |
popd || exit 1 |
| 114 |
rm -rf "${RUN_DIR}/${RND_WORKFLOW_NAME}-olaf" |
| 115 |
purge_rnd_workflow |
| 116 |
|
| 117 |
# ----------------------------------------------------------------------------- |
| 118 |
# Test running cylc install twice increments run dirs correctly |
| 119 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-1" |
| 120 |
make_rnd_workflow |
| 121 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 122 |
run_ok "${TEST_NAME}" cylc install |
| 123 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 124 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} |
| 125 |
__OUT__ |
| 126 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-2" |
| 127 |
run_ok "${TEST_NAME}" cylc install |
| 128 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 129 |
INSTALLED $RND_WORKFLOW_NAME/run2 from ${RND_WORKFLOW_SOURCE} |
| 130 |
__OUT__ |
| 131 |
popd || exit 1 |
| 132 |
purge_rnd_workflow |
| 133 |
|
| 134 |
# ----------------------------------------------------------------------------- |
| 135 |
# Test running cylc install with multi level name works correctly |
| 136 |
TEST_NAME="${TEST_NAME_BASE}-install-multi-level" |
| 137 |
pushd cylc-src || exit 1 |
| 138 |
make_rnd_workflow |
| 139 |
SUB_DIR="cylctb-x$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6)" |
| 140 |
mkdir "${RND_WORKFLOW_NAME}/${SUB_DIR}" |
| 141 |
mv "${RND_WORKFLOW_NAME}/flow.cylc" "${RND_WORKFLOW_NAME}/${SUB_DIR}" |
| 142 |
|
| 143 |
run_ok "${TEST_NAME}" cylc install "${RND_WORKFLOW_NAME}/${SUB_DIR}" |
| 144 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 145 |
INSTALLED ${RND_WORKFLOW_NAME}/${SUB_DIR}/run1 from ${RND_WORKFLOW_SOURCE}/$SUB_DIR |
| 146 |
__OUT__ |
| 147 |
TEST_NAME="${TEST_NAME_BASE}-multi-level-from-pwd" |
| 148 |
pushd "${RND_WORKFLOW_SOURCE}/$SUB_DIR" || exit 1 |
| 149 |
run_ok "${TEST_NAME}" cylc install |
| 150 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 151 |
INSTALLED ${RND_WORKFLOW_NAME}/${SUB_DIR}/run2 from ${RND_WORKFLOW_SOURCE}/${SUB_DIR} |
| 152 |
__OUT__ |
| 153 |
popd || exit 1 |
| 154 |
purge_rnd_workflow |