Do not save performance test results if worktree is dirty.
authorDavid Eichmann <EichmannD@gmail.com>
Tue, 11 Dec 2018 18:19:50 +0000 (13:19 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 11 Dec 2018 18:19:51 +0000 (13:19 -0500)
Reviewers: bgamari, tdammers

Reviewed By: bgamari, tdammers

Subscribers: rwbarton, carter

GHC Trac Issues: #15924

Differential Revision: https://phabricator.haskell.org/D5368

testsuite/driver/perf_notes.py
testsuite/driver/runtests.py

index 5ceede7..6d80e07 100644 (file)
@@ -30,6 +30,10 @@ def inside_git_repo():
     except subprocess.CalledProcessError:
         return False
 
+# Check if the worktree is dirty.
+def is_worktree_dirty():
+    return subprocess.check_output(['git', 'status', '--porcelain']) != b''
+
 #
 # Some data access functions. A the moment this uses git notes.
 #
index c1e8574..02d00f0 100644 (file)
@@ -25,7 +25,7 @@ import subprocess
 
 from testutil import getStdout, Watcher, str_warn, str_info
 from testglobals import getConfig, ghc_env, getTestRun, TestOptions, brokens
-from perf_notes import MetricChange, inside_git_repo
+from perf_notes import MetricChange, inside_git_repo, is_worktree_dirty
 from junit import junit
 
 # Readline sometimes spews out ANSI escapes for some values of TERM,
@@ -394,7 +394,12 @@ else:
         with open(config.metrics_file, 'a') as file:
             file.write("\n" + Perf.format_perf_stat(stats))
     elif canGitStatus and any(stats):
-        Perf.append_perf_stat(stats)
+        if is_worktree_dirty():
+            print()
+            print(str_warn('Working Tree is Dirty') + ' performance metrics will not be saved.' + \
+                                    ' Commit changes or use --metrics-file to save metrics to a file.')
+        else:
+            Perf.append_perf_stat(stats)
 
     # Write summary
     if config.summary_file: