pw_unit_test: Provide start_time to ResultDB
This will be useful for time-limiting queries.
Bug: 247857184
Change-Id: I637a0240e8cdac48bc23ba6800393effd0e9b708
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/112316
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Ted Pudlik <tpudlik@google.com>
diff --git a/pw_unit_test/py/pw_unit_test/test_runner.py b/pw_unit_test/py/pw_unit_test/test_runner.py
index 0d49ff9..ae74c52 100644
--- a/pw_unit_test/py/pw_unit_test/test_runner.py
+++ b/pw_unit_test/py/pw_unit_test/test_runner.py
@@ -16,6 +16,7 @@
import argparse
import asyncio
import base64
+import datetime
import enum
import json
import logging
@@ -89,6 +90,7 @@
self.name: str = name
self.file_path: str = file_path
self.status: TestResult = TestResult.UNKNOWN
+ self.start_time: datetime.datetime
self.duration_s: float
def __repr__(self) -> str:
@@ -177,6 +179,7 @@
if self._executable.endswith('.py'):
command.insert(0, sys.executable)
+ test.start_time = datetime.datetime.now(datetime.timezone.utc)
start_time = time.monotonic()
try:
process = await pw_cli.process.run_async(*command,
@@ -235,6 +238,7 @@
# like '1.1e-10', which is an invalid input for
# google.protobuf.duration.
"duration": "%.9fs" % test.duration_s,
+ "start_time": test.start_time.isoformat(),
"testMetadata": {
# Use the file path as the test name in the Milo UI. (If this is
# left unspecified, the UI will attempt to build a "good enough"