From aaba92e0cc6e37c4ef9eb951ac9b94bae9034ecf Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 19 Jun 2026 16:50:30 +0200 Subject: [PATCH] nixos-test-driver: reintroduce `--test-script` flag Restore the ability to pass a test script on the command line through: ``` --test-script [PATH] ``` which was possible prior to its removal in: f1bcb61731224bd8440510fc620d3c51f3e51c85 I have found the flag to be quite practical for NixOS test iteration and propose hereby to reintroduce it again. While it is still possible without this flag to pass an external test script, it now needs to be done through the indirection of a `--config` configuration file - which now has to have configuration which points towards the test script, which adds enough friction as to not make it ergonomic anymore. The `--test-script` flag overwrites the configuration from the test config. --- nixos/lib/test-driver/src/test_driver/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/src/test_driver/__init__.py b/nixos/lib/test-driver/src/test_driver/__init__.py index 62c2a6073e6c..3e0588bf7bce 100644 --- a/nixos/lib/test-driver/src/test_driver/__init__.py +++ b/nixos/lib/test-driver/src/test_driver/__init__.py @@ -88,6 +88,11 @@ def main() -> None: type=Path, required=True, ) + arg_parser.add_argument( + "--test-script", + help="path to a test script to run, taking precedence over the one defined in the config file", + type=Path, + ) arg_parser.add_argument( "--keep-vm-state", help=argparse.SUPPRESS, @@ -162,8 +167,12 @@ def main() -> None: if args.debug_hook_attach is not None: debugger = Debug(logger, args.debug_hook_attach) + config = load_driver_configuration(args.config) + if args.test_script is not None: + config.test_script = args.test_script + with Driver( - config=load_driver_configuration(args.config), + config=config, out_dir=output_directory, logger=logger, keep_machine_state=args.keep_machine_state,