summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorReid Barton <rwbarton@gmail.com>2015-06-16 16:39:15 -0500
committerAustin Seipp <austin@well-typed.com>2015-06-16 16:40:36 -0500
commitb98ca17e12c7efdc906f4901f25e6263a5399be1 (patch)
treeac71b782444caff319578c0e4594c1d91422d900 /libraries
parent0760b84e62d216cbd0ba08a46331bed7c45c88bb (diff)
downloadhaskell-b98ca17e12c7efdc906f4901f25e6263a5399be1.tar.gz
Make enum01/enum02/enum03 tests clang-compatible
... by entirely replacing the use of CPP by a custom preprocessor; clang -E -traditional has no stringification mechanism at all. Reviewed By: thomie, austin Differential Revision: https://phabricator.haskell.org/D957 GHC Trac Issues: #9399
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/tests/all.T6
-rw-r--r--libraries/base/tests/enum01.hs7
-rw-r--r--libraries/base/tests/enum02.hs7
-rw-r--r--libraries/base/tests/enum03.hs7
-rwxr-xr-xlibraries/base/tests/enum_processor.py24
5 files changed, 42 insertions, 9 deletions
diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T
index 1154a5335d..1c90d14e99 100644
--- a/libraries/base/tests/all.T
+++ b/libraries/base/tests/all.T
@@ -77,9 +77,9 @@ test('dynamic002', normal, compile_and_run, [''])
test('dynamic003', extra_run_opts('+RTS -K32m -RTS'), compile_and_run, [''])
test('dynamic004', omit_ways(['normal', 'threaded1', 'ghci']), compile_and_run, [''])
test('dynamic005', normal, compile_and_run, [''])
-test('enum01', when(fast(), skip), compile_and_run, ['-cpp'])
-test('enum02', when(fast(), skip), compile_and_run, ['-cpp'])
-test('enum03', when(fast(), skip), compile_and_run, ['-cpp'])
+test('enum01', when(fast(), skip), compile_and_run, [''])
+test('enum02', when(fast(), skip), compile_and_run, [''])
+test('enum03', when(fast(), skip), compile_and_run, [''])
test('enum04', normal, compile_and_run, [''])
test('exceptionsrun001', normal, compile_and_run, [''])
test('exceptionsrun002', normal, compile_and_run, [''])
diff --git a/libraries/base/tests/enum01.hs b/libraries/base/tests/enum01.hs
index 0f261732b6..0ae39b14d1 100644
--- a/libraries/base/tests/enum01.hs
+++ b/libraries/base/tests/enum01.hs
@@ -1,5 +1,9 @@
-- !!! Testing the Prelude's Enum instances.
-{-# LANGUAGE CPP #-}
+{-# OPTIONS_GHC -F -pgmF ./enum_processor.py #-}
+-- The processor is a non-CPP-based equivalent of
+-- #define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
+-- which is not portable to clang
+
module Main(main) where
import Control.Exception
@@ -82,7 +86,6 @@ main = do
OK - on with the regression testing.
-}
-#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
testEnumInt :: IO ()
diff --git a/libraries/base/tests/enum02.hs b/libraries/base/tests/enum02.hs
index 23de6ebdf9..f7e843c537 100644
--- a/libraries/base/tests/enum02.hs
+++ b/libraries/base/tests/enum02.hs
@@ -1,5 +1,9 @@
-- !!! Testing the Int Enum instances.
-{-# LANGUAGE CPP #-}
+{-# OPTIONS_GHC -F -pgmF ./enum_processor.py #-}
+-- The processor is a non-CPP-based equivalent of
+-- #define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
+-- which is not portable to clang
+
module Main(main) where
import Control.Exception
@@ -15,7 +19,6 @@ main = do
putStrLn "Testing Enum Int64:"
testEnumInt64
-#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
testEnumInt8 :: IO ()
testEnumInt8 = do
diff --git a/libraries/base/tests/enum03.hs b/libraries/base/tests/enum03.hs
index 1cbe3091ea..181354a5e5 100644
--- a/libraries/base/tests/enum03.hs
+++ b/libraries/base/tests/enum03.hs
@@ -1,5 +1,9 @@
-- !!! Testing the Word Enum instances.
-{-# LANGUAGE CPP #-}
+{-# OPTIONS_GHC -F -pgmF ./enum_processor.py #-}
+-- The processor is a non-CPP-based equivalent of
+-- #define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
+-- which is not portable to clang
+
module Main(main) where
import Control.Exception
@@ -17,7 +21,6 @@ main = do
testEnumWord64
-#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
testEnumWord8 :: IO ()
testEnumWord8 = do
diff --git a/libraries/base/tests/enum_processor.py b/libraries/base/tests/enum_processor.py
new file mode 100755
index 0000000000..86c3d6c94a
--- /dev/null
+++ b/libraries/base/tests/enum_processor.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+import sys
+
+def process(s):
+ while True:
+ start = s.find('printTest')
+ if start == -1:
+ return s
+ j0 = j = s.index('(', start) + 1
+ depth = 1
+ while depth > 0:
+ if s[j] == '(':
+ depth += 1
+ if s[j] == ')':
+ depth -= 1
+ j += 1
+ argument = s[j0:j-1]
+ expansion = '(do{ putStr ( " " ++ "%s" ++ " = " ) ; print (%s) })' \
+ % (argument, argument)
+ s = s[:start] + expansion + s[j:]
+
+_, _, inputFile, outputFile = sys.argv
+open(outputFile, 'w').write(process(open(inputFile, 'r').read()))