diff --git a/.travis.yml b/.travis.yml index 0c46109..34df4b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,19 @@ # This Travis job script has been generated by a script via # -# haskell-ci 'reflex-ghci.cabal' '--output' '.travis.yml' +# haskell-ci 'reflex-ghci.cabal' +# +# To regenerate the script (for example after adjusting tested-with) run +# +# haskell-ci regenerate # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.3.20190814 +# version: 0.10.2 # +version: ~> 1.0 language: c +os: linux dist: xenial -sudo: required git: # whether to recursively clone submodules submodules: false @@ -16,6 +21,7 @@ cache: directories: - $HOME/.cabal/packages - $HOME/.cabal/store + - $HOME/.hlint before_cache: - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log # remove files that are regenerated by 'cabal update' @@ -25,13 +31,15 @@ before_cache: - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx - rm -rfv $CABALHOME/packages/head.hackage -matrix: +jobs: include: - compiler: ghc-8.6.5 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4"]}} + addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.5","cabal-install-3.2"]}} + os: linux before_install: - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//') - WITHCOMPILER="-w $HC" + - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//') - HCPKG="$HC-pkg" - unset CC - CABAL=/opt/ghc/bin/cabal @@ -40,29 +48,8 @@ before_install: - TOP=$(pwd) - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')" - echo $HCNUMVER - - CABAL="$CABAL -vnormal+nowrap+markoutput" + - CABAL="$CABAL -vnormal+nowrap" - set -o pipefail - - | - echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk - echo 'BEGIN { state = "output"; }' >> .colorful.awk - echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk - echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk - echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk - echo ' if (state == "cabal") {' >> .colorful.awk - echo ' print blue($0)' >> .colorful.awk - echo ' } else {' >> .colorful.awk - echo ' print $0' >> .colorful.awk - echo ' }' >> .colorful.awk - echo '}' >> .colorful.awk - - cat .colorful.awk - - | - color_cabal_output () { - awk -f $TOP/.colorful.awk - } - - echo text | color_cabal_output -install: - - ${CABAL} --version - - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]" - TEST=--enable-tests - BENCH=--enable-benchmarks - HEADHACKAGE=false @@ -83,6 +70,12 @@ install: echo " prefix: $CABALHOME" >> $CABALHOME/config echo "repository hackage.haskell.org" >> $CABALHOME/config echo " url: http://hackage.haskell.org/" >> $CABALHOME/config +install: + - ${CABAL} --version + - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]" + - | + echo "program-default-options" >> $CABALHOME/config + echo " ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config - cat $CABALHOME/config - rm -fv cabal.project cabal.project.local cabal.project.freeze - travis_retry ${CABAL} v2-update -v @@ -91,20 +84,22 @@ install: - touch cabal.project - | echo "packages: ." >> cabal.project + - echo 'package reflex-ghci' >> cabal.project + - "echo ' ghc-options: -Werror=missing-methods' >> cabal.project" - | - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(reflex-ghci)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done" - cat cabal.project || true - cat cabal.project.local || true - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi - - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output + - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'" - rm cabal.project.freeze - - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output - - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all | color_cabal_output + - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all + - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all script: - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) # Packaging... - - ${CABAL} v2-sdist all | color_cabal_output + - ${CABAL} v2-sdist all # Unpacking... - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/ - cd ${DISTDIR} || false @@ -116,23 +111,28 @@ script: - touch cabal.project - | echo "packages: ${PKGDIR_reflex_ghci}" >> cabal.project + - echo 'package reflex-ghci' >> cabal.project + - "echo ' ghc-options: -Werror=missing-methods' >> cabal.project" - | - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(reflex-ghci)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done" - cat cabal.project || true - cat cabal.project.local || true # Building... # this builds all libraries and executables (without tests/benchmarks) - - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output + - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all # Building with tests and benchmarks... # build & run tests, build benchmarks - - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output + - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all + # Testing... + - export PATH="$(dirname "$HC"):$PATH" # MANUAL ADDITION + - (cd ${PKGDIR_reflex_ghci} && ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all) # MANUAL MODIFICATION # cabal check... - (cd ${PKGDIR_reflex_ghci} && ${CABAL} -vnormal check) # haddock... - - ${CABAL} v2-haddock $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output + - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all # Building without installed constraints for packages in global-db... - rm -f cabal.project.local - - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output + - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all -# REGENDATA ["reflex-ghci.cabal","--output",".travis.yml"] +# REGENDATA ("0.10.2",["reflex-ghci.cabal"]) # EOF diff --git a/ChangeLog.md b/ChangeLog.md index c98ae13..4b4e620 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,13 @@ # Revision history for reflex-ghci +## 0.1.4.1 + +* Library: Require at least version 0.7.1 of `reflex`. +* Library: Require at least version 0.3 of `reflex-process`. +* Library: Expand version bounds for `regex-tdfa` and `vty`. +* Tests: Include test fixtures in sdist. +* Tests: Fix some bugs. + ## 0.1.4.0 * Library: Export `shutdown` and `getExitEvent` to make it easier for library users to cleanly exit diff --git a/README.md b/README.md index d23f837..b4b27ba 100644 --- a/README.md +++ b/README.md @@ -20,17 +20,18 @@ This package includes a [reflex-vty](https://github.com/reflex-frp/reflex-vty)-b ```bash $ reflex-ghci -h -Welcome to reflex-ghci! +Welcome to reflex-ghci 0.1.4.0 -Usage: [-c|--command COMMAND] [-e|--expression EXPR] +Usage: reflex-ghci [-c|--command COMMAND] [-e|--expression EXPR] Run a Haskell REPL that automatically reloads when source files change. Available options: -c,--command COMMAND The ghci/cabal repl command to - run (default: "cabal repl") + run (default: "cabal repl --repl-options=-Wall") -e,--expression EXPR The optional expression to evaluate once modules have - successfully loaded (default: no expression) + successfully loaded -h,--help Show this help text + ``` Acknowledgements diff --git a/default.nix b/default.nix index 9ae29a8..97617be 100644 --- a/default.nix +++ b/default.nix @@ -1,30 +1,11 @@ -{ mkDerivation, base, bytestring, dependent-sum, directory -, filepath, fsnotify, mtl, optparse-applicative, primitive, process -, ref-tf, reflex, reflex-fsnotify, reflex-process, reflex-vty -, regex-tdfa, stdenv, temporary, text, unix, vty, which -, ghc -}: -mkDerivation { - pname = "reflex-ghci"; - version = "0.1.4.0"; - src = ./.; - isLibrary = true; - isExecutable = true; - libraryHaskellDepends = [ - base bytestring directory filepath fsnotify process reflex - reflex-fsnotify reflex-process reflex-vty regex-tdfa text unix vty - ]; - executableHaskellDepends = [ - base optparse-applicative process reflex reflex-process reflex-vty - text vty - ]; - testHaskellDepends = [ - base bytestring dependent-sum directory mtl primitive process - ref-tf reflex reflex-process reflex-vty temporary text which - ]; - testToolDepends = [ - ghc - ]; - description = "A GHCi widget library for use in reflex applications"; - license = stdenv.lib.licenses.bsd3; -} +{ callCabal2nix }: +let + src = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [ + "release.nix" + ".git" + "dist" + "dist-newstyle" + "cabal.project" + ".travis.yml" + ])) ./.; +in callCabal2nix "reflex-ghci" src {} diff --git a/reflex-ghci.cabal b/reflex-ghci.cabal index 392af1f..e7e2c6b 100644 --- a/reflex-ghci.cabal +++ b/reflex-ghci.cabal @@ -1,6 +1,6 @@ -cabal-version: >=1.10 +cabal-version: 2.4 name: reflex-ghci -version: 0.1.4.0 +version: 0.1.4.1 synopsis: A GHCi widget library for use in reflex applications description: Run GHCi from within a reflex application and interact with it using a functional-reactive interface. @@ -8,7 +8,7 @@ description: <> . bug-reports: https://github.com/reflex-frp/reflex-ghci/issues -license: BSD3 +license: BSD-3-Clause license-file: LICENSE author: Obsidian Systems LLC maintainer: maintainer@obsidian.systems @@ -18,6 +18,8 @@ build-type: Simple extra-source-files: ChangeLog.md README.md screenshot.png + tests/**/*.hs + tests/**/*.cabal tested-with: GHC ==8.6.5 library @@ -31,14 +33,14 @@ library , filepath >= 1.4 && < 1.5 , fsnotify >= 0.3 && < 0.4 , process >= 1.6 && < 1.7 - , reflex >= 0.6.3 && < 0.7 + , reflex >= 0.7.1.0 && < 0.8 , reflex-fsnotify >= 0.2 && < 0.3 - , reflex-process >= 0.2.1 && < 0.3 - , regex-tdfa >= 1.2.3 && < 1.3 + , reflex-process >= 0.3 && < 0.4 + , regex-tdfa >= 1.2.3 && < 1.4 , reflex-vty >= 0.1.3 && < 0.2 , text >= 1.2 && < 1.3 , unix >= 2.7 && < 2.8 - , vty >= 5.25 && < 5.26 + , vty >=5.21 && <5.29 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall @@ -50,12 +52,13 @@ executable reflex-ghci base , optparse-applicative >= 0.14.0 && < 0.16 , process - , reflex + , reflex >= 0.7.1.0 , reflex-ghci , reflex-vty , reflex-process , text , vty + autogen-modules: Paths_reflex_ghci other-modules: Paths_reflex_ghci ghc-options: -threaded -rtsopts default-language: Haskell2010 @@ -70,7 +73,7 @@ test-suite test , dependent-sum >= 0.6 && < 0.7 , directory , mtl >= 2.2 && < 2.3 - , primitive >= 0.6.4 && < 0.7 + , primitive >= 0.6.4 && < 0.8 , process , ref-tf >= 0.4 && < 0.5 , reflex @@ -79,7 +82,6 @@ test-suite test , reflex-vty , temporary >= 1.3 && < 1.4 , text - other-modules: HeadlessHost ghc-options: -threaded -rtsopts default-language: Haskell2010 diff --git a/reflex-platform/default.nix b/reflex-platform/default.nix index 7a04778..2b4d4ab 100644 --- a/reflex-platform/default.nix +++ b/reflex-platform/default.nix @@ -1,7 +1,2 @@ # DO NOT HAND-EDIT THIS FILE -import ((import {}).fetchFromGitHub ( - let json = builtins.fromJSON (builtins.readFile ./github.json); - in { inherit (json) owner repo rev sha256; - private = json.private or false; - } -)) +import (import ./thunk.nix) \ No newline at end of file diff --git a/reflex-platform/github.json b/reflex-platform/github.json index e897d49..8d9fa9b 100644 --- a/reflex-platform/github.json +++ b/reflex-platform/github.json @@ -1,7 +1,8 @@ { "owner": "reflex-frp", "repo": "reflex-platform", - "branch": "aa-bump-reflex-process", - "rev": "22f8ea48c15d2be6af6808826a63c6b03eb672c8", - "sha256": "08i6wvgwcmnlnncq66hjhagk45kyiy5ldi15vfm007fvv1kgnamm" + "branch": "master", + "private": false, + "rev": "c13cb19f49c8093de4718d2aced1930128476cfa", + "sha256": "0v87ilal9355xwz8y9m0zh14pm9c0f7pqch0854kkj92ybc5l62q" } diff --git a/reflex-platform/thunk.nix b/reflex-platform/thunk.nix new file mode 100644 index 0000000..bbf2dc1 --- /dev/null +++ b/reflex-platform/thunk.nix @@ -0,0 +1,9 @@ +# DO NOT HAND-EDIT THIS FILE +let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }: + if !fetchSubmodules && !private then builtins.fetchTarball { + url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256; + } else (import {}).fetchFromGitHub { + inherit owner repo rev sha256 fetchSubmodules private; + }; + json = builtins.fromJSON (builtins.readFile ./github.json); +in fetch json \ No newline at end of file diff --git a/release.nix b/release.nix index 2d3a600..0e25b2a 100644 --- a/release.nix +++ b/release.nix @@ -1,5 +1,31 @@ -{ p ? import ./reflex-platform {} +{ reflex-platform-fun ? import ./reflex-platform }: -let - inherit (p.nixpkgs) lib; -in p.ghc.callPackage ./. {} +(reflex-platform-fun { + haskellOverlaysPost = [ + (self: super: { + reflex = self.callHackageDirect { + pkg = "reflex"; + ver = "0.7.1.0"; + sha256 = "0a933xz7yl931m90bbwi9akfz77q6px36grlx6wba55mn1klpn27"; + } {}; + + reflex-fsnotify = self.callHackageDirect { + pkg = "reflex-fsnotify"; + ver = "0.2.1.1"; + sha256 = "1snbvf8z942fpb0r5spaxcdc036v6b1akgdscpfghz81bdvcxy8i"; + } {}; + + reflex-process = self.callHackageDirect { + pkg = "reflex-process"; + ver = "0.3.0.0"; + sha256 = "0xx8gzs7c60zh8rj794hyisljp0gwb26m34ns8z9xgp1k8jgkdgj"; + } {}; + + reflex-vty = self.callHackageDirect { + pkg = "reflex-vty"; + ver = "0.1.4.0"; + sha256 = "0djs7y4mmkb2q5hvp1fr1gn81k08hzab8v3c6qvh7nyn1fdh8zvh"; + } {}; + }) + ]; +}).ghc.callPackage ./default.nix {} diff --git a/src/Reflex/Process/GHCi.hs b/src/Reflex/Process/GHCi.hs index 4fdc104..01f76c8 100644 --- a/src/Reflex/Process/GHCi.hs +++ b/src/Reflex/Process/GHCi.hs @@ -20,7 +20,7 @@ module Reflex.Process.GHCi import Reflex import Reflex.FSNotify (watchDirectoryTree) -import Reflex.Process (ProcessConfig(..), Process(..), createProcess) +import Reflex.Process (ProcessConfig(..), Process(..), SendPipe(..), createProcess) import Control.Monad ((<=<)) import Control.Monad.Fix (MonadFix) @@ -55,7 +55,7 @@ ghci ghci cmd mexpr reloadReq = do -- Run the process and feed it some input: rec proc <- createProcess cmd $ ProcessConfig - { _processConfig_stdin = leftmost + { _processConfig_stdin = SendPipe_Message . (<> "\n") <$> leftmost [ reload -- Execute some expression if GHCi is ready to receive it , fforMaybe (updated status) $ \case @@ -91,7 +91,7 @@ ghci cmd mexpr reloadReq = do -- Only interrupt when there's a file change and we're ready and not in an idle state let interruptible s = s `elem` [Status_Loading, Status_Executing] - requestInterrupt = gate (interruptible <$> current status) $ (() <$ reloadReq) + requestInterrupt = gate (interruptible <$> current status) (() <$ reloadReq) -- Define some Regex patterns to use to determine GHCi's state based on output let okModulesLoaded = "Ok.*module.*loaded." :: ByteString @@ -114,7 +114,7 @@ ghci cmd mexpr reloadReq = do else Nothing , const Status_Loading <$ reload , ffor (updated output) $ \out -> case reverse (C8.lines out) of - (lastLine:expectedMessage:_) + lastLine:expectedMessage:_ | lastLine == prompt && expectedMessage Regex.=~ okModulesLoaded -> const Status_LoadSucceeded | lastLine == prompt && expectedMessage Regex.=~ failedNoModulesLoaded -> const Status_LoadFailed | lastLine == prompt -> \case @@ -127,7 +127,7 @@ ghci cmd mexpr reloadReq = do Just _ -> Status_Executing s -> s - (lastLine:_) + lastLine:_ | lastLine Regex.=~ ghciVersionMessage -> const Status_Loading _ -> id ] diff --git a/tests/HeadlessHost.hs b/tests/HeadlessHost.hs deleted file mode 100644 index 687ec3f..0000000 --- a/tests/HeadlessHost.hs +++ /dev/null @@ -1,83 +0,0 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE ConstraintKinds #-} -module HeadlessHost where - -import Data.Maybe -import Reflex -import Control.Monad.Fix -import Control.Monad.Primitive -import Reflex.Host.Class -import Control.Monad.IO.Class -import Control.Monad.Ref -import Data.IORef -import Data.Dependent.Sum -import Control.Concurrent.Chan (newChan, readChan) -import Control.Monad (forM, forM_) -import Control.Monad.Identity (Identity(..)) - -type HeadlessResult t = Event t () - -type MonadHeadlessApp t m = - ( Reflex t - , MonadHold t m - , MonadFix m - , PrimMonad (HostFrame t) - , ReflexHost t - , MonadIO (HostFrame t) - , Ref m ~ IORef - , Ref (HostFrame t) ~ IORef - , MonadRef (HostFrame t) - , NotReady t m - , TriggerEvent t m - , PostBuild t m - , PerformEvent t m - , MonadIO m - , MonadIO (Performable m) - , Adjustable t m - ) - -runHeadlessApp - :: (forall t m. MonadHeadlessApp t m => m (HeadlessResult t)) - -> IO () -runHeadlessApp guest = - (runSpiderHost :: SpiderHost Global a -> IO a) $ do - (postBuild, postBuildTriggerRef) <- newEventWithTriggerRef - events <- liftIO newChan - (vtyResult, fc@(FireCommand fire)) <- do - hostPerformEventT $ - flip runPostBuildT postBuild $ - flip runTriggerEventT events $ - guest - mPostBuildTrigger <- readRef postBuildTriggerRef - forM_ mPostBuildTrigger $ \postBuildTrigger -> - fire [postBuildTrigger :=> Identity ()] $ return () - shutdown <- subscribeEvent vtyResult - fix $ \loop -> do - ers <- liftIO $ readChan events - stop <- fireEventTriggerRefs fc ers $ readEvent shutdown >>= \case - Nothing -> return False - Just _ -> return True - if or stop - then return () - else loop - where - -- TODO Some part of this is probably general enough to belong in reflex - -- | Use the given 'FireCommand' to fire events that have subscribers - -- and call the callback for the 'TriggerInvocation' of each. - fireEventTriggerRefs - :: (Monad (ReadPhase m), MonadIO m) - => FireCommand t m - -> [DSum (EventTriggerRef t) TriggerInvocation] - -> ReadPhase m a - -> m [a] - fireEventTriggerRefs (FireCommand fire) ers rcb = do - mes <- liftIO $ - forM ers $ \(EventTriggerRef er :=> TriggerInvocation a _) -> do - me <- readIORef er - return $ fmap (\e -> e :=> Identity a) me - a <- fire (catMaybes mes) rcb - liftIO $ forM_ ers $ \(_ :=> TriggerInvocation _ cb) -> cb - return a diff --git a/tests/exe-pkg/tests.cabal b/tests/exe-pkg/tests.cabal index a9edcfc..c277e79 100644 --- a/tests/exe-pkg/tests.cabal +++ b/tests/exe-pkg/tests.cabal @@ -20,7 +20,7 @@ executable tests main-is: Main.hs -- other-modules: -- other-extensions: - build-depends: base >=4.12 && <4.13 + build-depends: base , reflex-ghci -- hs-source-dirs: default-language: Haskell2010 diff --git a/tests/lib-pkg-err/test-pkg2.cabal b/tests/lib-pkg-err/test-pkg2.cabal index fb0a0a1..2ed7900 100644 --- a/tests/lib-pkg-err/test-pkg2.cabal +++ b/tests/lib-pkg-err/test-pkg2.cabal @@ -23,6 +23,6 @@ library MyLib.Three -- other-modules: -- other-extensions: - build-depends: base >=4.12 && <4.13 + build-depends: base hs-source-dirs: src default-language: Haskell2010 diff --git a/tests/lib-pkg/test-pkg2.cabal b/tests/lib-pkg/test-pkg2.cabal index fb0a0a1..2ed7900 100644 --- a/tests/lib-pkg/test-pkg2.cabal +++ b/tests/lib-pkg/test-pkg2.cabal @@ -23,6 +23,6 @@ library MyLib.Three -- other-modules: -- other-extensions: - build-depends: base >=4.12 && <4.13 + build-depends: base hs-source-dirs: src default-language: Haskell2010 diff --git a/tests/test.hs b/tests/test.hs index 2a593c5..526addd 100644 --- a/tests/test.hs +++ b/tests/test.hs @@ -2,9 +2,9 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TemplateHaskell #-} -import HeadlessHost + import Reflex +import Reflex.Host.Headless import Reflex.Process.GHCi import Reflex.Vty import Reflex.Vty.GHCi @@ -188,13 +188,14 @@ watchAndReloadTest = withSystemTempDirectory "reflex-ghci-test" $ \p -> do let loadFailed = fforMaybe (updated $ _ghci_status g) $ \case Status_LoadFailed -> Just () _ -> Nothing - numFailures :: Dynamic t Int <- count loadFailed - performEvent_ $ ffor loadFailed $ \_ -> liftIO $ do + + loadFailedDelayed <- delay 1 loadFailed -- If we respond too quickly, fsnotify won't deliver the change. + performEvent_ $ ffor loadFailedDelayed $ \_ -> liftIO $ do putStrLn "copying fixed file" - P.callProcess "cp" - [ src <> "/tests/lib-pkg/src/MyLib/Three.hs" - , p <> "/lib-pkg-err/src/MyLib/Three.hs" - ] + copyFile (src <> "/tests/lib-pkg/src/MyLib/Three.hs") + (p <> "/lib-pkg-err/src/MyLib/Three.hs") + + numFailures :: Dynamic t Int <- count loadFailed let loadSucceeded = fforMaybe (updated $ _ghci_status g) $ \case Status_LoadSucceeded -> Just () _ -> Nothing @@ -202,7 +203,7 @@ watchAndReloadTest = withSystemTempDirectory "reflex-ghci-test" $ \p -> do if x > 1 then Just $ error "Too many failures." else Nothing - return loadSucceeded + return $ gate ((>= 1) <$> current numFailures) loadSucceeded testModuleLoadFailed :: ( MonadIO m