diff --git a/changes.d/6316.fix.md b/changes.d/6316.fix.md new file mode 100644 index 00000000000..956b0c06066 --- /dev/null +++ b/changes.d/6316.fix.md @@ -0,0 +1 @@ +Prevent validate step of VR changing CLI options. diff --git a/cylc/flow/scripts/validate_reinstall.py b/cylc/flow/scripts/validate_reinstall.py index fa53461b2c3..d634080a50d 100644 --- a/cylc/flow/scripts/validate_reinstall.py +++ b/cylc/flow/scripts/validate_reinstall.py @@ -39,6 +39,7 @@ in the installed workflow to ensure the change can be safely applied. """ +from copy import copy import sys from typing import TYPE_CHECKING @@ -171,7 +172,11 @@ async def vr_cli(parser: COP, options: 'Values', workflow_id: str): # Run cylc validate log_subcommand('validate --against-source', workflow_id) - await cylc_validate(parser, options, workflow_id) + + # Copy options in case validate decides to store information + # in the options object: + val_opts = copy(options) + await cylc_validate(parser, val_opts, workflow_id) # Unset options that do not apply after validation: delattr(options, 'against_source') diff --git a/tests/functional/cylc-combination-scripts/09-vr-icp-now.t b/tests/functional/cylc-combination-scripts/09-vr-icp-now.t new file mode 100644 index 00000000000..233978618c6 --- /dev/null +++ b/tests/functional/cylc-combination-scripts/09-vr-icp-now.t @@ -0,0 +1,38 @@ +#!/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 . + +#------------------------------------------------------------------------------ +# Ensure that validate step of Cylc VR cannot change the options object. +# See https://github.com/cylc/cylc-flow/issues/6262 + +. "$(dirname "$0")/test_header" +set_test_number 2 + +WORKFLOW_ID=$(workflow_id) + +cp -r "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/flow.cylc" . + +run_ok "${TEST_NAME_BASE}-vip" \ + cylc vip . \ + --workflow-name "${WORKFLOW_ID}" \ + --no-detach \ + --no-run-name + +echo "# Some Comment" >> flow.cylc + +run_ok "${TEST_NAME_BASE}-vr" \ + cylc vr "${WORKFLOW_ID}" diff --git a/tests/functional/cylc-combination-scripts/09-vr-icp-now/flow.cylc b/tests/functional/cylc-combination-scripts/09-vr-icp-now/flow.cylc new file mode 100644 index 00000000000..7aaf80f8d36 --- /dev/null +++ b/tests/functional/cylc-combination-scripts/09-vr-icp-now/flow.cylc @@ -0,0 +1,7 @@ +[scheduling] + initial cycle point = now + [[graph]] + PT1M = foo +[runtime] + [[foo]] + script = cylc stop "${CYLC_WORKFLOW_ID}"