[llvm] 233db43 - [lit] Do not forget test times for tests that weren't executed

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 22 05:26:27 PDT 2021


Author: Roman Lebedev
Date: 2021-03-22T15:26:00+03:00
New Revision: 233db43967359cc5576b6c7629fa4fcd1d87283a

URL: https://github.com/llvm/llvm-project/commit/233db43967359cc5576b6c7629fa4fcd1d87283a
DIFF: https://github.com/llvm/llvm-project/commit/233db43967359cc5576b6c7629fa4fcd1d87283a.diff

LOG: [lit] Do not forget test times for tests that weren't executed

Even though we have read the times before,
we intentionally forget about it for performance reasons.
But that means we also forget all the times for the tests
that weren't executed this time. This is mildly inconvenient.

So, when recording the new times, first re-read the old times,
and update times for the tests that were executed,
thus preserving all original times, too.

Added: 
    

Modified: 
    llvm/utils/lit/lit/TestTimes.py
    llvm/utils/lit/tests/reorder.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lit/lit/TestTimes.py b/llvm/utils/lit/lit/TestTimes.py
index fe01c3f36eb1..621343f29d26 100644
--- a/llvm/utils/lit/lit/TestTimes.py
+++ b/llvm/utils/lit/lit/TestTimes.py
@@ -18,23 +18,23 @@ def read_test_times(suite):
 def record_test_times(tests, lit_config):
     times_by_suite = {}
     for t in tests:
+        assert t.suite.test_times is None
         if not t.result.elapsed:
             continue
         if not t.suite.exec_root in times_by_suite:
-            times_by_suite[t.suite.exec_root] = []
+            times_by_suite[t.suite.exec_root] = read_test_times(t.suite)
         time = -t.result.elapsed if t.isFailure() else t.result.elapsed
         # The "path" here is only used as a key into a dictionary. It is never
         # used as an actual path to a filesystem API, therefore we use '/' as
         # the canonical separator so that Unix and Windows machines can share
         # timing data.
-        times_by_suite[t.suite.exec_root].append(('/'.join(t.path_in_suite),
-                                                  t.result.elapsed))
+        times_by_suite[t.suite.exec_root]['/'.join(t.path_in_suite)] = t.result.elapsed
 
     for s, value in times_by_suite.items():
         try:
             path = os.path.join(s, '.lit_test_times.txt')
             with open(path, 'w') as time_file:
-                for name, time in value:
+                for name, time in value.items():
                     time_file.write(("%e" % time) + ' ' + name + '\n')
         except:
             lit_config.warning('Could not save test time: ' + path)

diff  --git a/llvm/utils/lit/tests/reorder.py b/llvm/utils/lit/tests/reorder.py
index d787112b18f2..cac0a4eecaa6 100644
--- a/llvm/utils/lit/tests/reorder.py
+++ b/llvm/utils/lit/tests/reorder.py
@@ -5,11 +5,12 @@
 # RUN: cp %{inputs}/reorder/.lit_test_times.txt %{inputs}/reorder/.lit_test_times.txt.new
 # RUN: cp %{inputs}/reorder/.lit_test_times.txt.orig %{inputs}/reorder/.lit_test_times.txt
 # RUN: not 
diff  %{inputs}/reorder/.lit_test_times.txt.new %{inputs}/reorder/.lit_test_times.txt.orig
-# RUN: FileCheck --check-prefix=TIMES --implicit-check-not=not-executed.txt < %{inputs}/reorder/.lit_test_times.txt.new %s
+# RUN: FileCheck --check-prefix=TIMES --implicit-check-not= < %{inputs}/reorder/.lit_test_times.txt.new %s
 # RUN: FileCheck < %t.out %s
 # END.
 
-# TIMES: subdir/ccc.txt
+# TIMES: not-executed.txt
+# TIMES-NEXT: subdir/ccc.txt
 # TIMES-NEXT: bbb.txt
 # TIMES-NEXT: aaa.txt
 # TIMES-NEXT: new-test.txt


        


More information about the llvm-commits mailing list