Skip to content

Commit

Permalink
Make workspace output dir absolute path (#1119)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Fabrizio Ferrai <fabrizio.ferrai@gmail.com>
  • Loading branch information
JordanMartinez and f-f authored Nov 18, 2023
1 parent 47b735c commit 6d5929a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion bin/src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,6 @@ mkRunEnv runArgs { dependencies, purs } = do
runOptions =
{ moduleName
, execArgs
, sourceDir: Paths.cwd
, executeDir: Paths.cwd
, successMessage: Nothing
, failureMessage: "Running failed."
Expand Down
6 changes: 2 additions & 4 deletions src/Spago/Command/Run.purs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type RunEnv a =
type RunOptions =
{ execArgs :: Array String
, moduleName :: String
, sourceDir :: FilePath
, executeDir :: FilePath
, successMessage :: Maybe String
, failureMessage :: String
Expand Down Expand Up @@ -75,6 +74,7 @@ run = do
logDebug "Running with backend: nodejs"
let runDir = Path.concat [ Paths.localCachePath, "run" ]
FS.mkdirp runDir
absOutput <- liftEffect $ Path.resolve [] $ fromMaybe "output" workspace.buildOptions.output
let
runJsPath = Path.concat [ runDir, "run.js" ]
packageJsonPath = Path.concat [ runDir, "package.json" ]
Expand All @@ -85,9 +85,7 @@ run = do
nodeContents =
Array.fold
[ "import { main } from 'file://"
, withForwardSlashes opts.sourceDir
, "/"
, fromMaybe "output" workspace.buildOptions.output
, withForwardSlashes absOutput
, "/"
, opts.moduleName
, "/"
Expand Down
1 change: 0 additions & 1 deletion src/Spago/Command/Test.purs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ run = do
{ successMessage: Just $ "Test succeeded for package \"" <> PackageName.print name <> "\"."
, failureMessage: "Tests failed for package \"" <> PackageName.print name <> "\"."
, executeDir: Paths.cwd
, sourceDir: Paths.cwd
, execArgs
, moduleName
}
Expand Down
8 changes: 8 additions & 0 deletions test/Spago/Test.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Spago.Command.Init (DefaultConfigOptions(..))
import Spago.Command.Init as Init
import Spago.Core.Config as Config
import Spago.FS as FS
import Spago.Paths (paths)
import Test.Spec (Spec)
import Test.Spec as Spec
import Test.Spec.Assertions as Assert
Expand All @@ -25,6 +26,13 @@ spec = Spec.around withTempDir do
spago [ "build" ] >>= shouldBeSuccess
spago [ "test" ] >>= shouldBeSuccessOutputWithErr (fixture "test-output-stdout.txt") (fixture "test-output-stderr.txt")

Spec.it "tests successfully when using a different output dir" \{ spago, fixture } -> do
spago [ "init", "--name", "7368613235362d6a336156536c675a7033334e7659556c6d38" ] >>= shouldBeSuccess

let tempDir = Path.concat [ paths.temp, "output" ]
spago [ "build", "--output", tempDir ] >>= shouldBeSuccess
spago [ "test", "--output", tempDir ] >>= shouldBeSuccessOutputWithErr (fixture "test-output-stdout.txt") (fixture "test-output-stderr.txt")

Spec.it "fails nicely when the test module is not found" \{ spago, fixture } -> do
spago [ "init", "--name", "7368613235362d6a336156536c675a7033334e7659556c6d38" ] >>= shouldBeSuccess
spago [ "build" ] >>= shouldBeSuccess
Expand Down

0 comments on commit 6d5929a

Please sign in to comment.