Skip to content

Commit 0f38c91

Browse files
authored
Fix broken test command on older purs versions (#790)
1 parent 4e6968b commit 0f38c91

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.20.2] - 2021-05-06
11+
1012
Bugfixes:
11-
- Remove npm install from release.yml to prevent overwriting the spago file
12-
with the Linux binary (#783, #786)
13+
- Remove `npm install` from release CI to prevent overwriting the install script with the Linux binary (#783, #786)
1314
- Use spago.cabal instead of package.yaml to get version number (#787, #788)
15+
- Assume compatibility with newer minor versions of `purs` (#782, #777)
16+
- Fix `test` command not working on `purs` older than `v0.14.0` (#790, #789)
17+
18+
Other improvements:
19+
- Docs: add more useful comments in spago.dhall (#778, 708)
20+
- Dev: remove package.yaml, use only cabal file (#780)
21+
- Dev: use make to orchestrate builds (#781)
22+
- Deps: upgrade to GHC8.10 and lts-17 (#743)
1423

1524
## [0.20.1] - 2021-04-20
1625

spago.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 2.4
22

33
name: spago
4-
version: 0.20.1
4+
version: 0.20.2
55
description: Please see the README on GitHub at <https://github.com/purescript/spago#readme>
66
homepage: https://github.com/purescript/spago#readme
77
bug-reports: https://github.com/purescript/spago/issues

src/Spago/Build.hs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,18 @@ repl newPackages sourcePaths pursArgs depsOnly = do
242242
-- (or the provided module name) with node
243243
test :: HasBuildEnv env => Maybe ModuleName -> [BackendArg] -> RIO env ()
244244
test maybeModuleName extraArgs = do
245+
logDebug "Running `Spago.Build.test`"
245246
let moduleName = fromMaybe (ModuleName "Test.Main") maybeModuleName
246247
Config.Config { alternateBackend } <- view (the @Config)
247-
maybeGraph <- view (the @Graph)
248+
248249
-- We check if the test module is included in the build and spit out a nice error if it isn't (see #383)
249-
for_ maybeGraph $ \(ModuleGraph moduleMap) -> case Map.lookup moduleName moduleMap of
250-
Nothing -> die [ "Module '" <> (display . unModuleName) moduleName <> "' not found! Are you including it in your build?" ]
251-
Just _ -> do
252-
sourceDir <- Turtle.pwd
253-
let dirs = RunDirectories sourceDir sourceDir
254-
runBackend alternateBackend dirs moduleName (Just "Tests succeeded.") "Tests failed: " extraArgs
250+
maybeGraph <- view (the @Graph)
251+
for_ maybeGraph $ \(ModuleGraph moduleMap) -> when (isNothing $ Map.lookup moduleName moduleMap) $
252+
die [ "Module '" <> (display . unModuleName) moduleName <> "' not found! Are you including it in your build?" ]
253+
254+
sourceDir <- Turtle.pwd
255+
let dirs = RunDirectories sourceDir sourceDir
256+
runBackend alternateBackend dirs moduleName (Just "Tests succeeded.") "Tests failed: " extraArgs
255257

256258

257259
-- | Run the project: compile and run "Main"

src/Spago/RunEnv.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,15 @@ withBuildEnv'
135135
withBuildEnv' maybeConfig usePsa envBuildOptions@BuildOptions{ noInstall } app = do
136136
Env{..} <- getEnv
137137
envPursCmd <- getPurs usePsa
138-
envConfig@Config{..} <- case maybeConfig of
139-
Nothing -> getConfig
140-
Just c -> pure c
138+
envConfig@Config{..} <- maybe getConfig pure maybeConfig
141139
let envPackageSet = packageSet
142140
deps <- runRIO InstallEnv{..} $ do
143141
deps <- Packages.getProjectDeps
144142
when (noInstall == DoInstall) $ FetchPackage.fetchPackages deps
145143
pure deps
146144
envGraph <- runRIO PursEnv{..} (getMaybeGraph envBuildOptions envConfig deps)
147145
envGitCmd <- getGit
146+
logDebug "Running in `BuildEnv`"
148147
runRIO BuildEnv{..} app
149148

150149
withBuildEnv
@@ -205,6 +204,7 @@ getPackageSet = do
205204

206205
getMaybeGraph :: HasPursEnv env => BuildOptions -> Config -> [(PackageName, Package)] -> RIO env Graph
207206
getMaybeGraph BuildOptions{ depsOnly, sourcePaths } Config{ configSourcePaths } deps = do
207+
logDebug "Running `getMaybeGraph`"
208208
let partitionedGlobs = Packages.getGlobs deps depsOnly configSourcePaths
209209
globs = Packages.getGlobsSourcePaths partitionedGlobs <> sourcePaths
210210
supportsGraph <- Purs.hasMinPursVersion "0.14.0"

0 commit comments

Comments
 (0)