Skip to content

Conversation

OkunadeNaheem
Copy link

test_runner: write timestamp as first line in watch mode

The goal: To always print a timestamp as the first line in watch mode to make test restarts clearer and logs easier to read.

Continuation from https://github.com/nodejs/node/pull/57903/files solution, i simply created a new event 'timestamp' and then handled it. Also modified the test to directly test my changes from runner.js instead of test_streams.js file.

Refs: #57206

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Aug 1, 2025
this.#tryPush(null);
}

// This event emitter logs a timestamp whenever a test restarts because of changes in any related files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need comment here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have taken it out


await runningSubtests.get(file);

// Emit the 'test:restarted' event if a timeStamp reporter is available.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been taken out also.

The goal: To always print a timestamp as the first line in watch mode to make test restarts clearer and logs easier to read.

Continuation from https://github.com/nodejs/node/pull/57903/files solution, i simply created a new event 'timestamp' and then handled it. Also modified the test to directly test my changes from runner.js instead of test_streams.js file.

Refs: nodejs#57206

Authors: https://github.com/JacopoPatroclo, https://github.com/OkunadeNaheem
@OkunadeNaheem OkunadeNaheem force-pushed the test_runner/add-restart-timestamp branch from dcf91d8 to fac4f07 Compare August 2, 2025 07:35
@OkunadeNaheem OkunadeNaheem reopened this Aug 7, 2025
@OkunadeNaheem OkunadeNaheem marked this pull request as ready for review August 7, 2025 14:52
Copy link
Member

@pmarchini pmarchini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR we’re not introducing the timestamp as stated in the title.
What we should do instead is leverage the existing event so that the various reporters can print a restart message followed by the date.

The tests should then verify this behaviour!


await runningSubtests.get(file);

opts.root.reporter[kEmitMessage]('test:watch:restarted');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @OkunadeNaheem, it looks like this branch was created from a very outdated main branch.

This addition was already made two months ago in this PR: #57903

Here's the line: https://github.com/nodejs/node/blob/main/lib/internal/test_runner/runner.js#L526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants