diff --git a/lib/cylc/task_proxy.py b/lib/cylc/task_proxy.py index 0d0e8e4f59f..15c6434d77f 100644 --- a/lib/cylc/task_proxy.py +++ b/lib/cylc/task_proxy.py @@ -498,10 +498,13 @@ def retry_delay_done(self): self.sub_try_state.is_delay_done(now)) def ready_to_run(self): - """Is this task ready to run?""" + """Am I in a pre-run state but ready to run? + + Queued tasks are not counted as they've already been deemed ready. + + """ ready = ( ( - self.state.is_currently('queued') or ( self.state.is_currently('waiting') and self.prerequisites_are_all_satisfied() and diff --git a/tests/lib/bash/test_header b/tests/lib/bash/test_header index e873c1a2b54..44421fd9161 100644 --- a/tests/lib/bash/test_header +++ b/tests/lib/bash/test_header @@ -52,6 +52,8 @@ # (stdin if FILE_CONTROL is "-" or missing). # grep_ok PATTERN FILE # Run "grep -q PATTERN FILE". +# count_ok PATTERN FILE COUNT +# Test that PATTERN occurs in exactly COUNT lines of FILE. # exists_ok FILE # Test that FILE exists # exists_fail FILE @@ -235,6 +237,22 @@ function grep_ok() { fail $TEST_NAME } +function count_ok() { + local BRE=$1 + local FILE=$2 + local COUNT=$3 + local TEST_NAME=$(basename "$FILE")-count-ok + NEW_COUNT=$(grep -c "$BRE" "$FILE") + if (( NEW_COUNT == COUNT )); then + ok $TEST_NAME + return + fi + echo "Found $NEW_COUNT (not $COUNT) of $BRE in $FILE" > $TEST_NAME.stderr + mkdir -p $TEST_LOG_DIR + cp $TEST_NAME.stderr $TEST_LOG_DIR/$TEST_NAME.stderr + fail $TEST_NAME +} + function exists_ok() { local FILE=$1 local TEST_NAME=$(basename "$FILE")-file-exists-ok diff --git a/tests/task-proc-loop/00-count.t b/tests/task-proc-loop/00-count.t new file mode 100755 index 00000000000..59e1a2b816d --- /dev/null +++ b/tests/task-proc-loop/00-count.t @@ -0,0 +1,36 @@ +#!/bin/bash +# THIS FILE IS PART OF THE CYLC SUITE ENGINE. +# Copyright (C) 2008-2015 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 . + +# Test that presence of queued tasks does not cause dependency matching etc. in +# the absence of other activity - GitHub #1787. WARNING: this test is sensitive +# to the number of times the task pool gets processed as the suite runs, in +# response to task state changes. It will need to be updated if that number +# changes in the future. + +. $(dirname $0)/test_header + +set_test_number 3 +install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" + +run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}" +run_ok "${TEST_NAME_BASE}" cylc run --debug "${SUITE_NAME}" + +SUITE_LOG_DIR="$(cylc get-global-config --print-run-dir)/${SUITE_NAME}/log/suite" +count_ok "BEGIN TASK PROCESSING" $SUITE_LOG_DIR/log 6 + +purge_suite "${SUITE_NAME}" +exit diff --git a/tests/task-proc-loop/00-count/suite.rc b/tests/task-proc-loop/00-count/suite.rc new file mode 100644 index 00000000000..24c8c17b1fc --- /dev/null +++ b/tests/task-proc-loop/00-count/suite.rc @@ -0,0 +1,13 @@ +[cylc] + [[event hooks]] + timeout = PT1M + abort on timeout = True +[scheduling] + [[queues]] + [[[default]]] + limit = 1 + [[dependencies]] + graph = m1 & m2 +[runtime] + [[m1, m2]] + script = sleep 10 diff --git a/tests/task-proc-loop/test_header b/tests/task-proc-loop/test_header new file mode 120000 index 00000000000..90bd5a36f92 --- /dev/null +++ b/tests/task-proc-loop/test_header @@ -0,0 +1 @@ +../lib/bash/test_header \ No newline at end of file