[commit: ghc] master: testsuite: Don't use git status to determine whether we are inside a repo (3b075e1)

git at git.haskell.org git at git.haskell.org
Sat Dec 1 15:31:25 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/3b075e1a96564f29130540d933d07840c59a0feb/ghc

>---------------------------------------------------------------

commit 3b075e1a96564f29130540d933d07840c59a0feb
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Sat Dec 1 09:28:57 2018 -0500

    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.


>---------------------------------------------------------------

3b075e1a96564f29130540d933d07840c59a0feb
 testsuite/driver/perf_notes.py | 7 ++++---
 testsuite/driver/runtests.py   | 6 +++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/testsuite/driver/perf_notes.py b/testsuite/driver/perf_notes.py
index c275041..5ceede7 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
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index c8966b4..c1e8574 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



More information about the ghc-commits mailing list