Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new graph parser bug (PR to 6.11.1) #2002

Merged
merged 4 commits into from
Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/cylc/graph_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,13 @@ def _proc_dep_pair(self, left, right):
n_info = []
expr = left
for name, offset, trig in info:
offset = offset or ''
if not trig:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No offset already results in an empty string here, not None.

trig = self.__class__.TRIG_SUCCEED
this = r'\b%s\b%s(?!:)' % (name, re.escape(offset))
if offset:
this = r'\b%s\b%s(?!:)' % (name, re.escape(offset))
else:
this = r'\b%s\b(?![\[:])' % name

that = name + offset + trig
expr = re.sub(this, that, expr)
n_info.append((name, offset, trig))
Expand Down
54 changes: 21 additions & 33 deletions tests/cylc-cat-log/06-log-rotation.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,36 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 1
#-------------------------------------------------------------------------------
# Tests that cylc cat-log correctly handes log rotation.

# Create dummy suite.
TMP_DIR=$(mktemp -d)
SUITE_NAME="$(basename ${TMP_DIR})-cat-log"
echo '' >> $TMP_DIR/suite.rc
cylc register ${SUITE_NAME} ${TMP_DIR}
. "$(dirname "$0")/test_header"
set_test_number 1
init_suite "${TEST_NAME_BASE}" '/dev/null'

# Populate its cylc-run dir with empty log files.
LOG_DIR=$(dirname $(cylc cat-log ${SUITE_NAME} -l))
mkdir -p ${LOG_DIR}
touch $LOG_DIR/out.20000103T00Z
touch $LOG_DIR/out.20000102T00Z
touch $LOG_DIR/out.20000101T00Z
touch $LOG_DIR/out.0 # Back compatability to old log rotation system.
touch $LOG_DIR/out.1
touch $LOG_DIR/out.2
LOG_DIR="$(dirname "$(cylc cat-log "${SUITE_NAME}" -l)")"
mkdir -p "${LOG_DIR}"
# Note: .0 .1 .2: back compatability to old log rotation system
touch \
"${LOG_DIR}/out.20000103T00Z" \
"${LOG_DIR}/out.20000102T00Z" \
"${LOG_DIR}/out.20000101T00Z" \
"${LOG_DIR}/out.0" \
"${LOG_DIR}/out.1" \
"${LOG_DIR}/out.2"

# Test log rotation.
cylc cat-log ${SUITE_NAME} -o -l -r 0 |xargs basename >> "$TMP_DIR/result"
cylc cat-log ${SUITE_NAME} -o -l -r 1 |xargs basename >> "$TMP_DIR/result"
cylc cat-log ${SUITE_NAME} -o -l -r 2 |xargs basename >> "$TMP_DIR/result"
cylc cat-log ${SUITE_NAME} -o -l -r 3 |xargs basename >> "$TMP_DIR/result"
cylc cat-log ${SUITE_NAME} -o -l -r 4 |xargs basename >> "$TMP_DIR/result"
cylc cat-log ${SUITE_NAME} -o -l -r 5 |xargs basename >> "$TMP_DIR/result"
cylc unregister ${SUITE_NAME}
cmp_ok "$TMP_DIR/result" <<__CMP__
for I in {0..5}; do
basename "$(cylc cat-log "${SUITE_NAME}" -o -l -r "${I}")"
done >'result'

cmp_ok 'result' <<'__CMP__'
out.20000103T00Z
out.20000102T00Z
out.20000101T00Z
out.0
out.1
out.2
__CMP__
#-------------------------------------------------------------------------------
# Tidy up.
#rm -rf $TMP_DIR
#rm -rf $LOG_DIR
echo $TMP_DIR
echo $LOG_DIR
#-------------------------------------------------------------------------------

purge_suite "${SUITE_NAME}"
exit
1 change: 1 addition & 0 deletions tests/events/25-held-not-stalled/suite.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[cylc]
[[events]]
abort on inactivity = False
abort on stalled = True
inactivity handler = cylc release '%(suite)s'
inactivity = PT5S
Expand Down
39 changes: 39 additions & 0 deletions tests/validate/59-offset-no-offset.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2016 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/>.

# GitHub PR #2002 - validation of "foo | foo[-P1D] => bar" was failing because
# the explicit ':succeed' trigger was being substituted before the offset
# instead of after, creating an invalid trigger expression.

. "$(dirname "$0")/test_header"

set_test_number 1

cat >'suite.rc' <<'__SUITE_RC__'
[scheduling]
initial cycle point = 2010
[[dependencies]]
[[[P1D]]]
graph = foo | foo[-P1D] => bar
[runtime]
[[root]]
script = true
__SUITE_RC__

run_ok "${TEST_NAME_BASE}" cylc validate 'suite.rc'

exit