summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2018-12-01 09:28:57 -0500
committerBen Gamari <ben@smart-cactus.org>2018-12-01 09:28:57 -0500
commit3b075e1a96564f29130540d933d07840c59a0feb (patch)
treeedbb06b6ccbac2f5e876e36ce6f1d0f808dd0954
parentcd793325e3e71cee761df35df0934999f7d77ad7 (diff)
downloadhaskell-3b075e1a96564f29130540d933d07840c59a0feb.tar.gz
testsuite: Don't use git status to determine whether we are inside a repo
Git status is extremely expensive for this task. We instead use `git rev-parse HEAD` and throw away the output to ensure we don't spam the user.
-rw-r--r--testsuite/driver/perf_notes.py9
-rw-r--r--testsuite/driver/runtests.py6
2 files changed, 8 insertions, 7 deletions
diff --git a/testsuite/driver/perf_notes.py b/testsuite/driver/perf_notes.py
index c275041252..5ceede7be2 100644
--- a/testsuite/driver/perf_notes.py
+++ b/testsuite/driver/perf_notes.py
@@ -20,11 +20,12 @@ from math import ceil, trunc
from testutil import passed, failBecause
-# Check if "git status" can be run successfully.
+# Check if "git rev-parse" can be run successfully.
# True implies the current directory is a git repo.
-def can_git_status():
+def inside_git_repo():
try:
- subprocess.check_call(['git', 'status'])
+ subprocess.check_call(['git', 'rev-parse', 'HEAD'],
+ stdout=subprocess.DEVNULL)
return True
except subprocess.CalledProcessError:
return False
@@ -388,4 +389,4 @@ if __name__ == '__main__':
# Printing out percentages.
for test, metric in all_tests:
- print("{:27}{:30}".format(test, metric) + commit_string(test,'percentages')) \ No newline at end of file
+ print("{:27}{:30}".format(test, metric) + commit_string(test,'percentages'))
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index c8966b4580..c1e85744b9 100644
--- a/testsuite/driver/runtests.py
+++ b/testsuite/driver/runtests.py
@@ -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, can_git_status
+from perf_notes import MetricChange, inside_git_repo
from junit import junit
# Readline sometimes spews out ANSI escapes for some values of TERM,
@@ -118,10 +118,10 @@ if args.threads:
if args.verbose is not None:
config.verbose = args.verbose
-# Note force skip perf tests: skip if this is not a git repo (estimated with can_git_status)
+# Note force skip perf tests: skip if this is not a git repo (estimated with inside_git_repo)
# and no metrics file is given. In this case there is no way to read the previous commit's
# perf test results, nor a way to store new perf test results.
-canGitStatus = can_git_status()
+canGitStatus = inside_git_repo()
forceSkipPerfTests = not hasMetricsFile and not canGitStatus
config.skip_perf_tests = args.skip_perf_tests or forceSkipPerfTests
config.only_perf_tests = args.only_perf_tests