Skip to content

Commit

Permalink
Fix broken test command on older purs versions (#790)
Browse files Browse the repository at this point in the history
  • Loading branch information
f-f authored May 6, 2021
1 parent 4e6968b commit 0f38c91
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spago.cabal
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/purescript/spago#readme>
homepage: https://github.com/purescript/spago#readme
bug-reports: https://github.com/purescript/spago/issues
Expand Down
16 changes: 9 additions & 7 deletions src/Spago/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/Spago/RunEnv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,15 @@ 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
when (noInstall == DoInstall) $ FetchPackage.fetchPackages deps
pure deps
envGraph <- runRIO PursEnv{..} (getMaybeGraph envBuildOptions envConfig deps)
envGitCmd <- getGit
logDebug "Running in `BuildEnv`"
runRIO BuildEnv{..} app

withBuildEnv
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 0f38c91

Please sign in to comment.