[llvm] 749c20b - [LIT] Add a test for lit.Test.toMetricValue. NFC
Jon Roelofs via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 2 17:35:42 PDT 2025
Author: Jon Roelofs
Date: 2025-04-02T17:35:14-07:00
New Revision: 749c20b3e0b88792c10d7709874f3ae374e8170e
URL: https://github.com/llvm/llvm-project/commit/749c20b3e0b88792c10d7709874f3ae374e8170e
DIFF: https://github.com/llvm/llvm-project/commit/749c20b3e0b88792c10d7709874f3ae374e8170e.diff
LOG: [LIT] Add a test for lit.Test.toMetricValue. NFC
Added:
Modified:
llvm/utils/lit/tests/Inputs/test-data/dummy_format.py
llvm/utils/lit/tests/Inputs/test-data/metrics.ini
llvm/utils/lit/tests/test-data.py
llvm/utils/lit/tests/test-output.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/tests/Inputs/test-data/dummy_format.py b/llvm/utils/lit/tests/Inputs/test-data/dummy_format.py
index a2d314fdb1a8d..30bd1814a6a42 100644
--- a/llvm/utils/lit/tests/Inputs/test-data/dummy_format.py
+++ b/llvm/utils/lit/tests/Inputs/test-data/dummy_format.py
@@ -27,10 +27,16 @@ def execute(self, test, lit_config):
# Load additional metrics.
for key, value_str in cfg.items("results"):
value = eval(value_str)
+ metric = lit.Test.toMetricValue(value)
if isinstance(value, int):
- metric = lit.Test.IntMetricValue(value)
+ assert isinstance(metric, lit.Test.IntMetricValue)
+ assert metric.format() == lit.Test.IntMetricValue(value).format()
elif isinstance(value, float):
- metric = lit.Test.RealMetricValue(value)
+ assert isinstance(metric, lit.Test.RealMetricValue)
+ assert metric.format() == lit.Test.RealMetricValue(value).format()
+ elif isinstance(value, str):
+ assert isinstance(metric, lit.Test.JSONMetricValue)
+ assert metric.format() == lit.Test.JSONMetricValue(value).format()
else:
raise RuntimeError("unsupported result type")
result.addMetric(key, metric)
diff --git a/llvm/utils/lit/tests/Inputs/test-data/metrics.ini b/llvm/utils/lit/tests/Inputs/test-data/metrics.ini
index 01b09c5c77529..52fa32be71166 100644
--- a/llvm/utils/lit/tests/Inputs/test-data/metrics.ini
+++ b/llvm/utils/lit/tests/Inputs/test-data/metrics.ini
@@ -4,4 +4,5 @@ result_output = Test passed.
[results]
value0 = 1
-value1 = 2.3456
\ No newline at end of file
+value1 = 2.3456
+value2 = "stringy"
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/test-data.py b/llvm/utils/lit/tests/test-data.py
index 628a319dd4f52..6d2df74fd5a4d 100644
--- a/llvm/utils/lit/tests/test-data.py
+++ b/llvm/utils/lit/tests/test-data.py
@@ -9,4 +9,5 @@
# CHECK-NEXT: *** TEST 'test-data :: metrics.ini' RESULTS ***
# CHECK-NEXT: value0: 1
# CHECK-NEXT: value1: 2.3456
+# CHECK-NEXT: value2: "stringy"
# CHECK-NEXT: ***
diff --git a/llvm/utils/lit/tests/test-output.py b/llvm/utils/lit/tests/test-output.py
index d0d01202330f0..86b3bb4c7509e 100644
--- a/llvm/utils/lit/tests/test-output.py
+++ b/llvm/utils/lit/tests/test-output.py
@@ -10,7 +10,8 @@
# CHECK-NEXT: "elapsed": {{[-+0-9.eE]+}},
# CHECK-NEXT: "metrics": {
# CHECK-NEXT: "value0": 1,
-# CHECK-NEXT: "value1": 2.3456
+# CHECK-NEXT: "value1": 2.3456,
+# CHECK-NEXT: "value2": "stringy"
# CHECK-NEXT: }
# CHECK-NEXT: "name": "test-data :: metrics.ini",
# CHECK-NEXT: "output": "Test passed."
More information about the llvm-commits
mailing list