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_runner: refactor primordial-based Promise chains #55958

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Nov 22, 2024

This PR refactors two Promise chains in the test runner to use async/await style syntax instead. IMO this makes these two pieces of code significantly more readable (largely because of primordials), and will make some planned changes easier to implement.

test_runner: refactor build Promise in Suite()

This commit refactors the buildSuite Promise logic in the Suite
constructor to use an async function instead of creating an
awkward primordial-based Promise chain.

test_runner: refactor Promise chain in run()

This commit refactors the chain of functions in run() to use an
async function instead of creating an awkward primordial-based
Promise chain.

This commit refactors the buildSuite Promise logic in the Suite
constructor to use an async function instead of creating an
awkward primordial-based Promise chain.
This commit refactors the chain of functions in run() to use an
async function instead of creating an awkward primordial-based
Promise chain.
@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 Nov 22, 2024
Comment on lines +810 to +816
if (typeof postRun === 'function') {
postRun();
}

if (typeof teardown === 'function') {
teardown();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (typeof postRun === 'function') {
postRun();
}
if (typeof teardown === 'function') {
teardown();
}
postRun?.();
teardown?.();

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.98%. Comparing base (3178a76) to head (1b298a1).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55958      +/-   ##
==========================================
- Coverage   87.99%   87.98%   -0.01%     
==========================================
  Files         653      653              
  Lines      187852   187857       +5     
  Branches    35888    35885       -3     
==========================================
  Hits       165295   165295              
- Misses      15729    15734       +5     
  Partials     6828     6828              
Files with missing lines Coverage Δ
lib/internal/test_runner/runner.js 89.10% <100.00%> (+0.17%) ⬆️
lib/internal/test_runner/test.js 96.95% <100.00%> (-0.02%) ⬇️

... and 24 files with indirect coverage changes

---- 🚨 Try these New Features:

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

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.

9 participants