question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

proposal: output proper exit codes

See original GitHub issue

I like how fast and light zora is, would it be possible for it to output proper exit codes? Or is that job of at the test-runner?

  1. test case:
// wat.js
const test = require('zora')

test('what', t => {
    t.ok(false)
})
  1. what I think should happen
$ node wat.js
$ echo $status
1
  1. what is happening instead:
$ node wat.js
$ echo $status
0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:25 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
lorenzofox3commented, Jul 29, 2018

@lorenzofox3 possible suggestion, what if we use a flag to tell it’s running against node, and that way you can output the correct exit code, eliminating the need to pipe anything just for exit code in CI (less deps).

Something like this: node test-file.js --node

The problem whether you read it from a flag or not is that at some point we would need in zora something like

if(typeof process !== 'undefined'){
   const code = failing ? 1 : 0;
   process.exit(code);
}

My experience has taught me this can be problematic for module bundlers for example: when they parse that branch they must understand this branch is only relevant for a given environment. It is even more troublesome as process is a native module and they might need to provide a shim for browsers, etc.

I am not saying that is not doable but it is quite a lot of trouble compared to adding a development dependency

That or just update the README and tell people it’s not giving proper exit codes. People like @TehShrike had already adopted zora on a number of his repos, only to find out it was giving him false positive because CI sees it’s always returning zero exit code.

I agree although most of the time as you run your tests locally first you should have few false positives and update your ci setup little by little as you update the code in your repos

I should definitely update the Readme though. Thanks for the advice

1reaction
TehShrikecommented, Mar 3, 2020

tap-exit-code@2 and tap-color@1.2 are both patched to set the correct status code on bail out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[proposal] Capturing step exit codes in Tasks #2800
the exit code becomes available as a result to following tasks and conditions, allowing for branching based on the result, using conditions as ......
Read more >
Exit codes in C/C++ with Examples
Exit codes other than “0”(or EXIT_FAILURE) indicate the presence of an error in the code. Among all the exit codes, the codes 1,...
Read more >
Exit Codes From Main - Pitches
I'd like to pitch extending the MainType main function to return an exit code. Returning a non-zero/non-one exit-code from Swift in a ...
Read more >
Make it possible to control build status using exit codes - GitLab
I would be interested in this feature for my monorepo. Perhaps this proposal presents too much flexibility on which exit code accept as...
Read more >
Linux and Unix exit code tutorial with examples
Tutorial on using exit codes from Linux or UNIX commands. Examples of how to get the exit code of a command, how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found