Commit 3b075e1a authored by Ben Gamari's avatar Ben Gamari 🐢

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.
parent cd793325
......@@ -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():
subprocess.check_call(['git', 'status'])
subprocess.check_call(['git', 'rev-parse', 'HEAD'],
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'))
......@@ -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
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment