From 75de3397fd9b4e93752ecc6123deec8521aa0532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marijan=20Petri=C4=8Devi=C4=87?= Date: Tue, 25 Jan 2022 13:23:37 +0100 Subject: [PATCH 1/4] nixos/tests: fix #146169 --- nixos/lib/testing-python.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index a67040468136..885783b1d0b1 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -51,6 +51,7 @@ rec { , enableOCR ? false , skipLint ? false , passthru ? {} + , interactive ? false }: let # Reifies and correctly wraps the python test driver for @@ -139,7 +140,8 @@ rec { wrapProgram $out/bin/nixos-test-driver \ --set startScripts "''${vmStartScripts[*]}" \ --set testScript "$out/test-script" \ - --set vlans '${toString vlans}' + --set vlans '${toString vlans}' \ + ${if interactive then "--add-flags --interactive" else ""} ''); # Make a full-blown test @@ -217,6 +219,7 @@ rec { testName = name; qemu_pkg = pkgs.qemu; nodes = nodes pkgs.qemu; + interactive = true; }; test = From 44830dc0482b0325b384203b79a7f1bf4ce5e5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marijan=20Petri=C4=8Devi=C4=87?= Date: Tue, 25 Jan 2022 13:43:56 +0100 Subject: [PATCH 2/4] use lib.optionalString --- nixos/lib/testing-python.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index 885783b1d0b1..3d89e5484d16 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -141,7 +141,7 @@ rec { --set startScripts "''${vmStartScripts[*]}" \ --set testScript "$out/test-script" \ --set vlans '${toString vlans}' \ - ${if interactive then "--add-flags --interactive" else ""} + ${lib.optionalString (interactive) "--add-flags --interactive"} ''); # Make a full-blown test From d590556d5cd2d3b80e9ef6ba73cfa740fed895cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marijan=20Petri=C4=8Devi=C4=87?= Date: Tue, 25 Jan 2022 13:45:49 +0100 Subject: [PATCH 3/4] update docs --- .../development/running-nixos-tests-interactively.section.md | 4 ++-- .../development/running-nixos-tests-interactively.section.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/doc/manual/development/running-nixos-tests-interactively.section.md b/nixos/doc/manual/development/running-nixos-tests-interactively.section.md index 4c399586eb52..a1431859ff59 100644 --- a/nixos/doc/manual/development/running-nixos-tests-interactively.section.md +++ b/nixos/doc/manual/development/running-nixos-tests-interactively.section.md @@ -5,7 +5,7 @@ when developing or debugging a test: ```ShellSession $ nix-build . -A nixosTests.login.driverInteractive -$ ./result/bin/nixos-test-driver --interactive +$ ./result/bin/nixos-test-driver [...] >>> ``` @@ -28,7 +28,7 @@ You can re-use the VM states coming from a previous run by setting the `--keep-vm-state` flag. ```ShellSession -$ ./result/bin/nixos-test-driver --interactive --keep-vm-state +$ ./result/bin/nixos-test-driver --keep-vm-state ``` The machine state is stored in the `$TMPDIR/vm-state-machinename` diff --git a/nixos/doc/manual/from_md/development/running-nixos-tests-interactively.section.xml b/nixos/doc/manual/from_md/development/running-nixos-tests-interactively.section.xml index 8348ab56deb3..0e47350a0d24 100644 --- a/nixos/doc/manual/from_md/development/running-nixos-tests-interactively.section.xml +++ b/nixos/doc/manual/from_md/development/running-nixos-tests-interactively.section.xml @@ -6,7 +6,7 @@ $ nix-build . -A nixosTests.login.driverInteractive -$ ./result/bin/nixos-test-driver --interactive +$ ./result/bin/nixos-test-driver [...] >>> @@ -30,7 +30,7 @@ $ ./result/bin/nixos-test-driver --interactive the --keep-vm-state flag. -$ ./result/bin/nixos-test-driver --interactive --keep-vm-state +$ ./result/bin/nixos-test-driver --keep-vm-state The machine state is stored in the From 411bb3c35f729ea88f84c35150e7b67727d8d075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marijan=20Petri=C4=8Devi=C4=87?= Date: Wed, 26 Jan 2022 11:27:01 +0100 Subject: [PATCH 4/4] add --no-interactive flag --- nixos/lib/test-driver/test_driver/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/test_driver/__init__.py b/nixos/lib/test-driver/test_driver/__init__.py index 498a4f56c55b..61d91c9ed654 100755 --- a/nixos/lib/test-driver/test_driver/__init__.py +++ b/nixos/lib/test-driver/test_driver/__init__.py @@ -61,7 +61,7 @@ def main() -> None: "-I", "--interactive", help="drop into a python repl and run the tests interactively", - action="store_true", + action=argparse.BooleanOptionalAction, ) arg_parser.add_argument( "--start-scripts",