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: make test runner work even if there is no AbortSignal support #36

Merged
merged 3 commits into from
Aug 3, 2022

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Aug 2, 2022

Fixes a breaking change for Node.js v14.x that was introduced in 3.2.0. This also skips some test/message that rely on AbortSignal support. I suggest we land this and release in a semver-patch, then we revert and create a new semver-major. Thoughts?

Fixes: #35

package.json Outdated Show resolved Hide resolved
test/common/index.js Outdated Show resolved Hide resolved
Copy link
Member

@MoLow MoLow left a comment

Choose a reason for hiding this comment

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

LGTM.
Two thaughts:

  1. We can make this work in node14 even when no abort controller and just ignore the signal option when can't do anything with it
  2. Perhaps the message tests should have an out file per node (major) version? Instead of shimming apis in common.

@aduh95
Copy link
Contributor Author

aduh95 commented Aug 3, 2022

2. Perhaps the message tests should have an out file per node (major) version? Instead of shimming apis in common.

The out file comes from nodejs/node, the whole point is to use the same tests as Node.js to ensure we are shipping a similar API. Making separate out files would 1) a lot of work 2) harder to review 3) not as useful.

@MoLow
Copy link
Member

MoLow commented Aug 3, 2022

The out file comes from nodejs/node, the whole point is to use the same tests as Node.js to ensure we are shipping a similar API. Making separate out files would 1) a lot of work 2) harder to review 3) not as useful.

I am working on assert.snapshot that will hopfully make it much easier :)

@aduh95
Copy link
Contributor Author

aduh95 commented Aug 3, 2022

I am working on assert.snapshot that will hopfully make it much easier :)

It's unlikely to ever be backported to v14.x, so I'm not sure it's going to help us.

Fixes a breaking change for Node.js v14.x that was introduced in 3.2.0.

Fixes: nodejs#35
@aduh95 aduh95 force-pushed the fix-v14.x-breaking-change branch from 1b3f8bb to c9fa8a0 Compare August 3, 2022 08:20
@aduh95 aduh95 requested a review from juliangruber August 3, 2022 08:42
@@ -84,6 +84,10 @@ const main = async () => {
for await (const dirent of dir) {
const ext = extname(dirent.name)
if (ext === '.js' || ext === '.mjs') {
if (typeof AbortSignal === 'undefined' && dirent.name.startsWith('test_runner_abort')) {
console.log('no AbortSignal support, skipping', dirent.name)
Copy link
Member

Choose a reason for hiding this comment

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

would the smoothest flow be to include an AbortSignal ponyfill for node 14? Are there any major concerns including one?

Copy link
Member

Choose a reason for hiding this comment

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

I think this would be the nicest option, as long as node 14 is in maintenance lts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't find any satisfying ponyfill. Note that we are running tests both with and without --experimental-abort-controller flag, folks who want/need that functionality should pass this flag.

Copy link
Member

Choose a reason for hiding this comment

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

right, I think this is a good compromise 👍

Copy link
Member

Choose a reason for hiding this comment

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

+1

README.md Outdated
@@ -339,7 +342,7 @@ internally.
- `only` {boolean} If truthy, and the test context is configured to run
`only` tests, then this test will be run. Otherwise, the test is skipped.
**Default:** `false`.
* `signal` {AbortSignal} Allows aborting an in-progress test.
- `signal` {AbortSignal} Allows aborting an in-progress test (except on Node.js v14.x).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- `signal` {AbortSignal} Allows aborting an in-progress test (except on Node.js v14.x).
- `signal` {AbortSignal} Allows aborting an in-progress test (needs `--experimental-abortcontroller` on Node.js v14.x).

I believe the previous statement wasn't correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well now that I think about it, users are still allowed to pass an AbortSignal, which they can't pass if they don't have AbortController support themselves anyway. The part that doesn't work is context.signal, I should put the warning on that section instead.

@aduh95 aduh95 merged commit cb2e4fd into nodejs:main Aug 3, 2022
@aduh95 aduh95 deleted the fix-v14.x-breaking-change branch August 3, 2022 11:14
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 this pull request may close these issues.

3.2.0 fails in node 14
3 participants