mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/test-driver: introduce main method
This way we not accidentally use introduce/use global variables. Also it explictly mark the code for the mypy type checker.
This commit is contained in:
parent
c8189b52b5
commit
c1667f85bb
1 changed files with 8 additions and 2 deletions
|
@ -922,7 +922,8 @@ def subtest(name: str) -> Iterator[None]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main() -> None:
|
||||||
|
global machines
|
||||||
arg_parser = argparse.ArgumentParser()
|
arg_parser = argparse.ArgumentParser()
|
||||||
arg_parser.add_argument(
|
arg_parser.add_argument(
|
||||||
"-K",
|
"-K",
|
||||||
|
@ -944,7 +945,8 @@ if __name__ == "__main__":
|
||||||
if not cli_args.keep_vm_state:
|
if not cli_args.keep_vm_state:
|
||||||
machine.cleanup_statedir()
|
machine.cleanup_statedir()
|
||||||
machine_eval = [
|
machine_eval = [
|
||||||
"{0} = machines[{1}]".format(m.name, idx) for idx, m in enumerate(machines)
|
"global {0}; {0} = machines[{1}]".format(m.name, idx)
|
||||||
|
for idx, m in enumerate(machines)
|
||||||
]
|
]
|
||||||
exec("\n".join(machine_eval))
|
exec("\n".join(machine_eval))
|
||||||
|
|
||||||
|
@ -964,3 +966,7 @@ if __name__ == "__main__":
|
||||||
run_tests()
|
run_tests()
|
||||||
toc = time.time()
|
toc = time.time()
|
||||||
print("test script finished in {:.2f}s".format(toc - tic))
|
print("test script finished in {:.2f}s".format(toc - tic))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue