From b2e4856eec9092c4cd55db68a9870633b61107c6 Mon Sep 17 00:00:00 2001 From: Javier Sagredo <jasataco@gmail.com> Date: Wed, 31 Jul 2024 22:16:56 +0200 Subject: [PATCH] Enable autoreconf tests on Windows --- .../PackageTests/Configure/cabal.test.hs | 25 +++++++++++++++--- .../PackageTests/Configure/setup.test.hs | 26 +++++++++++++++---- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/cabal-testsuite/PackageTests/Configure/cabal.test.hs b/cabal-testsuite/PackageTests/Configure/cabal.test.hs index afcc00cbf7..cd419e8cee 100644 --- a/cabal-testsuite/PackageTests/Configure/cabal.test.hs +++ b/cabal-testsuite/PackageTests/Configure/cabal.test.hs @@ -2,9 +2,26 @@ import Test.Cabal.Prelude import Control.Monad.IO.Class import Data.Maybe import System.Directory +import System.Environment +import Data.List (isSuffixOf) + -- Test for 'build-type: Configure' example from the setup manual. main = cabalTest $ do - hasAutoreconf <- liftIO $ fmap isJust $ findExecutable "autoreconf" - skipUnless "no autoreconf" hasAutoreconf - _ <- shell "autoreconf" ["-i"] - cabal "v2-build" [] + if isWindows + then do + (mCI, mSh) <- liftIO $ (,) <$> lookupEnv "CI" <*> lookupEnv "SHELL" + case (mCI, mSh) of + (Nothing, Nothing) -> skip "Missing $SHELL" + (Nothing, Just sh) -> do + env <- getTestEnv + void $ shell sh [ "-l", "-c", "cd $(cygpath -m '" <> testTmpDir env <> "') && autoreconf -i"] + cabal "v2-build" [] + (Just{}, _) -> do + env <- getTestEnv + void $ shell "C:\\msys64\\usr\\bin\\bash.exe" [ "-l", "-c", "cd $(cygpath -m '" <> testTmpDir env <> "') && autoreconf -i"] + cabal "v2-build" [] + else do + hasAutoreconf <- liftIO $ fmap isJust $ findExecutable "autoreconf" + skipUnless "no autoreconf" hasAutoreconf + _ <- shell "autoreconf" ["-i"] + cabal "v2-build" [] diff --git a/cabal-testsuite/PackageTests/Configure/setup.test.hs b/cabal-testsuite/PackageTests/Configure/setup.test.hs index 559b88c6ff..5eaea387fe 100644 --- a/cabal-testsuite/PackageTests/Configure/setup.test.hs +++ b/cabal-testsuite/PackageTests/Configure/setup.test.hs @@ -2,9 +2,25 @@ import Test.Cabal.Prelude import Control.Monad.IO.Class import Data.Maybe import System.Directory +import System.Environment + -- Test for 'build-type: Configure' example from the setup manual. -main = setupTest $ do - hasAutoreconf <- liftIO $ fmap isJust $ findExecutable "autoreconf" - skipUnless "no autoreconf" hasAutoreconf - _ <- shell "autoreconf" ["-i"] - setup_build [] +main = setupTest $ + if isWindows + then do + (mCI, mSh) <- liftIO $ (,) <$> lookupEnv "CI" <*> lookupEnv "SHELL" + case (mCI, mSh) of + (Nothing, Nothing) -> skip "Missing $SHELL" + (Nothing, Just sh) -> do + env <- getTestEnv + void $ shell sh [ "-l", "-c", "cd $(cygpath -m '" <> testTmpDir env <> "') && autoreconf -i"] + setup_build [] + (Just{}, _) -> do + env <- getTestEnv + void $ shell "C:\\msys64\\usr\\bin\\bash.exe" [ "-l", "-c", "cd $(cygpath -m '" <> testTmpDir env <> "') && autoreconf -i"] + setup_build [] + else do + hasAutoreconf <- liftIO $ fmap isJust $ findExecutable "autoreconf" + skipUnless "no autoreconf" hasAutoreconf + _ <- shell "autoreconf" ["-i"] + setup_build [] -- GitLab