Skip to content

Commit

Permalink
Merge pull request #2218 from matthewrmshin/fix-jobscript-semicolon-e…
Browse files Browse the repository at this point in the history
…rr-trap

job.sh: fix ERR trap
  • Loading branch information
hjoliver committed Mar 28, 2017
2 parents ab81169 + 59ce9cd commit f4dc2b9
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/cylc/job.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ cylc__job__main() {
for signal_name in ${CYLC_VACATION_SIGNALS:-}; do
trap "cylc__job__trap_vacation ${signal_name}" "${signal_name}"
done
set -u
set -o pipefail
set -euo pipefail
# Export CYLC_ suite and task environment variables
cylc__job__inst__cylc_env
# Write task job self-identify
Expand Down
1 change: 1 addition & 0 deletions tests/api-suite-info/03-get-graph-raw-4/suite.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[cylc]
UTC mode = True
[[reference test]]
required run mode = live
live mode suite timeout = PT30S
Expand Down
1 change: 0 additions & 1 deletion tests/job-file-trap/02-pipefail.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ suite_run_fail "${TEST_NAME_BASE}-run" \
T1_STATUS_FILE="${SUITE_RUN_DIR}/log/job/1/t1/01/job.status"
contains_ok "${T1_STATUS_FILE}" <<'__STATUS__'
CYLC_JOB_EXIT=EXIT
CYLC_JOB_EXIT=ERR
__STATUS__

purge_suite "${SUITE_NAME}"
Expand Down
2 changes: 1 addition & 1 deletion tests/jobscript/12-err-script.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set_test_number 4
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
run_ok "${TEST_NAME_BASE}-run" cylc run "${SUITE_NAME}" --reference-test --debug
grep_ok 'ERR foo bar baz qux' "${SUITE_RUN_DIR}/log/job/1/foo/01/job.err"
grep_ok 'EXIT foo bar baz qux' "${SUITE_RUN_DIR}/log/job/1/foo/01/job.err"
run_fail "${TEST_NAME_BASE}-grep-02" \
grep -q -F 'ERR foo bar baz qux' "${SUITE_RUN_DIR}/log/job/1/foo/02/job.err"

Expand Down
28 changes: 28 additions & 0 deletions tests/jobscript/15-semicolon.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2017 NIWA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test error trapping in cmd1; cmd2 syntax. If cmd1 fails, the error trap
# should trigger.
. "$(dirname "${0}")/test_header"
set_test_number 2

install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
run_ok "${TEST_NAME_BASE}-run" cylc run "${SUITE_NAME}" --reference-test --debug

purge_suite "${SUITE_NAME}"
exit
4 changes: 4 additions & 0 deletions tests/jobscript/15-semicolon/reference.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2017-02-09T16:45:37Z INFO - Initial point: 1
2017-02-09T16:45:37Z INFO - Final point: 1
2017-02-09T16:45:37Z INFO - [foo.1] -triggered off []
2017-02-09T16:45:37Z INFO - [foo.1] -triggered off []
17 changes: 17 additions & 0 deletions tests/jobscript/15-semicolon/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[cylc]
[[reference test]]
expected task failures = foo.1
[[events]]
abort on stalled = True
[scheduling]
[[dependencies]]
graph = foo
[runtime]
[[foo]]
script = """
if ((${CYLC_TASK_SUBMIT_NUMBER} == 1)); then
false; true
fi
"""
[[[job]]]
execution retry delays = PT0S

0 comments on commit f4dc2b9

Please sign in to comment.