[Git][ghc/ghc][wip/T16798] testsuite: A more portable solution to #9399
Ben Gamari
gitlab at gitlab.haskell.org
Tue Jun 11 21:31:08 UTC 2019
Ben Gamari pushed to branch wip/T16798 at Glasgow Haskell Compiler / GHC
Commits:
9a841f70 by Ben Gamari at 2019-06-11T21:30:59Z
testsuite: A more portable solution to #9399
Previously we used an awful hybrid batch script/Bourne shell script to
allow this test to run both on Windows and Linux (fixing #9399).
However, this breaks on some libc implementations (e.g. musl). Fix this.
Fixes #16798.
- - - - -
6 changed files:
- libraries/base/tests/all.T
- libraries/base/tests/enum01.hs
- libraries/base/tests/enum02.hs
- libraries/base/tests/enum03.hs
- libraries/base/tests/enum_processor.bat
- libraries/base/tests/enum_processor.py
Changes:
=====================================
libraries/base/tests/all.T
=====================================
@@ -94,13 +94,27 @@ test('dynamic004', omit_ways(['normal', 'threaded1', 'ghci']), compile_and_
test('dynamic005', normal, compile_and_run, [''])
enum_setups = [when(fast(), skip)]
-test('enum01', [extra_files(['enum_processor.bat', 'enum_processor.py']),
- enum_setups], compile_and_run, [''])
-test('enum02', [extra_files(['enum_processor.bat', 'enum_processor.py']),
- enum_setups], compile_and_run, [''])
-test('enum03', [extra_files(['enum_processor.bat', 'enum_processor.py']),
- enum_setups], compile_and_run, [''])
-test('enum04', normal, compile_and_run, [''])
+def enum_test(name):
+ """
+ These tests have a funky Python preprocessor which require some headstands
+ to run on Windows.
+ """
+ if opsys('mingw32'):
+ test(name,
+ [when(opsys('mingw32'), extra_files(['enum_processor.bat'])),
+ extra_files(['enum_processor.py'])],
+ compile_and_run,
+ ['-F -pgmF ./enum_processor.bat'])
+ else:
+ test(name,
+ [extra_files(['enum_processor.py'])],
+ compile_and_run,
+ ['-F -pgmF ./enum_processor.py'])
+
+enum_test('enum01')
+enum_test('enum02')
+enum_test('enum03')
+test('enum04', normal, compile_and_run, [''])
test('exceptionsrun001', normal, compile_and_run, [''])
test('exceptionsrun002', normal, compile_and_run, [''])
=====================================
libraries/base/tests/enum01.hs
=====================================
@@ -1,8 +1,4 @@
-- !!! Testing the Prelude's Enum instances.
-{-# OPTIONS_GHC -F -pgmF ./enum_processor.bat #-}
--- 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
=====================================
libraries/base/tests/enum02.hs
=====================================
@@ -1,8 +1,4 @@
-- !!! Testing the Int Enum instances.
-{-# OPTIONS_GHC -F -pgmF ./enum_processor.bat #-}
--- 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
=====================================
libraries/base/tests/enum03.hs
=====================================
@@ -1,8 +1,4 @@
-- !!! Testing the Word Enum instances.
-{-# OPTIONS_GHC -F -pgmF ./enum_processor.bat #-}
--- 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
=====================================
libraries/base/tests/enum_processor.bat
=====================================
@@ -1,11 +1,5 @@
:;# Problem: GHC on Windows doesn't like '-pgmF ./enum_processor.py'.
:;# See ticket:365#comment:7 for details.
:;#
-:;# Workaround: this file, which functions both as a Windows .bat script and a
-:;# Unix shell script. Hacky, but it seems to work.
-:;# Starts with a ':', to skip on Windows.
-:; "${PYTHON}" enum_processor.py $@; exit $?
-
-:;# Windows only:
%PYTHON% enum_processor.py %*
=====================================
libraries/base/tests/enum_processor.py
=====================================
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# The rough equivalent of the traditional CPP:
# #define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
# which is not portable to clang.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/9a841f70d308e9f699fb3e33f032e3b145a9c0b0
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/9a841f70d308e9f699fb3e33f032e3b145a9c0b0
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190611/1fd2ebd9/attachment-0001.html>
More information about the ghc-commits
mailing list