diff --git a/validate/launcher/baseclasses.py b/validate/launcher/baseclasses.py index 4022621bd2..8b32d656d6 100644 --- a/validate/launcher/baseclasses.py +++ b/validate/launcher/baseclasses.py @@ -175,6 +175,15 @@ class Test(Loggable): self.kill_subprocess() self.process = None + def should_dump_on_failure(self): + if not self.options.dump_on_failure: + return False + + try: + return os.path.getsize(self.logfile) < self.options.max_dump_size * 1024 * 1024 + except FileNotFoundError: + return False + def __str__(self): string = self.classname if self.result != Result.NOT_RUN: diff --git a/validate/launcher/main.py b/validate/launcher/main.py index 7071d919b4..31c70bfa9b 100644 --- a/validate/launcher/main.py +++ b/validate/launcher/main.py @@ -464,6 +464,8 @@ class LauncherConfig(Loggable): action="store_true", default=False, help="Dump logs to stdout when a test fails." " Note that mdv is used to enhance output if avalaible, install with `pip install mdv`.") + parser.add_argument("--max-dump-size", dest="max_dump_size", type=float, + default=0.5, help="Maximum size of logs to dump on stdout in MB.") parser.add_argument("-c", "--config", dest="config", help="This is DEPRECATED, prefer using the testsuite format" " to configure testsuites")