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

test module corrupts console.log output #47955

Closed
strager opened this issue May 11, 2023 · 6 comments · Fixed by #47867
Closed

test module corrupts console.log output #47955

strager opened this issue May 11, 2023 · 6 comments · Fixed by #47867
Labels
confirmed-bug Issues with confirmed bugs. test_runner Issues and PRs related to the test runner subsystem.

Comments

@strager
Copy link

strager commented May 11, 2023

Version

v20.1.0

Platform

Linux strapurp 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

test/test-bug.mjs:

import test from "node:test";                                                   
                                                                                
test("bug repro", () => {                                                       
  console.log(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]));                        
}); 

Run: node --test test/test-bug.mjs

How often does it reproduce? Is there a required condition?

100% repro rate (not flaky).

Seems to happen when [ is logged.

What is the expected behavior? Why is that the expected behavior?

ℹ Uint8Array(8) [
ℹ   1, 2, 3, 4,
ℹ   5, 6, 7, 8
ℹ ]
✔ bug repro (1.678472ms)
ℹ tests 1
ℹ suites 0
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 35.77873

console.log in --test mode should show output similar to console.log in normal Node.js:

$ node -e 'console.log(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]));'
Uint8Array(8) [
  1, 2, 3, 4,
  5, 6, 7, 8
]

What do you see instead?

Logged elements of the Uint8Array are missing:

ℹ Uint8Array(8) [
ℹ 1
ℹ 5
ℹ ]
✔ bug repro (1.678472ms)
ℹ tests 1
ℹ suites 0
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 35.77873

Additional information

I encountered this bug with Uint8Array.

I also encountered this bug with code like the following:

console.log(`  [${i}] ...`);
@strager
Copy link
Author

strager commented May 11, 2023

console.error doesn't seem to have this problem. I'll use console.error as a workaround.

@cronosmain
Copy link

It seems that if a line starts with a space character, only the first word in the line is printed.

This code, for example:

import test from 'node:test'

test('bug', () => {
  console.log('hello world')
  console.log(' hello world')
})

outputs the following:

ℹ hello world
ℹ hello

@VoltrexKeyva VoltrexKeyva added the test_runner Issues and PRs related to the test runner subsystem. label May 11, 2023
@jakecastelli
Copy link
Contributor

I found the issue in the TapParse, can I work on this issue?

@MoLow MoLow added the confirmed-bug Issues with confirmed bugs. label May 11, 2023
@MoLow
Copy link
Member

MoLow commented May 11, 2023

this will be fixed by #47867 so no need to fix TapParse

@jakecastelli
Copy link
Contributor

jakecastelli commented May 11, 2023

Thanks @MoLow! For the sake of the coding exercise, was the issue because of tap laxer (tap_lexer.js)?

By the way the fix PR you linked seems not the correct one ^ 47867 instead of 47955 (which is this issue itself)

@MoLow
Copy link
Member

MoLow commented May 11, 2023

For the sake of the coding exercise, was the issue because of tap laxer (tap_lexer.js)?

don't know :)

nodejs-github-bot pushed a commit that referenced this issue May 15, 2023
PR-URL: #47867
Fixes: #44656
Fixes: #47955
Fixes: #47481
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
targos pushed a commit that referenced this issue May 15, 2023
PR-URL: #47867
Fixes: #44656
Fixes: #47955
Fixes: #47481
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
danielleadams pushed a commit that referenced this issue Jul 6, 2023
PR-URL: #47867
Fixes: #44656
Fixes: #47955
Fixes: #47481
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
MoLow added a commit to MoLow/node that referenced this issue Jul 6, 2023
PR-URL: nodejs#47867
Fixes: nodejs#44656
Fixes: nodejs#47955
Fixes: nodejs#47481
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants