mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-31 17:17:26 +00:00
* Fix dev exit code #7767 * fix nix+clippy
This commit is contained in:
parent
be25f88aea
commit
e89bb6eb50
4 changed files with 34 additions and 30 deletions
|
@ -1398,35 +1398,37 @@ fn roc_dev_native(
|
|||
signal_hook::flag::register(signal_hook::consts::SIGCHLD, Arc::clone(&sigchld))
|
||||
.unwrap();
|
||||
|
||||
let exit_code = loop {
|
||||
match memory.wait_for_child(sigchld.clone()) {
|
||||
ChildProcessMsg::Terminate => {
|
||||
let mut status = 0;
|
||||
let options = 0;
|
||||
unsafe { libc::waitpid(pid, &mut status, options) };
|
||||
let exit_code = match memory.wait_for_child(sigchld.clone()) {
|
||||
ChildProcessMsg::Terminate => {
|
||||
let mut status = 0;
|
||||
let options = 0;
|
||||
unsafe { libc::waitpid(pid, &mut status, options) };
|
||||
|
||||
// if `WIFEXITED` returns false, `WEXITSTATUS` will just return junk
|
||||
break if libc::WIFEXITED(status) {
|
||||
libc::WEXITSTATUS(status)
|
||||
} else {
|
||||
// we don't have an exit code, but something went wrong if we're in this else
|
||||
1
|
||||
};
|
||||
// if `WIFEXITED` returns false, `WEXITSTATUS` will just return junk
|
||||
if libc::WIFEXITED(status) {
|
||||
libc::WEXITSTATUS(status)
|
||||
} else {
|
||||
// we don't have an exit code, but something went wrong if we're in this else
|
||||
1
|
||||
}
|
||||
ChildProcessMsg::Expect => {
|
||||
let mut writer = std::io::stdout();
|
||||
roc_repl_expect::run::render_expects_in_memory(
|
||||
&mut writer,
|
||||
arena,
|
||||
&mut expectations,
|
||||
&interns,
|
||||
&layout_interner,
|
||||
&memory,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
ChildProcessMsg::Expect => {
|
||||
let mut writer = std::io::stdout();
|
||||
roc_repl_expect::run::render_expects_in_memory(
|
||||
&mut writer,
|
||||
arena,
|
||||
&mut expectations,
|
||||
&interns,
|
||||
&layout_interner,
|
||||
&memory,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
memory.reset();
|
||||
}
|
||||
memory.reset();
|
||||
|
||||
// If we're in this block that means an expect failed while using the dev(default) command.
|
||||
// So we should exit with a non-zero exit code.
|
||||
1
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -777,8 +777,8 @@ mod cli_tests {
|
|||
);
|
||||
|
||||
let cli_dev_out = cli_dev.run();
|
||||
// TODO enable or delete this based on https://roc.zulipchat.com/#narrow/channel/304641-ideas/topic/roc.20dev.20expect.20failure/near/477682063
|
||||
//cli_dev_out.assert_nonzero_exit();
|
||||
|
||||
cli_dev_out.assert_nonzero_exit();
|
||||
|
||||
insta::assert_snapshot!(cli_dev_out.normalize_stdout_and_stderr());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ poly_dbg = \x ->
|
|||
main =
|
||||
str = "this will for sure be a large string so when we split it it will use seamless slices which affect printing"
|
||||
words = Str.split_on(str, " ")
|
||||
|
||||
# we expect this to fail
|
||||
expect words == []
|
||||
|
||||
x = 42
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue