mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-22 03:53:47 +00:00
make output_directory an optional parameter
This commit is contained in:
parent
f9b5f9dba7
commit
7765670c8a
@ -33,16 +33,18 @@ class EnvDefault(argparse.Action):
|
|||||||
setattr(namespace, self.dest, values)
|
setattr(namespace, self.dest, values)
|
||||||
|
|
||||||
|
|
||||||
class WriteableDir(argparse.Action): # type: ignore
|
def raise_if_not_writeable_dir(path: Path) -> None:
|
||||||
def __call__(self, parser, namespace, values, option_string=None): # type: ignore
|
"""Raises an ArgumentTypeError if the given path isn't a writeable directory
|
||||||
if not values.is_dir():
|
Note: We want to fail as early as possible if a directory isn't writeable,
|
||||||
raise argparse.ArgumentTypeError("{0} is not a directory".format(values))
|
since an executed nixos-test could fail (very late) because of the test-driver
|
||||||
if os.access(values, os.W_OK):
|
writing in a directory without proper permissions.
|
||||||
setattr(namespace, self.dest, values)
|
"""
|
||||||
else:
|
if not path.is_dir():
|
||||||
raise argparse.ArgumentTypeError(
|
raise argparse.ArgumentTypeError("{0} is not a directory".format(path))
|
||||||
"{0} is not a writeable directory".format(values)
|
if not os.access(path, os.W_OK):
|
||||||
)
|
raise argparse.ArgumentTypeError(
|
||||||
|
"{0} is not a writeable directory".format(path)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
@ -76,10 +78,11 @@ def main() -> None:
|
|||||||
help="vlans to span by the driver",
|
help="vlans to span by the driver",
|
||||||
)
|
)
|
||||||
arg_parser.add_argument(
|
arg_parser.add_argument(
|
||||||
"output_directory",
|
"-o",
|
||||||
action=WriteableDir,
|
"--output_directory",
|
||||||
help="""The path to the directory where outputs copied from the VM will be placed.
|
help="""The path to the directory where outputs copied from the VM will be placed.
|
||||||
By e.g. Machine.copy_from_vm or Machine.screenshot""",
|
By e.g. Machine.copy_from_vm or Machine.screenshot""",
|
||||||
|
default=Path.cwd(),
|
||||||
type=Path,
|
type=Path,
|
||||||
)
|
)
|
||||||
arg_parser.add_argument(
|
arg_parser.add_argument(
|
||||||
@ -92,6 +95,8 @@ def main() -> None:
|
|||||||
|
|
||||||
args = arg_parser.parse_args()
|
args = arg_parser.parse_args()
|
||||||
|
|
||||||
|
raise_if_not_writeable_dir(args.output_directory)
|
||||||
|
|
||||||
if not args.keep_vm_state:
|
if not args.keep_vm_state:
|
||||||
rootlog.info("Machine state will be reset. To keep it, pass --keep-vm-state")
|
rootlog.info("Machine state will be reset. To keep it, pass --keep-vm-state")
|
||||||
|
|
||||||
@ -99,7 +104,7 @@ def main() -> None:
|
|||||||
args.start_scripts,
|
args.start_scripts,
|
||||||
args.vlans,
|
args.vlans,
|
||||||
args.testscript.read_text(),
|
args.testscript.read_text(),
|
||||||
args.output_directory,
|
args.output_directory.resolve(),
|
||||||
args.keep_vm_state,
|
args.keep_vm_state,
|
||||||
) as driver:
|
) as driver:
|
||||||
if args.interactive:
|
if args.interactive:
|
||||||
|
@ -48,11 +48,8 @@ class Driver:
|
|||||||
keep_vm_state=keep_vm_state,
|
keep_vm_state=keep_vm_state,
|
||||||
name=cmd.machine_name,
|
name=cmd.machine_name,
|
||||||
tmp_dir=tmp_dir,
|
tmp_dir=tmp_dir,
|
||||||
<<<<<<< HEAD
|
|
||||||
callbacks=[self.check_polling_conditions],
|
callbacks=[self.check_polling_conditions],
|
||||||
=======
|
|
||||||
out_dir=self.out_dir,
|
out_dir=self.out_dir,
|
||||||
>>>>>>> 68b2e235272 (nixos/test-driver: use an argument instead of the out env-var)
|
|
||||||
)
|
)
|
||||||
for cmd in cmd(start_scripts)
|
for cmd in cmd(start_scripts)
|
||||||
]
|
]
|
||||||
|
@ -30,7 +30,7 @@ rec {
|
|||||||
# effectively mute the XMLLogger
|
# effectively mute the XMLLogger
|
||||||
export LOGFILE=/dev/null
|
export LOGFILE=/dev/null
|
||||||
|
|
||||||
${driver}/bin/nixos-test-driver $out
|
${driver}/bin/nixos-test-driver
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = driver.passthru // {
|
passthru = driver.passthru // {
|
||||||
|
Loading…
Reference in New Issue
Block a user