Browse Source

mesonbuild/mtest: plumb and report a test's start time

Camilo Celis Guzman 1 month ago
parent
commit
7a76fecdf7
1 changed files with 17 additions and 11 deletions
  1. 17
    11
      mesonbuild/mtest.py

+ 17
- 11
mesonbuild/mtest.py View File

@@ -320,8 +320,8 @@ class TestRun:
320 320
 
321 321
     @classmethod
322 322
     def make_exitcode(cls, test: 'TestSerialisation', test_env: typing.Dict[str, str],
323
-                      returncode: int, duration: float, stdo: typing.Optional[str],
324
-                      stde: typing.Optional[str],
323
+                      returncode: int, starttime: float, duration: float,
324
+                      stdo: typing.Optional[str], stde: typing.Optional[str],
325 325
                       cmd: typing.Optional[typing.List[str]]) -> 'TestRun':
326 326
         if returncode == GNU_SKIP_RETURNCODE:
327 327
             res = TestResult.SKIP
@@ -331,11 +331,12 @@ class TestRun:
331 331
             res = TestResult.EXPECTEDFAIL if bool(returncode) else TestResult.UNEXPECTEDPASS
332 332
         else:
333 333
             res = TestResult.FAIL if bool(returncode) else TestResult.OK
334
-        return cls(test, test_env, res, returncode, duration, stdo, stde, cmd)
334
+        return cls(test, test_env, res, returncode, starttime, duration, stdo, stde, cmd)
335 335
 
336 336
     @classmethod
337 337
     def make_tap(cls, test: 'TestSerialisation', test_env: typing.Dict[str, str],
338
-                 returncode: int, duration: float, stdo: str, stde: str,
338
+                 returncode: int, starttime: float, duration: float,
339
+                 stdo: str, stde: str,
339 340
                  cmd: typing.Optional[typing.List[str]]) -> 'TestRun':
340 341
         res = None
341 342
         num_tests = 0
@@ -369,15 +370,16 @@ class TestRun:
369 370
             else:
370 371
                 res = TestResult.FAIL if failed else TestResult.OK
371 372
 
372
-        return cls(test, test_env, res, returncode, duration, stdo, stde, cmd)
373
+        return cls(test, test_env, res, returncode, starttime, duration, stdo, stde, cmd)
373 374
 
374 375
     def __init__(self, test: 'TestSerialisation', test_env: typing.Dict[str, str],
375
-                 res: TestResult, returncode: int, duration: float,
376
+                 res: TestResult, returncode: int, starttime: float, duration: float,
376 377
                  stdo: typing.Optional[str], stde: typing.Optional[str],
377 378
                  cmd: typing.Optional[typing.List[str]]):
378 379
         assert isinstance(res, TestResult)
379 380
         self.res = res
380 381
         self.returncode = returncode
382
+        self.starttime = starttime
381 383
         self.duration = duration
382 384
         self.stdo = stdo
383 385
         self.stde = stde
@@ -391,7 +393,10 @@ class TestRun:
391 393
             res += 'NONE\n'
392 394
         else:
393 395
             test_only_env = set(self.env.items()) - set(os.environ.items())
394
-            res += '{}{}\n'.format(env_tuple_to_str(test_only_env), ' '.join(self.cmd))
396
+            starttime_str = time.strftime("%H:%M:%S", time.gmtime(self.starttime))
397
+            res += '{} {}{}\n'.format(
398
+                starttime_str, env_tuple_to_str(test_only_env), ' '.join(self.cmd)
399
+            )
395 400
         if self.stdo:
396 401
             res += '--- stdout ---\n'
397 402
             res += self.stdo
@@ -417,6 +422,7 @@ def write_json_log(jsonlogfile: typing.TextIO, test_name: str, result: TestRun)
417 422
     jresult = {'name': test_name,
418 423
                'stdout': result.stdo,
419 424
                'result': result.res.value,
425
+               'starttime': result.starttime,
420 426
                'duration': result.duration,
421 427
                'returncode': result.returncode,
422 428
                'env': result.env,
@@ -480,7 +486,7 @@ class SingleTestRunner:
480 486
         cmd = self._get_cmd()
481 487
         if cmd is None:
482 488
             skip_stdout = 'Not run because can not execute cross compiled binaries.'
483
-            return TestRun(self.test, self.test_env, TestResult.SKIP, GNU_SKIP_RETURNCODE, 0.0, skip_stdout, None, None)
489
+            return TestRun(self.test, self.test_env, TestResult.SKIP, GNU_SKIP_RETURNCODE, time.time(), 0.0, skip_stdout, None, None)
484 490
         else:
485 491
             wrap = TestHarness.get_wrapper(self.options)
486 492
             if self.options.gdb:
@@ -610,14 +616,14 @@ class SingleTestRunner:
610 616
             stdo = ""
611 617
             stde = additional_error
612 618
         if timed_out:
613
-            return TestRun(self.test, self.test_env, TestResult.TIMEOUT, p.returncode, duration, stdo, stde, cmd)
619
+            return TestRun(self.test, self.test_env, TestResult.TIMEOUT, p.returncode, starttime, duration, stdo, stde, cmd)
614 620
         else:
615 621
             if self.test.protocol == 'exitcode':
616
-                return TestRun.make_exitcode(self.test, self.test_env, p.returncode, duration, stdo, stde, cmd)
622
+                return TestRun.make_exitcode(self.test, self.test_env, p.returncode, starttime, duration, stdo, stde, cmd)
617 623
             else:
618 624
                 if self.options.verbose:
619 625
                     print(stdo, end='')
620
-                return TestRun.make_tap(self.test, self.test_env, p.returncode, duration, stdo, stde, cmd)
626
+                return TestRun.make_tap(self.test, self.test_env, p.returncode, starttime, duration, stdo, stde, cmd)
621 627
 
622 628
 
623 629
 class TestHarness:

Loading…
Cancel
Save