diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-11-04 11:47:32 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2021-11-04 12:54:05 -0400 |
commit | 910a3713921267b7508fe488ba7f1cd858271b47 (patch) | |
tree | e18643611ec3be5dee3b4818bf6fece6da96f439 | |
parent | dc53dd592b1deacd3f940154c355fb119fed065c (diff) | |
download | haskell-910a3713921267b7508fe488ba7f1cd858271b47.tar.gz |
testsuite: Add support for collecting tix files to the driver
-rw-r--r-- | hadrian/src/Flavour.hs | 4 | ||||
-rw-r--r-- | testsuite/driver/runtests.py | 6 | ||||
-rw-r--r-- | testsuite/driver/testglobals.py | 2 | ||||
-rw-r--r-- | testsuite/driver/testlib.py | 13 |
4 files changed, 22 insertions, 3 deletions
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs index aedf78ff64..e6b80a853b 100644 --- a/hadrian/src/Flavour.hs +++ b/hadrian/src/Flavour.hs @@ -28,6 +28,7 @@ import Settings.Parser import Text.Parsec.Prim as P import Text.Parsec.Combinator as P import Text.Parsec.Char as P +import System.Directory (canonicalizePath) import Control.Monad.Except import UserSettings @@ -252,6 +253,9 @@ enableGhcCoverage = addArgs $ notStage0 ? mconcat [ package compiler ? enableCoverage , package ghc ? enableCoverage , package ghci ? enableCoverage + , builder (Testsuite RunTest) ? do + path <- expr $ buildRoot >>= liftIO . canonicalizePath + pure ["--hpc", path -/- "testsuite/hpc-tix"] ] where -- In principle this should work but in practice it does not: -fhpc does diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py index eff240fc78..04efa21390 100644 --- a/testsuite/driver/runtests.py +++ b/testsuite/driver/runtests.py @@ -81,6 +81,8 @@ parser.add_argument("--ignore-perf-failures", choices=['increases','decreases',' help="Do not fail due to out-of-tolerance perf tests") parser.add_argument("--only-report-hadrian-deps", type=argparse.FileType('w'), help="Dry run the testsuite and report all extra hadrian depenedencies needed on the given file") +parser.add_argument("--hpc", type=Path, + help="Enable collection of tix files from test compilations in the given directory") args = parser.parse_args() @@ -170,6 +172,10 @@ elif args.ignore_perf_failures == 'decreases': if args.test_env: config.test_env = args.test_env +config.tix_dir = args.hpc +if config.tix_dir is not None: + config.tix_dir.mkdir(exist_ok=True) + config.cygwin = False config.msys = False diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py index da82458fcf..6203600179 100644 --- a/testsuite/driver/testglobals.py +++ b/testsuite/driver/testglobals.py @@ -217,6 +217,8 @@ class TestConfig: # The path specifies the file in which to write the dependencies self.only_report_hadrian_deps = None # type: Optional[Path] + # Where to place tix files from compilation runs? + self.tix_dir = None # type: Optional[Path] def validate(self) -> None: """ Check the TestConfig for self-consistency """ diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index efeaa94b89..846e813838 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -1675,7 +1675,11 @@ def simple_build(name: Union[TestName, str], if filter_with != '': cmd = cmd + ' | ' + filter_with - exit_code = runCmd(cmd, None, stdout, stderr, opts.compile_timeout_multiplier) + env = {} + if config.tix_dir is not None: + env['HPCTIXFILE'] = str(config.tix_dir / ('%s.%s.tix' % (name, way))) + + exit_code = runCmd(cmd, None, stdout, stderr, opts.compile_timeout_multiplier, env_overrides=env) actual_stderr_path = in_testdir(name, 'comp.stderr') @@ -2433,7 +2437,8 @@ def runCmd(cmd: str, stdout: Union[None, Path]=None, stderr: Union[None, int, Path]=None, timeout_multiplier=1.0, - print_output=False) -> int: + print_output=False, + env_overrides: Dict[str, str]={}) -> int: timeout_prog = strip_quotes(config.timeout_prog) timeout = str(int(ceil(config.timeout * timeout_multiplier))) @@ -2455,11 +2460,13 @@ def runCmd(cmd: str, # Hence it must ultimately be run by a Bourne shell. It's timeout's job # to invoke the Bourne shell + env = copy.copy(ghc_env) + env.update(env_overrides) r = subprocess.Popen([timeout_prog, timeout, cmd], stdin=stdin_file, stdout=subprocess.PIPE, stderr=hStdErr, - env=ghc_env) + env=env) stdout_buffer, stderr_buffer = r.communicate() finally: |