[commit: ghc] ghc-8.0: Filter out -prof callstacks from test output (#11521) (dd55ce4)

git at git.haskell.org git at git.haskell.org
Sat Feb 27 15:21:18 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/dd55ce43051156265cd30fa9a7300310b002b39d/ghc

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

commit dd55ce43051156265cd30fa9a7300310b002b39d
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Mon Feb 22 17:44:17 2016 +0100

    Filter out -prof callstacks from test output (#11521)
    
    (cherry picked from commit 176be87cb28f675d87ea8f5c07eaef7ca47ff8de)


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

dd55ce43051156265cd30fa9a7300310b002b39d
 testsuite/driver/testglobals.py            |  3 +++
 testsuite/driver/testlib.py                | 19 ++++++++++++++++---
 testsuite/tests/profiling/should_run/all.T |  1 +
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py
index 0891624..6f8dd64 100644
--- a/testsuite/driver/testglobals.py
+++ b/testsuite/driver/testglobals.py
@@ -265,6 +265,9 @@ class TestOptions:
        # Extra normalisation for compiler error messages
        self.extra_errmsg_normaliser = lambda x: x
 
+       # Keep profiling callstacks.
+       self.keep_prof_callstacks = False
+
        # The directory the test is in
        self.testdir = '.'
 
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 0251884..08ab6e1 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -516,6 +516,13 @@ def normalise_drive_letter(name, opts):
     # Windows only. Change D:\\ to C:\\.
     _normalise_fun(name, opts, lambda str: re.sub(r'[A-Z]:\\', r'C:\\', str))
 
+def keep_prof_callstacks(name, opts):
+    """Keep profiling callstacks.
+
+    Use together with `only_ways(prof_ways)`.
+    """
+    opts.keep_prof_callstacks = True
+
 def join_normalisers(*a):
     """
     Compose functions, flattening sequences.
@@ -1691,15 +1698,21 @@ def normalise_whitespace( str ):
 
 callSite_re = re.compile(r', called at (.+):[\d]+:[\d]+ in [\w\-\.]+:')
 
-def normalise_callstacks(str):
+def normalise_callstacks(s):
+    opts = getTestOpts()
     def repl(matches):
         location = matches.group(1)
         location = normalise_slashes_(location)
         return ', called at {0}:<line>:<column> in <package-id>:'.format(location)
     # Ignore line number differences in call stacks (#10834).
-    str1 = re.sub(callSite_re, repl, str)
+    s = re.sub(callSite_re, repl, s)
     # Ignore the change in how we identify implicit call-stacks
-    return str1.replace('from ImplicitParams', 'from HasCallStack')
+    s = s.replace('from ImplicitParams', 'from HasCallStack')
+    if not opts.keep_prof_callstacks:
+        # Don't output prof callstacks. Test output should be
+        # independent from the WAY we run the test.
+        s = re.sub(r'CallStack \(from -prof\):(\n  .*)*\n?', '', s)
+    return s
 
 tyCon_re = re.compile(r'TyCon\s*\d+L?\#\#\s*\d+L?\#\#\s*', flags=re.MULTILINE)
 
diff --git a/testsuite/tests/profiling/should_run/all.T b/testsuite/tests/profiling/should_run/all.T
index ae349e9..707ade3 100644
--- a/testsuite/tests/profiling/should_run/all.T
+++ b/testsuite/tests/profiling/should_run/all.T
@@ -15,6 +15,7 @@ test('T11489', [req_profiling, extra_clean(['T11489.prof', 'T11489.hp'])],
 setTestOpts(req_profiling)
 setTestOpts(extra_ways(['prof']))
 setTestOpts(only_ways(prof_ways))
+setTestOpts(keep_prof_callstacks)
 
 extra_prof_ways = ['prof', 'prof_hc_hb', 'prof_hb', 'prof_hd', 'prof_hy', 'prof_hr']
 



More information about the ghc-commits mailing list