aboutsummaryrefslogtreecommitdiff
path: root/scripts/incremental_build/util_test.py
diff options
context:
space:
mode:
authorUsta Shrestha <usta@google.com>2023-03-08 12:19:35 -0500
committerusta <usta@google.com>2023-03-13 22:16:25 -0400
commit232b9d244581c422fcb2f17a8c87b491b16dd400 (patch)
tree9935a0c6af344ad145f5edb6d5bc08f8d0099066 /scripts/incremental_build/util_test.py
parent7e9acc68732ca7fde312ddb666cd05267a37febd (diff)
downloadbazel-232b9d244581c422fcb2f17a8c87b491b16dd400.tar.gz
Simplify pretty print of metrics
Test: incremental-build.py -c change Bug: NA Change-Id: Ic95b90e16ab2c684c624a9b082e59b2a47ab5135
Diffstat (limited to 'scripts/incremental_build/util_test.py')
-rw-r--r--scripts/incremental_build/util_test.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/scripts/incremental_build/util_test.py b/scripts/incremental_build/util_test.py
index 0e68bc3a..01b5f9c2 100644
--- a/scripts/incremental_build/util_test.py
+++ b/scripts/incremental_build/util_test.py
@@ -19,6 +19,7 @@ from util import _next_path_helper
from util import any_match
from util import get_top_dir
from util import hhmmss
+from util import period_to_seconds
class UtilTest(unittest.TestCase):
@@ -78,10 +79,25 @@ class UtilTest(unittest.TestCase):
def test_hhmmss(self):
examples = [
- (datetime.timedelta(seconds=(2 * 60 + 5)), '00:02:05.000'),
+ (datetime.timedelta(seconds=(2 * 60 + 5)), '02:05.000'),
(datetime.timedelta(seconds=(3600 + 23 * 60 + 45.897898)),
- '01:23:45.898'),
+ '1:23:45.898'),
]
for (ts, expected) in examples:
self.subTest(ts=ts, expected=expected)
self.assertEqual(hhmmss(ts), expected)
+
+ def test_period_to_seconds(self):
+ examples = [
+ ('02:05.000', 2 * 60 + 5),
+ ('1:23:45.898', 3600 + 23 * 60 + 45.898),
+ ('1.898', 1.898),
+ ('0.3', 0.3),
+ ('0', 0),
+ ('0:00', 0),
+ ('0:00:00', 0),
+ ('', 0)
+ ]
+ for (ts, expected) in examples:
+ self.subTest(ts=ts, expected=expected)
+ self.assertEqual(period_to_seconds(ts), expected)