From 4c052fdf3333cd9a495028527e7d5d72fe682921 Mon Sep 17 00:00:00 2001 From: Rodrigo Mesquita Date: Wed, 3 Dec 2025 10:48:17 +0000 Subject: [PATCH 1/2] Don't depend on unix on Windows Fixes #146 --- haskell-debugger.cabal | 6 ++++-- haskell-debugger/GHC/Debugger/Monad.hs | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/haskell-debugger.cabal b/haskell-debugger.cabal index 4b5327b..863e50d 100644 --- a/haskell-debugger.cabal +++ b/haskell-debugger.cabal @@ -87,7 +87,6 @@ library mtl >= 2.3 && < 3, binary >= 0.8.9 && < 0.11, process >= 1.6.25 && < 1.7, - unix >= 2.8.6 && < 2.9, filepath >= 1.5.4 && < 1.6, directory >= 1.3.9.0 && < 1.4, exceptions >= 0.10.9 && < 0.11, @@ -105,6 +104,9 @@ library haskell-debugger-view >= 0.1 && < 1.0 + if !os(windows) + build-depends: unix >= 2.8.6 && < 2.9, + hs-source-dirs: haskell-debugger default-language: GHC2021 @@ -137,7 +139,7 @@ executable hdb base, ghc, exceptions, aeson, bytestring, containers, filepath, - process, mtl, unix, + process, mtl, unordered-containers >= 0.2.19 && < 0.3, haskell-debugger, diff --git a/haskell-debugger/GHC/Debugger/Monad.hs b/haskell-debugger/GHC/Debugger/Monad.hs index 2c5b2ba..5fe2172 100644 --- a/haskell-debugger/GHC/Debugger/Monad.hs +++ b/haskell-debugger/GHC/Debugger/Monad.hs @@ -20,7 +20,9 @@ import Data.IORef import Data.Maybe import Prelude hiding (mod) import System.IO +#ifdef MIN_VERSION_unix import System.Posix.Signals +#endif import qualified Data.IntMap as IM import qualified Data.List as L import qualified Data.List.NonEmpty as NonEmpty @@ -161,8 +163,10 @@ runDebugger :: Recorder (WithSeverity DebuggerMonadLog) runDebugger l dbg_out rootDir compDir libdir units ghcInvocation' extraGhcArgs mainFp conf (Debugger action) = do let ghcInvocation = filter (\case ('-':'B':_) -> False; _ -> True) ghcInvocation' GHC.runGhc (Just libdir) $ do +#ifdef MIN_VERSION_unix -- Workaround #4162 _ <- liftIO $ installHandler sigINT Default Nothing +#endif dflags0 <- GHC.getSessionDynFlags let dflags1 = dflags0 { GHC.ghcMode = GHC.CompManager From ce9c9c7f0e47ee42ff711a505073c85c74e2d1bc Mon Sep 17 00:00:00 2001 From: Rodrigo Mesquita Date: Wed, 3 Dec 2025 11:19:26 +0000 Subject: [PATCH 2/2] ci: Run golden tests on macOS and build on Windows Runs the in-tree golden tests on macOS and builds haskell-debugger on Windows. Eventually it'd be good to also build and test on these platforms directly from the source tarball. Fixes #147 Enabling the testsuite on Windows is tracked by #149 --- .github/workflows/debugger.yaml | 26 +++++++++++++------------- cabal.project | 10 ++++++---- haskell-debugger.cabal | 1 + test/haskell/Main.hs | 6 +++++- test/haskell/Test/DAP/RunInTerminal.hs | 8 +++++++- 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/.github/workflows/debugger.yaml b/.github/workflows/debugger.yaml index b8d1181..477a7b4 100644 --- a/.github/workflows/debugger.yaml +++ b/.github/workflows/debugger.yaml @@ -25,7 +25,7 @@ name: Debugger CI jobs: build-vscode-extension: name: Build VSCode Extension - runs-on: ubuntu-latest # or macOS-latest, or windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -136,12 +136,13 @@ jobs: # Golden+Haskell tests are run on the git checkout build-n-more-test-haskell-debugger: - name: Build and Run Haskell Tests - runs-on: ubuntu-latest - # Run all jobs in the matrix to the end (IF NOT ON RELEASE) + name: Build and Run Haskell Tests (${{ matrix.runner }}) + runs-on: ${{ matrix.runner }} + # Run all jobs in the matrix to the end (IF RELEASE, STOP ON FAILURE) continue-on-error: ${{ inputs.is-release == false }} strategy: matrix: + runner: [ubuntu-latest, macOS-latest, windows-latest] # it'd be good to also build-from-hackage on windows and macOS version: [9.14.0.20251104] #, latest-nightly] disable nightly while its broken include: # - channel: https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml @@ -156,8 +157,7 @@ jobs: # Cabal store cache (main speed-up) - uses: actions/cache@v3 with: - path: | - ~/.cabal/store + path: ~/.cabal/store key: ${{ runner.os }}-ghc-${{ matrix.version }}-cabal-${{ hashFiles('**/*.cabal', 'cabal.project*') }} restore-keys: | ${{ runner.os }}-ghc-${{ matrix.version }}-cabal- @@ -168,11 +168,11 @@ jobs: cabal-version: 3.14 ghcup-release-channel: ${{ matrix.channel }} - - uses: cachix/install-nix-action@v31 - with: - nix_path: nixpkgs=channel:nixos-unstable - - - name: Build and Run integration tests + - name: Build and Run Haskell tests + shell: bash run: | - echo "Running Haskell Testsuite now..." - cabal run haskell-debugger-test --enable-executable-dynamic --allow-newer=ghc-bignum,containers,time,ghc,base,template-haskell + if [ "$RUNNER_OS" == "Windows" ]; then + cabal run haskell-debugger-test --allow-newer=ghc-bignum,containers,time,ghc,base,template-haskell + else + cabal run haskell-debugger-test --enable-executable-dynamic --allow-newer=ghc-bignum,containers,time,ghc,base,template-haskell + fi diff --git a/cabal.project b/cabal.project index ddeb56a..45861e2 100644 --- a/cabal.project +++ b/cabal.project @@ -2,9 +2,11 @@ packages: . haskell-debugger-view allow-newer: ghc-bignum,containers,time,ghc,base,template-haskell -package * - -- Speeds up a bit - library-vanilla: False +if !os(windows) + package * + -- Speeds up a bit + library-vanilla: False -executable-dynamic: True +if !os(windows) + executable-dynamic: True diff --git a/haskell-debugger.cabal b/haskell-debugger.cabal index 863e50d..68235a7 100644 --- a/haskell-debugger.cabal +++ b/haskell-debugger.cabal @@ -189,6 +189,7 @@ test-suite haskell-debugger-test tasty >= 1.5.3, tasty-golden >= 2.3.5, tasty-hunit >= 0.10.2, + tasty-expected-failure >= 0.12.3, regex >= 1.1 build-tool-depends: haskell-debugger:hdb ghc-options: -threaded diff --git a/test/haskell/Main.hs b/test/haskell/Main.hs index 1e857ed..85cb9a4 100644 --- a/test/haskell/Main.hs +++ b/test/haskell/Main.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE LambdaCase, OverloadedStrings, ViewPatterns, QuasiQuotes #-} +{-# LANGUAGE LambdaCase, OverloadedStrings, ViewPatterns, QuasiQuotes, CPP #-} module Main (main) where import Text.RE.TDFA.Text.Lazy @@ -15,6 +15,7 @@ import System.IO import Control.Exception import Test.Tasty +import Test.Tasty.ExpectedFailure import Test.Tasty.Golden as G import Test.Tasty.Golden.Advanced as G @@ -25,6 +26,9 @@ main :: IO () main = do goldens <- mapM (mkGoldenTest False) =<< findByExtension [".hdb-test"] "test/golden" defaultMain $ +#ifdef mingw32_HOST_OS + ignoreTestBecause "Testsuite is not enabled on Windows (#149)" $ +#endif testGroup "Tests" [ testGroup "Golden tests" goldens , testGroup "Unit tests" unitTests diff --git a/test/haskell/Test/DAP/RunInTerminal.hs b/test/haskell/Test/DAP/RunInTerminal.hs index 518cc16..ff98161 100644 --- a/test/haskell/Test/DAP/RunInTerminal.hs +++ b/test/haskell/Test/DAP/RunInTerminal.hs @@ -3,6 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE CPP #-} module Test.DAP.RunInTerminal (runInTerminalTests) where import Control.Concurrent @@ -17,6 +18,7 @@ import System.Random import Test.DAP import Test.Tasty import Test.Tasty.HUnit +import Test.Tasty.ExpectedFailure import Test.Utils import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Lazy.Char8 as LB8 @@ -26,7 +28,11 @@ import qualified System.Process as P runInTerminalTests = testGroup "DAP.RunInTerminal" - [ testCase "runInTerminal: proxy forwards stdin correctly" runInTerminal1 + [ +#ifdef mingw32_HOST_OS + ignoreTestBecause "Needs to be fixed for Windows" $ +#endif + testCase "runInTerminal: proxy forwards stdin correctly" runInTerminal1 ] rit_keep_tmp_dirs :: Bool