-
Notifications
You must be signed in to change notification settings - Fork 738
fix: silent does not always work (fixes #851) #861
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,20 @@ import test from 'ava'; | |
|
||
import shell from '..'; | ||
import utils from './utils/utils'; | ||
import mocks from './utils/mocks'; | ||
|
||
const CWD = process.cwd(); | ||
const ORIG_EXEC_PATH = shell.config.execPath; | ||
shell.config.silent = true; | ||
|
||
test.beforeEach(() => { | ||
mocks.init(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is OK as written. This actually exposes a bug (#862), which I will handle. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI fix is uploaded (#863). It's OK if this PR lands first. |
||
}); | ||
|
||
test.afterEach.always(() => { | ||
process.chdir(CWD); | ||
shell.config.execPath = ORIG_EXEC_PATH; | ||
mocks.restore(); | ||
}); | ||
|
||
// | ||
|
@@ -85,6 +91,14 @@ test('check if stdout + stderr go to output', t => { | |
t.is(result.stderr, '1234\n'); | ||
}); | ||
|
||
test('check if stdout + stderr should not be printed to console if silent', t => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is great. Can you also add a second test to handle the case for Optional suggestion: you can replace the command with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Above you suggested that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For this PR, correct behavior is to always pass
I think two cases are interesting:
Does this make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @uttpal any update? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will fix and add test asap |
||
shell.exec(`${JSON.stringify(shell.config.execPath)} -e "console.error(1234); console.log(666); process.exit(12);"`, { silent: true }); | ||
const stdout = mocks.stdout(); | ||
const stderr = mocks.stderr(); | ||
t.is(stdout, ''); | ||
t.is(stderr, ''); | ||
}); | ||
|
||
test('check exit code', t => { | ||
const result = shell.exec(`${JSON.stringify(shell.config.execPath)} -e "process.exit(12);"`); | ||
t.truthy(shell.error()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I believe correct behavior (comparing against v0.7.8) is to never print this. So, this should be
silent: true
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to clarify, here
silent: true
will always be there?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my previous comment, I intended for you to change this line to: