Skip to content

test module corrupts console.log output #47955

Description

@strager

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}] ...`);

Activity

  1. strager commented on May 11, 2023

    @strager
    Author

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

  2. cronosmain commented on May 11, 2023

    @cronosmain

    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
    
  3. jakecastelli commented on May 11, 2023

    @jakecastelli
    Member

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

  4. MoLow commented on May 11, 2023

    @MoLow
    Member

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

  5. jakecastelli commented on May 11, 2023

    @jakecastelli
    Member

    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)

  6. MoLow commented on May 11, 2023

    @MoLow
    Member

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

    don't know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions