summaryrefslogtreecommitdiff
path: root/libraries/base/tests/enum_processor.py
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/base/tests/enum_processor.py
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/base/tests/enum_processor.py')
-rwxr-xr-xlibraries/base/tests/enum_processor.py24
1 files changed, 24 insertions, 0 deletions
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()))