diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..96d94205 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.cabal linguist-generated +/examples/init/foo.cabal -linguist-generated diff --git a/cabal.project b/cabal.project index f251078a..9754c17e 100644 --- a/cabal.project +++ b/cabal.project @@ -1 +1,2 @@ packages: garn.cabal +tests: True diff --git a/src/Garn.hs b/src/Garn.hs index 8e9dc61f..4e506dd5 100644 --- a/src/Garn.hs +++ b/src/Garn.hs @@ -6,7 +6,7 @@ module Garn ) where -import Control.Exception (catch) +import Control.Exception (catch, throwIO) import Control.Monad (forM_, when) import Development.Shake (Exit (Exit), cmd) import Garn.Common (currentSystem, nixArgs) @@ -48,7 +48,7 @@ runWith env (WithGarnTsOpts garnConfig opts) = do case opts of Gen -> pure () Run (CommandOptions {..}) argv -> do - callProcess "nix" $ ["run"] <> nixArgs <> [".#" <> asNixFacing target, "--"] <> argv + rawSystem "nix" (["run"] <> nixArgs <> [".#" <> asNixFacing target, "--"] <> argv) >>= throwIO Enter (CommandOptions {..}) -> do hPutStrLn stderr $ "[garn] Entering " diff --git a/test/spec/RunSpec.hs b/test/spec/RunSpec.hs index 2b2d1b40..8ef2dfbe 100644 --- a/test/spec/RunSpec.hs +++ b/test/spec/RunSpec.hs @@ -45,6 +45,19 @@ spec = output <- runGarn ["run", "main"] "" repoDir Nothing stdout output `shouldBe` "foobarbaz\n" exitCode output `shouldBe` ExitSuccess + + it "propagates the exit status of the child process" $ do + writeFile + "garn.ts" + [i| + import * as garn from "#{repoDir}/ts/mod.ts" + + export const main = garn.shell`exit 23`; + |] + output <- runGarn ["run", "main"] "" repoDir Nothing + stdout output `shouldBe` "" + exitCode output `shouldBe` ExitFailure 23 + it "runs executables within an environment" $ do writeFile "garn.ts"