about summary refs log tree commit diff
path: root/nixos/lib/test-driver
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-08-12 23:01:03 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2021-08-12 23:01:03 +0200
commite1ec5acd3137d3af247f9a938d9cc086d8111377 (patch)
tree1eb40579fabfdc38ee1c392083f02640ac7f91c9 /nixos/lib/test-driver
parent260d9cc7e10e477a60d11e9b44d80fd76a4492ae (diff)
downloadnixlib-e1ec5acd3137d3af247f9a938d9cc086d8111377.tar
nixlib-e1ec5acd3137d3af247f9a938d9cc086d8111377.tar.gz
nixlib-e1ec5acd3137d3af247f9a938d9cc086d8111377.tar.bz2
nixlib-e1ec5acd3137d3af247f9a938d9cc086d8111377.tar.lz
nixlib-e1ec5acd3137d3af247f9a938d9cc086d8111377.tar.xz
nixlib-e1ec5acd3137d3af247f9a938d9cc086d8111377.tar.zst
nixlib-e1ec5acd3137d3af247f9a938d9cc086d8111377.zip
nixos/test-driver: start interactive mode if `testScript` is empty
This is relevant for `nixos-build-vms(8)` which doesn't have a
test-script. In that case it's more intuitive to directly go into the
interactive mode which is IMHO more intuitive.
Diffstat (limited to 'nixos/lib/test-driver')
-rwxr-xr-xnixos/lib/test-driver/test-driver.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index 1720e553d733..0372148cb33c 100755
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -1029,10 +1029,11 @@ if __name__ == "__main__":
 
     args = arg_parser.parse_args()
     global test_script
+    testscript = pathlib.Path(args.testscript).read_text()
 
     def test_script() -> None:
         with log.nested("running the VM test script"):
-            exec(pathlib.Path(args.testscript).read_text(), globals())
+            exec(testscript, globals())
 
     log = Logger()
 
@@ -1061,7 +1062,8 @@ if __name__ == "__main__":
                 process.terminate()
         log.close()
 
+    interactive = args.interactive or (not bool(testscript))
     tic = time.time()
-    run_tests(args.interactive)
+    run_tests(interactive)
     toc = time.time()
     print("test script finished in {:.2f}s".format(toc - tic))