Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of user interrupts (fixes #299) #349

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.cabal linguist-generated
/examples/init/foo.cabal -linguist-generated
soenkehahn marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
packages: garn.cabal
tests: True
soenkehahn marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion src/Garn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ runWith env (WithGarnTsOpts garnConfig opts) = do
case opts of
Gen -> pure ()
Run (CommandOptions {..}) argv -> do
callProcess "nix" $ ["run"] <> nixArgs <> [".#" <> asNixFacing target, "--"] <> argv
exitCode <- rawSystem "nix" (["run"] <> nixArgs <> [".#" <> asNixFacing target, "--"] <> argv)
exitWith exitCode
Enter (CommandOptions {..}) -> do
hPutStrLn stderr $
"[garn] Entering "
Expand Down
14 changes: 14 additions & 0 deletions test/spec/RunSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ spec =
onTestFailureLog output
stdout output `shouldBe` "foobarbaz\n"
exitCode output `shouldBe` ExitSuccess

it "propagates the exit status of the child process" $ \onTestFailureLog -> 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
onTestFailureLog output
stdout output `shouldBe` ""
exitCode output `shouldBe` ExitFailure 23

it "runs executables within an environment" $ \onTestFailureLog -> do
writeFile
"garn.ts"
Expand Down