From 0f38c9153e46f30e9d87963e181f5c1a595f4b64 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrai Date: Thu, 6 May 2021 21:41:45 +0300 Subject: [PATCH] Fix broken test command on older purs versions (#790) --- CHANGELOG.md | 13 +++++++++++-- spago.cabal | 2 +- src/Spago/Build.hs | 16 +++++++++------- src/Spago/RunEnv.hs | 6 +++--- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f60b0a85..bdcafb945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.20.2] - 2021-05-06 + Bugfixes: -- Remove npm install from release.yml to prevent overwriting the spago file - with the Linux binary (#783, #786) +- Remove `npm install` from release CI to prevent overwriting the install script with the Linux binary (#783, #786) - Use spago.cabal instead of package.yaml to get version number (#787, #788) +- Assume compatibility with newer minor versions of `purs` (#782, #777) +- Fix `test` command not working on `purs` older than `v0.14.0` (#790, #789) + +Other improvements: +- Docs: add more useful comments in spago.dhall (#778, 708) +- Dev: remove package.yaml, use only cabal file (#780) +- Dev: use make to orchestrate builds (#781) +- Deps: upgrade to GHC8.10 and lts-17 (#743) ## [0.20.1] - 2021-04-20 diff --git a/spago.cabal b/spago.cabal index adad45d69..2bb423851 100644 --- a/spago.cabal +++ b/spago.cabal @@ -1,7 +1,7 @@ cabal-version: 2.4 name: spago -version: 0.20.1 +version: 0.20.2 description: Please see the README on GitHub at homepage: https://github.com/purescript/spago#readme bug-reports: https://github.com/purescript/spago/issues diff --git a/src/Spago/Build.hs b/src/Spago/Build.hs index 17d978f00..70fb54ca8 100644 --- a/src/Spago/Build.hs +++ b/src/Spago/Build.hs @@ -242,16 +242,18 @@ repl newPackages sourcePaths pursArgs depsOnly = do -- (or the provided module name) with node test :: HasBuildEnv env => Maybe ModuleName -> [BackendArg] -> RIO env () test maybeModuleName extraArgs = do + logDebug "Running `Spago.Build.test`" let moduleName = fromMaybe (ModuleName "Test.Main") maybeModuleName Config.Config { alternateBackend } <- view (the @Config) - maybeGraph <- view (the @Graph) + -- We check if the test module is included in the build and spit out a nice error if it isn't (see #383) - for_ maybeGraph $ \(ModuleGraph moduleMap) -> case Map.lookup moduleName moduleMap of - Nothing -> die [ "Module '" <> (display . unModuleName) moduleName <> "' not found! Are you including it in your build?" ] - Just _ -> do - sourceDir <- Turtle.pwd - let dirs = RunDirectories sourceDir sourceDir - runBackend alternateBackend dirs moduleName (Just "Tests succeeded.") "Tests failed: " extraArgs + maybeGraph <- view (the @Graph) + for_ maybeGraph $ \(ModuleGraph moduleMap) -> when (isNothing $ Map.lookup moduleName moduleMap) $ + die [ "Module '" <> (display . unModuleName) moduleName <> "' not found! Are you including it in your build?" ] + + sourceDir <- Turtle.pwd + let dirs = RunDirectories sourceDir sourceDir + runBackend alternateBackend dirs moduleName (Just "Tests succeeded.") "Tests failed: " extraArgs -- | Run the project: compile and run "Main" diff --git a/src/Spago/RunEnv.hs b/src/Spago/RunEnv.hs index 3332defae..b41d68082 100644 --- a/src/Spago/RunEnv.hs +++ b/src/Spago/RunEnv.hs @@ -135,9 +135,7 @@ withBuildEnv' withBuildEnv' maybeConfig usePsa envBuildOptions@BuildOptions{ noInstall } app = do Env{..} <- getEnv envPursCmd <- getPurs usePsa - envConfig@Config{..} <- case maybeConfig of - Nothing -> getConfig - Just c -> pure c + envConfig@Config{..} <- maybe getConfig pure maybeConfig let envPackageSet = packageSet deps <- runRIO InstallEnv{..} $ do deps <- Packages.getProjectDeps @@ -145,6 +143,7 @@ withBuildEnv' maybeConfig usePsa envBuildOptions@BuildOptions{ noInstall } app = pure deps envGraph <- runRIO PursEnv{..} (getMaybeGraph envBuildOptions envConfig deps) envGitCmd <- getGit + logDebug "Running in `BuildEnv`" runRIO BuildEnv{..} app withBuildEnv @@ -205,6 +204,7 @@ getPackageSet = do getMaybeGraph :: HasPursEnv env => BuildOptions -> Config -> [(PackageName, Package)] -> RIO env Graph getMaybeGraph BuildOptions{ depsOnly, sourcePaths } Config{ configSourcePaths } deps = do + logDebug "Running `getMaybeGraph`" let partitionedGlobs = Packages.getGlobs deps depsOnly configSourcePaths globs = Packages.getGlobsSourcePaths partitionedGlobs <> sourcePaths supportsGraph <- Purs.hasMinPursVersion "0.14.0"