diff --git a/.travis.yml b/.travis.yml index 2ff783a88..6629568e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,7 +92,7 @@ script: 'cd spago && stack build --test --no-run-tests --copy-bins --local-bin-path ./artifacts' fi nvm install 10 && nvm use 10 - npm install -g psc-package@3.0.1 bower@1.8.8 purescript-psa + npm install -g psc-package@3.0.1 bower@1.8.8 # get newest purescript from github releases TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') @@ -104,6 +104,10 @@ script: # run the test suite executable ./.stack-work/dist/*/*/build/spec/spec + + # install psa and rerun tests that exercise it + npm install -g purescript-psa + ./.stack-work/dist/*/*/build/spec/spec --match "/Spago/spago run" before_deploy: diff --git a/appveyor.yml b/appveyor.yml index 3e61f90ce..bed65706d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,7 +20,7 @@ install: - choco install -y haskell-stack --version %STACK_VERSION% - stack setup > nul - choco install psc-package - - npm install -g bower purescript-psa + - npm install -g bower - ps: | $releases = "https://api.github.com/repos/purescript/purescript/releases" $tag = "v0.13.2" @@ -43,6 +43,9 @@ test_script: - set PATH=C:\projects\spago\bin;C:\projects\spago\purescript;%PATH% - set XDG_CACHE_HOME=C:\cache - stack test + # We install psa and rerun the tests that exercise it + - npm install -g purescript-psa + - stack test --ta "--match \"/Spago/spago run\"" artifacts: - path: windows.tar.gz diff --git a/src/Spago/Prelude.hs b/src/Spago/Prelude.hs index 18c60aa98..ecc4d6352 100644 --- a/src/Spago/Prelude.hs +++ b/src/Spago/Prelude.hs @@ -57,6 +57,7 @@ module Spago.Prelude , callCommand , shell , shellStrict + , shellStrictWithErr , systemStrictWithErr , viewShell , repr @@ -105,7 +106,8 @@ import System.FilePath (isAbsolute, pathSeparator, () import System.IO (hPutStrLn) import Turtle (ExitCode (..), FilePath, appendonly, chmod, executable, mktree, repr, shell, shellStrict, - systemStrictWithErr, testdir, testfile) + shellStrictWithErr, systemStrictWithErr, testdir, + testfile) import UnliftIO (MonadUnliftIO, withRunInIO) import UnliftIO.Directory (getModificationTime, makeAbsolute) import UnliftIO.Exception (IOException, handleAny, try, tryIO) diff --git a/src/Spago/Purs.hs b/src/Spago/Purs.hs index 6052c6d30..262b3575d 100644 --- a/src/Spago/Purs.hs +++ b/src/Spago/Purs.hs @@ -37,9 +37,9 @@ compile sourcePaths extraArgs = do usePsa <- asks globalUsePsa purs <- case usePsa of NoPsa -> pure "purs" - UsePsa -> tryIO psaVersion >>= \case + UsePsa -> try psaVersion >>= \case Right _ -> pure "psa" - Left _ -> pure "purs" + Left (_err :: SomeException) -> pure "purs" echoDebug $ "Compiling with " <> Messages.surroundQuote purs @@ -115,8 +115,8 @@ psaVersion = versionImpl "psa" versionImpl :: Spago m => Text -> m (Maybe Version.SemVer) versionImpl purs = do - fullVersionText <- shellStrict (purs <> " --version") empty >>= \case - (ExitSuccess, out) -> pure out + fullVersionText <- shellStrictWithErr (purs <> " --version") empty >>= \case + (ExitSuccess, out, _err) -> pure out _ -> die $ "Failed to run '" <> purs <> " --version'" versionText <- pure $ headMay $ Text.split (== ' ') fullVersionText parsed <- pure $ versionText >>= (hush . Version.semver) diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 000000000..a7340f5e5 --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,96 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: +- completed: + hackage: dhall-1.23.0@sha256:12a699b7ed30ee40b1a3e05dfd3eef1b053914a5aebeb2f76cc568306570e51b,30737 + pantry-tree: + size: 127759 + sha256: d5c6ff3a3628ac42975364405f9c0dfac4ad0286667e2535839b4806e5438109 + original: + hackage: dhall-1.23.0 +- completed: + hackage: dhall-json-1.2.8@sha256:e098f4f7891ea9ab2ac38c126614e07c821166dea47f10d876eaeda0ad5ceb11,3722 + pantry-tree: + size: 632 + sha256: c73951ed3564a1650d11d282c21cb284c884ff5524349f0d67298af7ea6ea90c + original: + hackage: dhall-json-1.2.8 +- completed: + hackage: async-pool-0.9.0.2@sha256:3aca5861a7b839d02a3f5c52ad6d1ce368631003f68c3d9cb6d711c29e9618db,1599 + pantry-tree: + size: 443 + sha256: 6e97326dc06f9c32fbe7b312e17c427a716a9c2688529ab356de61b0effdb684 + original: + hackage: async-pool-0.9.0.2 +- completed: + hackage: cborg-json-0.2.1.0@sha256:af9137557002ca5308fe80570a9a29398dfb9708423870875223796760689ac3,1268 + pantry-tree: + size: 274 + sha256: fa0ca2dc2d6cdab48e5ef74ffe248670045fca98339d939e47215a5c3ebe47c0 + original: + hackage: cborg-json-0.2.1.0@sha256:af9137557002ca5308fe80570a9a29398dfb9708423870875223796760689ac3 +- completed: + hackage: versions-3.5.0@sha256:4eacd2eb31d6048b87ce3aa2c5cce98b79ac603cfd0e9c52706fcdb68625eb8d,2550 + pantry-tree: + size: 319 + sha256: 95f204e361a7fb2d943ca580ba60eda9cfb989ca7a9420bf56e7904cbbc9b5a6 + original: + hackage: versions-3.5.0 +- completed: + hackage: dotgen-0.4.2@sha256:309b7cc8a3593a8e48bee7b53020d5f72db156d58edf78a0214f58fbb84b292b,1402 + pantry-tree: + size: 357 + sha256: d03f332855d4d9b02e96931596e358202bd18032c323fb1abd8fe84299d259cd + original: + hackage: dotgen-0.4.2 +- completed: + hackage: megaparsec-7.0.3@sha256:2dd155e03b373ebf082bfea1dcc805a7ec1921b4fb3909c47dee4ab8a3aaf68a,6202 + pantry-tree: + size: 2647 + sha256: 730ec04d25a37b28e19568730d4dda75cd44c7fe9f408316c3117c0a38453763 + original: + hackage: megaparsec-7.0.3 +- completed: + hackage: repline-0.2.1.0@sha256:0f8e92d78e771afb9d41243c2b6ab9609fe02f94e676fae3caed66fa4ce09b18,1187 + pantry-tree: + size: 323 + sha256: f48833fb8a89fc4ede1b254bdfbc8937d82e694eb05bf936bf89293bab691700 + original: + hackage: repline-0.2.1.0 +- completed: + hackage: serialise-0.2.1.0@sha256:8d6051f64c6ebfaf705195dd0b8dfb667617f2e674b290ed2e44985009e4f951,8242 + pantry-tree: + size: 4056 + sha256: 26f4c5d503a78001152b73868bd66c5b3479d9b62bb0134c6557815ced34402a + original: + hackage: serialise-0.2.1.0 +- completed: + hackage: Win32-2.5.4.1@sha256:e623a1058bd8134ec14d62759f76cac52eee3576711cb2c4981f398f1ec44b85,3970 + pantry-tree: + size: 5866 + sha256: 34a2d4724363d2f509aba87672b87a24a5246737421ba904d242b1766c6df080 + original: + hackage: Win32-2.5.4.1@sha256:e623a1058bd8134ec14d62759f76cac52eee3576711cb2c4981f398f1ec44b85 +- completed: + hackage: Glob-0.10.0@sha256:bbccaf21bff9071dcf369f55cc1a07250bdc84c432bdf4277ed53e5e2327cd7d,2947 + pantry-tree: + size: 1432 + sha256: 2b14578b5cf51af20efeaf332a1e1ea0c9c24fe2fcb2afba64f77d9249395844 + original: + hackage: Glob-0.10.0 +- completed: + hackage: turtle-1.5.14@sha256:be0f9d3102e11458554d17f581a69984e511f15d6d51a4c4816743783576b566,4908 + pantry-tree: + size: 1114 + sha256: 191eed87a5e8713a212ddfe4c5f4b819d07771c56becd92b8b5c6119f7ddad5d + original: + hackage: turtle-1.5.14 +snapshots: +- completed: + size: 508406 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/12/21.yaml + sha256: 609dd00c32f59e11bb333b9113d9d2e54269627de1268cbb3cc576af8c7b6237 + original: lts-12.21 diff --git a/test/SpagoSpec.hs b/test/SpagoSpec.hs index a783bf84a..cbe0ce3fb 100644 --- a/test/SpagoSpec.hs +++ b/test/SpagoSpec.hs @@ -6,8 +6,8 @@ import qualified Data.Text as Text import Prelude hiding (FilePath) import qualified System.IO.Temp as Temp import Test.Hspec (Spec, around_, describe, it, shouldBe) -import Turtle (cd, cp, decodeString, fromText, mkdir, mktree, mv, - readTextFile, rm, testdir, writeTextFile) +import Turtle (ExitCode (..), cd, cp, decodeString, fromText, mkdir, mktree, + mv, readTextFile, rm, testdir, writeTextFile, shell, empty) import Utils (checkFixture, readFixture, runFor, shouldBeFailure, shouldBeFailureOutput, shouldBeSuccess, shouldBeSuccessOutput, spago, withCwd) @@ -226,7 +226,10 @@ spec = around_ setup $ do -- Note: apparently purs starts caching the compiled modules only after three builds spago ["build"] >>= shouldBeSuccess spago ["build"] >>= shouldBeSuccess - spago ["-v", "run"] >>= shouldBeSuccessOutput "run-output.txt" + + shell "psa --version" empty >>= \case + ExitSuccess -> spago ["-v", "run"] >>= shouldBeSuccessOutput "run-output.txt" + ExitFailure _ -> spago ["-v", "run"] >>= shouldBeSuccessOutput "run-output-psa-not-installed.txt" it "Spago should be able to not use `psa`" $ do diff --git a/test/fixtures/run-output-psa-not-installed.txt b/test/fixtures/run-output-psa-not-installed.txt new file mode 100644 index 000000000..76315e22d --- /dev/null +++ b/test/fixtures/run-output-psa-not-installed.txt @@ -0,0 +1,13 @@ +🍝 +Running NodeJS +Running `spago build` +Ensuring that the package set is frozen +Getting transitive deps +Running `fetchPackages` +Checking if `purs` is up to date +Running `getGlobalCacheDir` +Installation complete. +Compiling with "purs" +Running command: `purs compile ".spago/console/v4.2.0/src/**/*.purs" ".spago/effect/v2.0.1/src/**/*.purs" ".spago/prelude/v4.1.1/src/**/*.purs" ".spago/psci-support/v4.0.0/src/**/*.purs" "src/**/*.purs" "test/**/*.purs"` +Build succeeded. +Writing .spago/run.js