Fix fragile T9579 tests
authorJavran Cheng <Javran.c@gmail.com>
Tue, 12 May 2015 21:54:57 +0000 (07:54 +1000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Tue, 12 May 2015 22:44:56 +0000 (08:44 +1000)
Fix fragile tests according to comment 13 of #9579 (by @bherzog)

Done by capturing stderr and replace `xx bytes` with `NUM bytes`
(literal).

Some numbers like `(1 MB)` would still remain, but I think
it's safe to assume the actual difference in bytes (on different
architectures) is too small to have an effect on the rounded megabyte
value.

Test Plan: validate

Reviewers: erikd, austin

Reviewed By: erikd, austin

Subscribers: erikd, bgamari, thomie, bherzog

Differential Revision: https://phabricator.haskell.org/D882

GHC Trac Issues: #9579

testsuite/tests/rts/T9579/T9579_outofheap_rtsall.stdout [moved from testsuite/tests/rts/T9579/T9579_outofheap_rtsall.stderr with 57% similarity]
testsuite/tests/rts/T9579/T9579_outofheap_rtsall_no_suggestions.stdout [moved from testsuite/tests/rts/T9579/T9579_outofheap_rtsall_no_suggestions.stderr with 82% similarity]
testsuite/tests/rts/T9579/T9579_outofheap_rtsnone.stdout [moved from testsuite/tests/rts/T9579/T9579_outofheap_rtsnone.stderr with 62% similarity]
testsuite/tests/rts/T9579/T9579_outofheap_rtssome.stdout [moved from testsuite/tests/rts/T9579/T9579_outofheap_rtssome.stderr with 62% similarity]
testsuite/tests/rts/T9579/T9579_stackoverflow_rtsall.stderr [deleted file]
testsuite/tests/rts/T9579/T9579_stackoverflow_rtsall.stdout [new file with mode: 0644]
testsuite/tests/rts/T9579/T9579_stackoverflow_rtsall_no_suggestions.stdout [moved from testsuite/tests/rts/T9579/T9579_stackoverflow_rtsall_no_suggestions.stderr with 70% similarity]
testsuite/tests/rts/T9579/T9579_stackoverflow_rtsnone.stdout [moved from testsuite/tests/rts/T9579/T9579_stackoverflow_rtsnone.stderr with 92% similarity]
testsuite/tests/rts/T9579/T9579_stackoverflow_rtssome.stdout [moved from testsuite/tests/rts/T9579/T9579_stackoverflow_rtssome.stderr with 92% similarity]
testsuite/tests/rts/T9579/all.T

@@ -1,3 +1,4 @@
 T9579_outofheap_rtsall: Heap exhausted;
-T9579_outofheap_rtsall: Current maximum heap size is 1048576 bytes (1 MB).
+T9579_outofheap_rtsall: Current maximum heap size is NUM bytes (1 MB).
 T9579_outofheap_rtsall: Use `+RTS -M<size>' to increase it.
+251
@@ -1,2 +1,3 @@
 T9579_outofheap_rtsall_no_suggestions: Heap exhausted;
-T9579_outofheap_rtsall_no_suggestions: Current maximum heap size is 1048576 bytes (1 MB).
+T9579_outofheap_rtsall_no_suggestions: Current maximum heap size is NUM bytes (1 MB).
+251
@@ -1,3 +1,4 @@
 T9579_outofheap_rtsnone: Heap exhausted;
-T9579_outofheap_rtsnone: Current maximum heap size is 1048576 bytes (1 MB).
+T9579_outofheap_rtsnone: Current maximum heap size is NUM bytes (1 MB).
 T9579_outofheap_rtsnone: Relink with -rtsopts and use `+RTS -M<size>' to increase it.
+251
@@ -1,3 +1,4 @@
 T9579_outofheap_rtssome: Heap exhausted;
-T9579_outofheap_rtssome: Current maximum heap size is 1048576 bytes (1 MB).
+T9579_outofheap_rtssome: Current maximum heap size is NUM bytes (1 MB).
 T9579_outofheap_rtssome: Relink with -rtsopts and use `+RTS -M<size>' to increase it.
+251
diff --git a/testsuite/tests/rts/T9579/T9579_stackoverflow_rtsall.stderr b/testsuite/tests/rts/T9579/T9579_stackoverflow_rtsall.stderr
deleted file mode 100644 (file)
index 16404b8..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-T9579_stackoverflow_rtsall: Stack space overflow: current size 99136 bytes.
-T9579_stackoverflow_rtsall: Use `+RTS -Ksize -RTS' to increase it.
diff --git a/testsuite/tests/rts/T9579/T9579_stackoverflow_rtsall.stdout b/testsuite/tests/rts/T9579/T9579_stackoverflow_rtsall.stdout
new file mode 100644 (file)
index 0000000..6d12889
--- /dev/null
@@ -0,0 +1,3 @@
+T9579_stackoverflow_rtsall: Stack space overflow: current size NUM bytes.
+T9579_stackoverflow_rtsall: Use `+RTS -Ksize -RTS' to increase it.
+2
@@ -1,2 +1,3 @@
-T9579_stackoverflow_rtsnone: Stack space overflow: current size 99136 bytes.
+T9579_stackoverflow_rtsnone: Stack space overflow: current size NUM bytes.
 T9579_stackoverflow_rtsnone: Relink with -rtsopts and use `+RTS -Ksize -RTS' to increase it.
+2
@@ -1,2 +1,3 @@
-T9579_stackoverflow_rtssome: Stack space overflow: current size 99136 bytes.
+T9579_stackoverflow_rtssome: Stack space overflow: current size NUM bytes.
 T9579_stackoverflow_rtssome: Relink with -rtsopts and use `+RTS -Ksize -RTS' to increase it.
+2
index e029b4a..fd5a3b6 100644 (file)
@@ -1,64 +1,31 @@
-test('T9579_stackoverflow_rtsnone',
-     [exit_code(2),
-      extra_clean([ 'tmp_T9579_stackoverflow_rtsnone/Main.hi',
-                    'tmp_T9579_stackoverflow_rtsnone/Main.o' ])],
-       run_command,
-     ['$MAKE -s --no-print-directory T9579_stackoverflow_rtsnone \
-       && ./T9579_stackoverflow_rtsnone'])
-
-test('T9579_stackoverflow_rtssome',
-     [exit_code(2),
-      extra_clean([ 'tmp_T9579_stackoverflow_rtssome/Main.hi',
-                    'tmp_T9579_stackoverflow_rtssome/Main.o' ])],
-       run_command,
-     ['$MAKE -s --no-print-directory T9579_stackoverflow_rtssome \
-       && ./T9579_stackoverflow_rtssome'])
-
-test('T9579_stackoverflow_rtsall',
-     [exit_code(2),
-      extra_clean([ 'tmp_T9579_stackoverflow_rtsall/Main.hi',
-                    'tmp_T9579_stackoverflow_rtsall/Main.o' ])],
-       run_command,
-     ['$MAKE -s --no-print-directory T9579_stackoverflow_rtsall \
-       && ./T9579_stackoverflow_rtsall'])
-
-test('T9579_stackoverflow_rtsall_no_suggestions',
-     [exit_code(2),
-      extra_clean([ 'tmp_T9579_stackoverflow_rtsall_no_suggestions/Main.hi',
-                    'tmp_T9579_stackoverflow_rtsall_no_suggestions/Main.o' ])],
-       run_command,
-     ['$MAKE -s --no-print-directory T9579_stackoverflow_rtsall_no_suggestions \
-       && ./T9579_stackoverflow_rtsall_no_suggestions'])
-
-test('T9579_outofheap_rtsnone',
-     [exit_code(251),
-      extra_clean([ 'tmp_T9579_outofheap_rtsnone/Main.hi',
-                    'tmp_T9579_outofheap_rtsnone/Main.o' ])],
-       run_command,
-     ['$MAKE -s --no-print-directory T9579_outofheap_rtsnone \
-      && ./T9579_outofheap_rtsnone'])
-
-test('T9579_outofheap_rtssome',
-     [exit_code(251),
-      extra_clean([ 'tmp_T9579_outofheap_rtssome/Main.hi',
-                    'tmp_T9579_outofheap_rtssome/Main.o' ])],
-       run_command,
-     ['$MAKE -s --no-print-directory T9579_outofheap_rtssome \
-       && ./T9579_outofheap_rtssome'])
-
-test('T9579_outofheap_rtsall',
-     [exit_code(251),
-      extra_clean([ 'tmp_T9579_outofheap_rtsall/Main.hi',
-                    'tmp_T9579_outofheap_rtsall/Main.o' ])],
-
-       run_command,
-     ['$MAKE -s --no-print-directory T9579_outofheap_rtsall \
-       && ./T9579_outofheap_rtsall'])
-
-test('T9579_outofheap_rtsall_no_suggestions',
-     [exit_code(251),
-      extra_clean([ 'tmp_T9579_outofheap_rtsall_no_suggestions/Main.hi',
-                    'tmp_T9579_outofheap_rtsall_no_suggestions/Main.o' ])],
-       run_command,
-     ['$MAKE -s --no-print-directory T9579_outofheap_rtsall_no_suggestions \
-       && ./T9579_outofheap_rtsall_no_suggestions'])
+# some numbers like "(1 MB)" would still remain.
+# but let's just assume the actual difference in bytes
+# is too small to have an effect on the rounded megabyte value.
+
+def T9579_run_test(binName, expExitCode):
+    fmt = lambda s: s.format(binName=binName)
+    # 1. compile the binary using MAKE
+    # 2. redirect stderr to stdout
+    # 3. capture exitcode using echo
+    # 4. replace actual number with NUM
+    testCommandTemplate = """
+          $MAKE -s --no-print-directory T9579_{binName} \
+        && ( ( ./T9579_{binName} 2>&1; echo $?) \
+           | sed -e 's/[0-9]\+ bytes/NUM bytes/g' ) \
+    """
+
+    test(fmt('T9579_{binName}'),
+         [extra_clean([ fmt('tmp_T9579_{binName}/Main.hi'),
+                        fmt('tmp_T9579_{binName}/Main.o') ])],
+          run_command,
+          [fmt(testCommandTemplate)])
+
+T9579_run_test('stackoverflow_rtsnone',2)
+T9579_run_test('stackoverflow_rtssome',2)
+T9579_run_test('stackoverflow_rtsall',2)
+T9579_run_test('stackoverflow_rtsall_no_suggestions',2)
+
+T9579_run_test('outofheap_rtsnone',251)
+T9579_run_test('outofheap_rtssome',251)
+T9579_run_test('outofheap_rtsall',251)
+T9579_run_test('outofheap_rtsall_no_suggestions',251)