diff options
author | Reid Barton <rwbarton@gmail.com> | 2015-06-16 16:39:15 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-06-16 16:40:36 -0500 |
commit | b98ca17e12c7efdc906f4901f25e6263a5399be1 (patch) | |
tree | ac71b782444caff319578c0e4594c1d91422d900 /libraries/base/tests/enum_processor.py | |
parent | 0760b84e62d216cbd0ba08a46331bed7c45c88bb (diff) | |
download | haskell-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-x | libraries/base/tests/enum_processor.py | 24 |
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())) |