Add --test-param CLI option for runtime parameters#1036
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new --test-param KEY=VALUE command-line option to allow users to pass custom test parameters, which are then set as variables in the test context. A review comment points out that the current validation unless key && value is insufficient because empty strings are truthy in Ruby, and suggests a more robust check to prevent empty keys.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| key, value = kv.split('=', 2) | ||
| raise AutoHCKError, "Invalid --test-param format: #{kv}" unless key && value |
There was a problem hiding this comment.
The current validation unless key && value is insufficient because in Ruby, empty strings are truthy. If a user passes --test-param =value or --test-param =, key will be parsed as an empty string "", which is truthy, and the validation will pass. This would result in setting an empty key in the test parameters hash.
We should explicitly check that the key is not empty and that the value is not nil.
key, value = kv.split('=', 2)
raise AutoHCKError, "Invalid --test-param format: #{kv}" if key.to_s.empty? || value.nil?edecc60 to
9193aa3
Compare
Signed-off-by: rachael-george <rgeorge@redhat.com>
9193aa3 to
7839f21
Compare
Problem:
Functest test cases sometimes need runtime parameters that vary between runs (e.g. a path to an older installer for upgrade testing). There was no way to pass these without hardcoding them in the test JSON.
Fix:
Add a
--test-param KEY=VALUEoption to the CLI (repeatable). Each key-value pair is set as a context variable insetup_test_context, making it available as@KEY@in test JSON files via the existing replacement map.Example:
Pass an older installer path for upgrade testing:
In the test JSON,
@old_installer_path@resolves and is used to upload the old installer:{ "desc": "Validate old installer path", "host_run": "test -f '@old_installer_path@/installer/virtio-win-guest-tools.exe' || { echo 'ERROR: Old installer not found. Use --test-param old_installer_path=/path/to/old/virtio-win'; exit 1; }", "timeout": 10 }, { "local_path": "@old_installer_path@/installer/virtio-win-guest-tools.exe", "remote_path": "C:\\AutoHCK\\virtio-win-guest-tools-old.exe", "direction": "local-to-remote" }