From 0a177f3af30806cc021c339f2575a906ad4368fa Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Wed, 8 Nov 2023 12:15:22 +0000 Subject: [PATCH] ci: Enable windows tests for 9.6.3 There were two failing tests: 1. CCompilerOverride, was attempting to use gcc.exe rather than clang.exe without also overriding the C options which led to incorrect options being passed to gcc.exe. The fix is to override to clang.exe on ghc-9.4 or newer. 2. ForeignLibs exposes a bug in GHC (https://gitlab.haskell.org/ghc/ghc/-/issues/24185) and hence is skipped for GHCs newer than 9.4 where it was first introduced. Towards fixing #8451, we just need to fix the shared library issue now. --- .github/workflows/validate.yml | 2 -- .../CCompilerOverride/custom-cc-clang.bat | 11 ++++++++++ .../CCompilerOverride/setup.test.hs | 21 ++++++++++--------- .../PackageTests/ForeignLibs/setup.test.hs | 3 ++- 4 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 cabal-testsuite/PackageTests/CCompilerOverride/custom-cc-clang.bat diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 259fcfdca7c..aa6d01a128d 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -166,7 +166,6 @@ jobs: # Have to disable *-suite validation: # - the Windows@9.6.1 problem is tracked at https://github.com/haskell/cabal/issues/8858 # - but curently can't run it with GHC 9.6, tracking: https://github.com/haskell/cabal/issues/8883 - if: (runner.os != 'Windows') || (matrix.ghc != '9.6.3') run: sh validate.sh $FLAGS -s lib-suite - name: Validate cli-tests @@ -174,7 +173,6 @@ jobs: - name: Validate cli-suite # Have to disable *-suite validation, see above the comment for lib-suite - if: (runner.os != 'Windows') || (matrix.ghc != '9.6.3') run: sh validate.sh $FLAGS -s cli-suite validate-old-ghcs: diff --git a/cabal-testsuite/PackageTests/CCompilerOverride/custom-cc-clang.bat b/cabal-testsuite/PackageTests/CCompilerOverride/custom-cc-clang.bat new file mode 100644 index 00000000000..72012c9c9d0 --- /dev/null +++ b/cabal-testsuite/PackageTests/CCompilerOverride/custom-cc-clang.bat @@ -0,0 +1,11 @@ +@echo OFF + +where /q clang.exe + +IF %ERRORLEVEL% EQU 0 ( + call clang.exe -DNOERROR6 %* + EXIT /B %ERRORLEVEL% +) + +ECHO "Cannot find C compiler" +EXIT /B 1 diff --git a/cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs b/cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs index dbc10efa7a3..5843cb2b7df 100644 --- a/cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs +++ b/cabal-testsuite/PackageTests/CCompilerOverride/setup.test.hs @@ -6,16 +6,17 @@ import Test.Cabal.Prelude main = setupAndCabalTest $ do skipUnlessGhcVersion ">= 8.8" isWin <- isWindows - ghc94 <- isGhcVersion "== 9.4.*" + ghc94 <- isGhcVersion ">= 9.4.1" env <- getTestEnv let pwd = testCurrentDir env - customCC = pwd ++ "/custom-cc" ++ if isWin then ".bat" else "" + win_suffix = if ghc94 then "-clang.bat" else ".bat" + customCC = + pwd ++ "/custom-cc" ++ if isWin then win_suffix else "" - expectBrokenIf (isWin && ghc94) 8451 $ do - setup "configure" - [ "--ghc-option=-DNOERROR1" - , "--ghc-option=-optc=-DNOERROR2" - , "--ghc-option=-optP=-DNOERROR3" - , "--with-gcc=" ++ customCC - ] - setup "build" ["-v2"] + setup "configure" + [ "--ghc-option=-DNOERROR1" + , "--ghc-option=-optc=-DNOERROR2" + , "--ghc-option=-optP=-DNOERROR3" + , "--with-gcc=" ++ customCC + ] + setup "build" ["-v2"] diff --git a/cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs b/cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs index 2bd17605b72..1dcf918eaed 100644 --- a/cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs +++ b/cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs @@ -17,6 +17,7 @@ import Distribution.Simple.Program.Types import Distribution.System import Distribution.Verbosity import Distribution.Version +import System.Directory import Test.Cabal.Prelude @@ -27,7 +28,7 @@ main = setupAndCabalTest . recordMode DoNotRecord $ do -- Foreign libraries don't work with GHC 7.6 and earlier skipUnlessGhcVersion ">= 7.8" win <- isWindows - ghc94 <- isGhcVersion "== 9.4.*" + ghc94 <- isGhcVersion ">= 9.4.1" expectBrokenIf (win && ghc94) 8451 $ withPackageDb $ do setup_install []