-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shell: add 'exit' builtin command (#9705)
* shell: add 'exit' builtin command * remove loop here * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jarred Sumner <[email protected]>
- Loading branch information
1 parent
7172013
commit b8389f3
Showing
2 changed files
with
116 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { $ } from "bun"; | ||
import { describe, test, expect } from "bun:test"; | ||
import { TestBuilder } from "../test_builder"; | ||
import { sortedShellOutput } from "../util"; | ||
import { join } from "path"; | ||
|
||
describe("exit", async () => { | ||
TestBuilder.command`exit`.exitCode(0).runAsTest("works"); | ||
|
||
describe("argument sets exit code", async () => { | ||
for (const arg of [0, 2, 11]) { | ||
TestBuilder.command`exit ${arg}`.exitCode(arg).runAsTest(`${arg}`); | ||
} | ||
}); | ||
|
||
TestBuilder.command`exit 3 5`.exitCode(1).stderr("exit: too many arguments").runAsTest("too many arguments"); | ||
|
||
TestBuilder.command`exit 62757836`.exitCode(204).runAsTest("exit code wraps u8"); | ||
|
||
// prettier-ignore | ||
TestBuilder.command`exit abc`.exitCode(1).stderr("exit: numeric argument required").runAsTest("numeric argument required"); | ||
}); |