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

Make the higher-order comparisons in the structured clone tests async #31232

Merged
merged 3 commits into from Oct 25, 2021

Conversation

andreubotella
Copy link
Member

In the structured clone battery of tests, the callback parameter to check can be an async function, and its return value is awaited. However, comparison functions which might be async can be passed to the higher-order comparison function enumerate_props, whose return value is in turn passed to the higher-order functions compare_Array or compare_Object.

Currently, the returned function from these higher-order comparison functions is sync and simply calls the HOF's callback. This means that, if the callback is async (like compare_Blob is), its comparison might not be done by the time the test finishes, and any errors and assertion failures in the comparison will count as errors of the test file, rather than of the specific subtest.

This change makes the function returned from enumerate_props, compare_Array and compare_Object async and changes them to await the return value of their callback. It also makes compare_File await for the return value of compare_Blob.

In the structured clone battery of tests, the `callback` parameter to
`check` can be an `async` function, and its return value is awaited.
However, comparison functions which might be `async` can be passed to
the higher-order comparison function `enumerate_props`, whose return
value is in turn passed to the higher-order functions `compare_Array` or
`compare_Object`.

Currently, the returned function from these higher-order comparison
functions is sync and simply calls the HOF's callback. This means that,
if the callback is `async` (like `compare_Blob` is), its comparison
might not be done by the time the test finishes, and any errors and
assertion failures in the comparison will count as errors of the test
file, rather than of the specific subtest.

This change makes the function returned from `enumerate_props`,
`compare_Array` and `compare_Object` `async` and changes them to `await`
the return value of their callback. It also makes `compare_File` await
for the return value of `compare_Blob`.
andreubotella pushed a commit that referenced this pull request Oct 14, 2021
The `test_obj` parameter in the comparison functions of the structured
clone battery of tests doesn't seem to be used at all, considering that
the those functions only use it to call `test_obj.done()`, which is a
no-op. This seems to have once been used to indicate asynchronous test
completion, but that hasn't worked for a long time, and #31232 has now
made that obsolete.

Aside from removing the `test_obj` arguments to the comparison functions
and the calls to `test_obj.done()`, as well as the creation of the
`testObjMock` object in the `check` function, this change also removes
the `callback_is_async` boolean argument to `compare_Array` and
`compare_Object`.
@annevk
Copy link
Member

annevk commented Oct 15, 2021

I wonder if @surma is willing to review this. It looks reasonable to me, but I'm not as familiar with the complete setup.

@domenic
Copy link
Member

domenic commented Oct 25, 2021

Can we/should we also remove callback_is_async, since you are effectively always assuming it's async now?

@andreubotella
Copy link
Member Author

andreubotella commented Oct 25, 2021

Can we/should we also remove callback_is_async, since you are effectively always assuming it's async now?

I did that and other follow-up clean-ups in #31233.

@domenic domenic merged commit a90395d into master Oct 25, 2021
@domenic domenic deleted the andreubotella/structured-clone-async-hof branch October 25, 2021 17:23
andreubotella pushed a commit that referenced this pull request Oct 25, 2021
The `test_obj` parameter in the comparison functions of the structured
clone battery of tests doesn't seem to be used at all, considering that
the those functions only use it to call `test_obj.done()`, which is a
no-op. This seems to have once been used to indicate asynchronous test
completion, but that hasn't worked for a long time, and #31232 has now
made that obsolete.

Aside from removing the `test_obj` arguments to the comparison functions
and the calls to `test_obj.done()`, as well as the creation of the
`testObjMock` object in the `check` function, this change also removes
the `callback_is_async` boolean argument to `compare_Array` and
`compare_Object`.
domenic pushed a commit that referenced this pull request Oct 25, 2021
The `test_obj` parameter in the comparison functions of the structured
clone battery of tests doesn't seem to be used at all, considering that
the those functions only use it to call `test_obj.done()`, which is a
no-op. This seems to have once been used to indicate asynchronous test
completion, but that hasn't worked for a long time, and #31232 has now
made that obsolete.

Aside from removing the `test_obj` arguments to the comparison functions
and the calls to `test_obj.done()`, as well as the creation of the
`testObjMock` object in the `check` function, this change also removes
the `callback_is_async` boolean argument to `compare_Array` and
`compare_Object`.
Gabisampaio pushed a commit to Gabisampaio/wpt that referenced this pull request Nov 18, 2021
The `test_obj` parameter in the comparison functions of the structured
clone battery of tests doesn't seem to be used at all, considering that
the those functions only use it to call `test_obj.done()`, which is a
no-op. This seems to have once been used to indicate asynchronous test
completion, but that hasn't worked for a long time, and web-platform-tests#31232 has now
made that obsolete.

Aside from removing the `test_obj` arguments to the comparison functions
and the calls to `test_obj.done()`, as well as the creation of the
`testObjMock` object in the `check` function, this change also removes
the `callback_is_async` boolean argument to `compare_Array` and
`compare_Object`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants