Commit e1bdf63f authored by brianlsmith's avatar brianlsmith
Browse files

Allow testsuite to run under MSYS/MinGW using native Python (not Cygwin Python).

This patch is based on a similar one "Enable timeout in Windows
and don't require cygwin python" by Esa Ilari Vuokko. It seems
like timeout is always built on Windows so I rearranged the logic
there to make the code clearer, Esa's patch required the user to
uncomment the MinGW-specific logic in order for it to work; this
patch does not have the MinGW-specific logic commented out.

I tested this on the trunk in Ubuntu 6.06 on i686 (VMWare).
I tested this on the trunk and ghc-6.6 branch on Windows i686.
parent cfc15fc0
......@@ -922,16 +922,20 @@ def guess_compiler_flags():
def runCmd( cmd ):
if_verbose( 1, cmd )
# On Windows, we need to run the command via the cygwin shell here,
# rather than CMD.EXE. os.system() does the right thing (as long as
# Python is the cygwin Python), but our timeout program doesn't. So
# We disable the use of the timeout program on Windows, for now.
if (config.timeout_prog == '' or config.platform == 'i386-unknown-mingw32'):
return os.system( cmd )
r = 0
if config.platform == 'i386-unknown-mingw32':
# On MinGW, we will always have timeout
assert config.timeout_prog!=''
# We need to add " around the command, because
# (like Windows programs usually) timeout parses the commandline.
r = os.spawnl(os.P_WAIT, config.timeout_prog,
config.timeout_prog,`config.timeout`,'"%s"'%cmd )
elif config.timeout_prog!='':
r = os.spawnv(os.P_WAIT, config.timeout_prog,
[config.timeout_prog,`config.timeout`,cmd] )
else:
r = os.spawnv(os.P_WAIT, config.timeout_prog,
[config.timeout_prog,`config.timeout`,cmd] )
return r << 8
r = os.system(cmd)
return r << 8
def rm_no_fail( file ):
try:
......
{-# OPTIONS -cpp #-}
-- Used to present a consistent shell view for :! commands in GHCi
-- scripts. We're assuming cygwin is installed in C:/cygwin.
-- scripts. We're assuming that sh.exe is in the path and that it
-- is a Bourne-compatible shell.
import System.Cmd
#ifdef mingw32_HOST_OS
shell s = system ("c:/cygwin/bin/sh.exe -c '" ++ s ++ "'")
shell s = system ("sh.exe -c '" ++ s ++ "'")
#else
shell s = system s
#endif
......@@ -3,7 +3,7 @@ import System.IO
import System.Process
#ifdef mingw32_HOST_OS
cmd = "c:/cygwin/bin/ls"
cmd = "ls"
#else
cmd = "/bin/ls"
#endif
......
......@@ -3,7 +3,7 @@ import System.Process
import System.IO
#ifdef mingw32_HOST_OS
cmd = "c:/cygwin/bin/ls"
cmd = "ls"
#else
cmd = "/bin/ls"
#endif
......
......@@ -81,7 +81,10 @@ main = do
forkIO (do threadDelay (read secs * 1000000)
putMVar m Nothing
)
forkIO (do p <- runCommand cmd
-- Assume sh.exe is in the path
forkIO (do p <- runProcess
"sh" ["-c",cmd]
Nothing Nothing Nothing Nothing Nothing
putMVar mp p
r <- waitForProcess p
putMVar m (Just r))
......@@ -93,7 +96,7 @@ main = do
exitWith (ExitFailure 99)
Just r -> do
exitWith r
_other -> do hPutStrLn stderr "timeout: bad arguments"
_other -> do hPutStrLn stderr $ "timeout: bad arguments " ++ show args
exitWith (ExitFailure 1)
killProcess p = do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment