diff --git a/cylc/flow/scripts/workflow_state.py b/cylc/flow/scripts/workflow_state.py
index 80bb4fea689..23b20b5ae90 100755
--- a/cylc/flow/scripts/workflow_state.py
+++ b/cylc/flow/scripts/workflow_state.py
@@ -197,8 +197,9 @@ def get_option_parser() -> COP:
action="store", dest="status", default=None, choices=statuses)
parser.add_option(
- "-O", "--output", metavar="OUTPUT",
- help="Check for a given task output.",
+ "-O", "--output", "--message", metavar="OUTPUT",
+ help="Check for a given task output"
+ " (--message is deprecated and aliased to task output)",
action="store", dest="output", default=None)
parser.add_option(
diff --git a/tests/flakyfunctional/events/44-timeout.t b/tests/flakyfunctional/events/44-timeout.t
index c28557194d8..d1865345b27 100755
--- a/tests/flakyfunctional/events/44-timeout.t
+++ b/tests/flakyfunctional/events/44-timeout.t
@@ -46,8 +46,8 @@ __END__
cylc workflow-state "${WORKFLOW_NAME}" >'workflow-state.log'
contains_ok 'workflow-state.log' << __END__
-stopper, 1, succeeded
-foo, 1, succeeded
+stopper, 1, succeeded, [1]
+foo, 1, succeeded, [1]
__END__
purge
diff --git a/tests/flakyfunctional/xtriggers/01-workflow_state.t b/tests/flakyfunctional/xtriggers/01-workflow_state.t
index ef401598595..f01fbf62619 100644
--- a/tests/flakyfunctional/xtriggers/01-workflow_state.t
+++ b/tests/flakyfunctional/xtriggers/01-workflow_state.t
@@ -47,10 +47,10 @@ grep_ok 'WARNING - inactivity timer timed out after PT20S' "${WORKFLOW_LOG}"
# ... with 2016/foo succeeded and 2016/FAM waiting.
cylc workflow-state -p '2016' "${WORKFLOW_NAME}" >'workflow_state.out'
contains_ok 'workflow_state.out' << __END__
-foo, 2016, succeeded
-f3, 2016, waiting
-f1, 2016, waiting
-f2, 2016, waiting
+foo, 2016, succeeded, [1]
+f3, 2016, waiting, [1]
+f1, 2016, waiting, [1]
+f2, 2016, waiting, [1]
__END__
# Check broadcast of xtrigger outputs to dependent tasks.
diff --git a/tests/functional/job-submission/16-timeout.t b/tests/functional/job-submission/16-timeout.t
index 266b04b0164..44f8c3aa324 100755
--- a/tests/functional/job-submission/16-timeout.t
+++ b/tests/functional/job-submission/16-timeout.t
@@ -54,8 +54,8 @@ __END__
cylc workflow-state "${WORKFLOW_NAME}" > workflow-state.log
contains_ok workflow-state.log << __END__
-stopper, 1, succeeded
-foo, 1, submit-failed
+stopper, 1, succeeded, [1]
+foo, 1, submit-failed, [1]
__END__
purge
diff --git a/tests/functional/reload/22-remove-task-cycling.t b/tests/functional/reload/22-remove-task-cycling.t
index 9936857ac2f..184affca3b7 100644
--- a/tests/functional/reload/22-remove-task-cycling.t
+++ b/tests/functional/reload/22-remove-task-cycling.t
@@ -75,10 +75,10 @@ workflow_run_ok "${TEST_NAME}" cylc play --debug --no-detach "${WORKFLOW_NAME}"
TEST_NAME="${TEST_NAME_BASE}-result"
cylc workflow-state "${WORKFLOW_NAME}" > workflow-state.log
contains_ok workflow-state.log << __END__
-foo, 1, succeeded
-bar, 1, succeeded
-foo, 2, succeeded
-foo, 3, succeeded
+foo, 1, succeeded, [1]
+bar, 1, succeeded, [1]
+foo, 2, succeeded, [1]
+foo, 3, succeeded, [1]
__END__
purge
diff --git a/tests/functional/workflow-state/05-message.t b/tests/functional/workflow-state/05-message.t
deleted file mode 100755
index 89acd6d83e3..00000000000
--- a/tests/functional/workflow-state/05-message.t
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env bash
-# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
-# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
-#
-# 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 cylc workflow-state "template" option
-. "$(dirname "$0")/test_header"
-#-------------------------------------------------------------------------------
-set_test_number 2
-#-------------------------------------------------------------------------------
-install_workflow "${TEST_NAME_BASE}" message
-#-------------------------------------------------------------------------------
-TEST_NAME="${TEST_NAME_BASE}-run"
-workflow_run_ok "${TEST_NAME}" cylc play --reference-test --debug --no-detach "${WORKFLOW_NAME}"
-#-------------------------------------------------------------------------------
-TEST_NAME=${TEST_NAME_BASE}-cli-template
-run_ok "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}" -p 20100101T0000Z \
- --message=hello --task=t1 --max-polls=1
-#-------------------------------------------------------------------------------
-purge
-#-------------------------------------------------------------------------------
-exit 0
diff --git a/tests/functional/workflow-state/05-output.t b/tests/functional/workflow-state/05-output.t
new file mode 100755
index 00000000000..d1591ef8c95
--- /dev/null
+++ b/tests/functional/workflow-state/05-output.t
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
+# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
+#
+# 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 cylc workflow-state for outputs (as opposed to statuses)
+. "$(dirname "$0")/test_header"
+
+set_test_number 2
+
+install_workflow "${TEST_NAME_BASE}" output
+
+TEST_NAME="${TEST_NAME_BASE}-run"
+workflow_run_ok "${TEST_NAME}" \
+ cylc play --reference-test --debug --no-detach "${WORKFLOW_NAME}"
+
+TEST_NAME=${TEST_NAME_BASE}-cli-check
+run_ok "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}" \
+ -p 20100101T0000Z --output=hello --task=t1 --max-polls=1
+
+
+purge
diff --git a/tests/functional/workflow-state/06-format.t b/tests/functional/workflow-state/06-format.t
index f43460cfbb4..24d8c63c2ab 100755
--- a/tests/functional/workflow-state/06-format.t
+++ b/tests/functional/workflow-state/06-format.t
@@ -14,13 +14,13 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-#-------------------------------------------------------------------------------
+
# Test "cylc workflow-state" cycle point format conversion, when the target workflow
# sets an explicit cycle point format, and the CLI does not.
. "$(dirname "$0")/test_header"
-#-------------------------------------------------------------------------------
+
set_test_number 5
-#-------------------------------------------------------------------------------
+
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__'
[scheduler]
UTC mode = True
@@ -33,23 +33,22 @@ init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__'
[[foo]]
script = true
__FLOW_CONFIG__
-#-------------------------------------------------------------------------------
+
TEST_NAME="${TEST_NAME_BASE}-run"
workflow_run_ok "${TEST_NAME}" cylc play --debug --no-detach "${WORKFLOW_NAME}"
-#-------------------------------------------------------------------------------
+
TEST_NAME=${TEST_NAME_BASE}-cli-poll
run_ok "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}" -p 20100101T0000Z \
--task=foo --status=succeeded
contains_ok "${TEST_NAME}.stdout" <<__OUT__
polling for 'succeeded': satisfied
__OUT__
-#-------------------------------------------------------------------------------
+
TEST_NAME=${TEST_NAME_BASE}-cli-dump
run_ok "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}" -p 20100101T0000Z
contains_ok "${TEST_NAME}.stdout" <<__OUT__
-foo, 2010-01-01, succeeded
+foo, 2010-01-01, succeeded, [1]
__OUT__
-#-------------------------------------------------------------------------------
+
purge
-#-------------------------------------------------------------------------------
-exit 0
+
diff --git a/tests/functional/workflow-state/06a-noformat.t b/tests/functional/workflow-state/06a-noformat.t
index 6bf800e27f2..9542a3b022e 100755
--- a/tests/functional/workflow-state/06a-noformat.t
+++ b/tests/functional/workflow-state/06a-noformat.t
@@ -14,14 +14,13 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-#-------------------------------------------------------------------------------
+
# Test "cylc workflow-state" cycle point format conversion, when the target workflow
# sets no explicit cycle point format, and the CLI does (the reverse of 06.t).
-
. "$(dirname "$0")/test_header"
-#-------------------------------------------------------------------------------
+
set_test_number 5
-#-------------------------------------------------------------------------------
+
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__'
[scheduler]
UTC mode = True
@@ -34,23 +33,22 @@ init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__'
[[foo]]
script = true
__FLOW_CONFIG__
-#-------------------------------------------------------------------------------
+
TEST_NAME="${TEST_NAME_BASE}-run"
workflow_run_ok "${TEST_NAME}" cylc play --debug --no-detach "${WORKFLOW_NAME}"
-#-------------------------------------------------------------------------------
+
TEST_NAME=${TEST_NAME_BASE}-cli-poll
run_ok "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}" -p 2010-01-01T00:00Z \
--task=foo --status=succeeded
contains_ok "${TEST_NAME}.stdout" <<__OUT__
polling for 'succeeded': satisfied
__OUT__
-#-------------------------------------------------------------------------------
+
TEST_NAME=${TEST_NAME_BASE}-cli-dump
run_ok "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}" -p 2010-01-01T00:00Z
contains_ok "${TEST_NAME}.stdout" <<__OUT__
-foo, 20100101T0000Z, succeeded
+foo, 20100101T0000Z, succeeded, [1]
__OUT__
-#-------------------------------------------------------------------------------
+
purge
-#-------------------------------------------------------------------------------
-exit 0
+
diff --git a/tests/functional/workflow-state/07-message2.t b/tests/functional/workflow-state/07-message2.t
index cebdeecb13f..0d31b1f915b 100755
--- a/tests/functional/workflow-state/07-message2.t
+++ b/tests/functional/workflow-state/07-message2.t
@@ -15,8 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-# Test workflow-state message query on a waiting task - GitHub #2440.
-
+# Test workflow-state output query on a waiting task - GitHub #2440.
. "$(dirname "$0")/test_header"
set_test_number 4
@@ -24,11 +23,12 @@ install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
run_ok "${TEST_NAME_BASE}-val" cylc validate "${WORKFLOW_NAME}"
-workflow_run_ok "${TEST_NAME_BASE}-run" cylc play --debug --no-detach "${WORKFLOW_NAME}"
+workflow_run_ok "${TEST_NAME_BASE}-run" \
+ cylc play --debug --no-detach "${WORKFLOW_NAME}"
TEST_NAME=${TEST_NAME_BASE}-query
-run_fail "${TEST_NAME}" cylc workflow-state \
- "${WORKFLOW_NAME}" -p 2013 -t foo --max-polls=1 -m "the quick brown fox"
+run_fail "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}" \
+ -p 2013 -t foo --max-polls=1 --output x
grep_ok "ERROR: condition not satisfied" "${TEST_NAME}.stderr"
diff --git a/tests/functional/workflow-state/message/flow.cylc b/tests/functional/workflow-state/output/flow.cylc
similarity index 100%
rename from tests/functional/workflow-state/message/flow.cylc
rename to tests/functional/workflow-state/output/flow.cylc
diff --git a/tests/functional/workflow-state/message/reference.log b/tests/functional/workflow-state/output/reference.log
similarity index 100%
rename from tests/functional/workflow-state/message/reference.log
rename to tests/functional/workflow-state/output/reference.log
diff --git a/tests/functional/workflow-state/template_ref/flow.cylc b/tests/functional/workflow-state/template_ref/flow.cylc
deleted file mode 100644
index a01c722c1dc..00000000000
--- a/tests/functional/workflow-state/template_ref/flow.cylc
+++ /dev/null
@@ -1,13 +0,0 @@
-[scheduler]
- UTC mode = True
- cycle point format = %Y
-
-[scheduling]
- initial cycle point = 2010
- final cycle point = 2011
- [[graph]]
- P1Y = foo
-
-[runtime]
- [[foo]]
- script = true
diff --git a/tests/functional/workflow-state/template_ref/reference.log b/tests/functional/workflow-state/template_ref/reference.log
deleted file mode 100644
index 97101910d54..00000000000
--- a/tests/functional/workflow-state/template_ref/reference.log
+++ /dev/null
@@ -1,4 +0,0 @@
-Initial point: 2010
-Final point: 2011
-2010/foo -triggered off []
-2011/foo -triggered off []