[commit: testsuite] master: Add a different sort of stats_num_field helper function (3967a5e)

Ian Lynagh igloo at earth.li
Fri Feb 8 01:08:56 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/3967a5e4aca1b17c47beaa72da7e633854413cb8

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

commit 3967a5e4aca1b17c47beaa72da7e633854413cb8
Author: Ian Lynagh <ian at well-typed.com>
Date:   Thu Feb 7 22:47:30 2013 +0000

    Add a different sort of stats_num_field helper function
    
    Uses look like
        stats_num_field('bytes allocated',
                        [(wordsize(32), 45648, 5),
                         (wordsize(64), 49400, 5)])
    where the first matching triple will be used. e.g. we could override
    the Win32 expected values with:
                        [(platform('i386-unknown-mingw32'), 41000, 5),
                         (wordsize(32),                     45648, 5),
                         (wordsize(64),                     49400, 5)])
    with other 32-bit platforms falling through to the wordsize(32) case.
    
    This makes it easier to give different values for different platforms,
    while being sure that all platforms are covered.

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

 driver/testlib.py           |   36 +++++++++++++++++++++++++++++-------
 tests/perf/should_run/all.T |   11 +++++------
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/driver/testlib.py b/driver/testlib.py
index 7d744bb..c988434 100644
--- a/driver/testlib.py
+++ b/driver/testlib.py
@@ -251,17 +251,39 @@ def _extra_clean( name, opts, v ):
 
 # -----
 
+def stats_num_field( field, expecteds ):
+    return lambda name, opts, f=field, e=expecteds: _stats_num_field(name, opts, f, e);
+
+def _stats_num_field( name, opts, field, expecteds ):
+    if field in opts.stats_range_fields:
+        framework_fail(name, 'duplicate-numfield', 'Duplicate ' + field + ' num_field check')
+
+    for (b, expected, dev) in expecteds:
+        if b:
+            opts.stats_range_fields[field] = (expected, dev)
+            return
+
+    framework_fail(name, 'numfield-no-expected', 'No expected value found for ' + field + ' in num_field check')
+
 def stats_range_field( field, expected, dev ):
-    return lambda name, opts, f=field, x=expected, y=dev: _stats_range_field(name, opts, f, x, y);
+    return stats_num_field( field, [(True, expected, dev)] )
 
-def _stats_range_field( name, opts, f, x, y ):
-    opts.stats_range_fields[f] = (x, y)
+def compiler_stats_num_field( field, expecteds ):
+    return lambda name, opts, f=field, e=expecteds: _compiler_stats_num_field(name, opts, f, e);
 
-def compiler_stats_range_field( field, expected, dev ):
-    return lambda name, opts, f=field, x=expected, y=dev: _compiler_stats_range_field(name, opts, f, x, y);
+def _compiler_stats_num_field( name, opts, field, expecteds ):
+    if field in opts.compiler_stats_range_fields:
+        framework_fail(name, 'duplicate-numfield', 'Duplicate ' + field + ' num_field check')
+
+    for (b, expected, dev) in expecteds:
+        if b:
+            opts.compiler_stats_range_fields[field] = (expected, dev)
+            return
 
-def _compiler_stats_range_field( name, opts, f, x, y ):
-    opts.compiler_stats_range_fields[f] = (x, y)
+    framework_fail(name, 'numfield-no-expected', 'No expected value found for ' + field + ' in num_field check')
+
+def compiler_stats_range_field( field, expected, dev ):
+    return compiler_stats_num_field( field, [(True, expected, dev)] )
 
 # -----
 
diff --git a/tests/perf/should_run/all.T b/tests/perf/should_run/all.T
index d484c96..6ec8523 100644
--- a/tests/perf/should_run/all.T
+++ b/tests/perf/should_run/all.T
@@ -59,12 +59,11 @@ test('T3738',
      [extra_clean(['T3738a.hi', 'T3738a.o']),
       stats_range_field('peak_megabytes_allocated', 1, 0),
                                      # expected value: 1 (amd64/Linux)
-      when(wordsize(32),
-          stats_range_field('bytes allocated', 45648, 5)),
-                                     # expected value: 45648 (x86/Linux):
-      when(wordsize(64),
-          stats_range_field('bytes allocated', 49400, 5)),
-                                     # expected value: 49400 (amd64/Linux)
+      stats_num_field('bytes allocated',
+                      [(wordsize(32), 45648, 5),
+                    # expected value: 45648 (x86/Linux)
+                       (wordsize(64), 49400, 5)]),
+                    # expected value: 49400 (amd64/Linux)
       only_ways(['normal'])
       ],
      compile_and_run,





More information about the ghc-commits mailing list