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

Fix the verbose tests #598

Closed
ehmicky opened this issue Dec 14, 2023 · 1 comment · Fixed by #600
Closed

Fix the verbose tests #598

ehmicky opened this issue Dec 14, 2023 · 1 comment · Fixed by #600

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented Dec 14, 2023

The verbose tests are currently randomly failing.

execa/test/verbose.js

Lines 10 to 22 in 5b1a1c7

test('Prints command when "verbose" is true', async t => {
const {stdout, stderr, all} = await execa('nested.js', [JSON.stringify({verbose: true}), 'noop.js', 'test'], {all: true});
t.is(stdout, 'test');
t.is(normalizeTimestamp(stderr), `${testTimestamp} noop.js test`);
t.is(normalizeTimestamp(all), `${testTimestamp} noop.js test\ntest`);
});
test('Prints command with NODE_DEBUG=execa', async t => {
const {stdout, stderr, all} = await execa('nested.js', [JSON.stringify({}), 'noop.js', 'test'], {all: true, env: {NODE_DEBUG: 'execa'}});
t.is(stdout, 'test');
t.is(normalizeTimestamp(stderr), `${testTimestamp} noop.js test`);
t.is(normalizeTimestamp(all), `${testTimestamp} noop.js test\ntest`);
});


  verbose › Prints command when "verbose" is true

  test/verbose.js:14

   13:   t.is(normalizeTimestamp(stderr), `${testTimestamp} noop.js test`);   
   14:   t.is(normalizeTimestamp(all), `${testTimestamp} noop.js test\ntest`);
   15: });                                                                    

  Difference (- actual, + expected):

  - `test␊
  - [00:00:00.000] noop.js test`
  + `[00:00:00.000] noop.js test␊
  + test`

  › file://test/verbose.js:14:4

  verbose › Prints command with NODE_DEBUG=execa

  test/verbose.js:21

   20:   t.is(normalizeTimestamp(stderr), `${testTimestamp} noop.js test`);   
   21:   t.is(normalizeTimestamp(all), `${testTimestamp} noop.js test\ntest`);
   22: });                                                                    

  Difference (- actual, + expected):

  - `test␊
  - [00:00:00.000] noop.js test`
  + `[00:00:00.000] noop.js test␊
  + test`

  › file://test/verbose.js:21:4

This is because the verbose option prints to stderr. When the process prints to stdout, it might be printed first, even if the call to stderr was made before. This is a race condition.

This was referenced Dec 14, 2023
@ehmicky
Copy link
Collaborator Author

ehmicky commented Dec 14, 2023

Fixed by #600.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant