Skip to content

Conversation

@Dexterp37
Copy link
Contributor

This PR removes the mechanism based on timeouts and observers to wait on test tasks in the dispatcher. It instead defines a new task type, TestTask, and passes a resolver function when its created.

This PR removes the mechanism based on timeouts and
observers to wait on test tasks in the dispatcher. It
instead defines a new task type, TestTask, and passes
a resolver function when its created.
@Dexterp37 Dexterp37 requested a review from brizental April 26, 2021 06:17
@Dexterp37 Dexterp37 self-assigned this Apr 26, 2021
Copy link
Contributor

@brizental brizental left a comment

Choose a reason for hiding this comment

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

I think we should keep the timeout part. Otherwise tests will hang forever in case Glean.initialize is not called before using the testing APIs.

A clearer error message can be logged in that case, to make the error more actionable for users:

console.error(
    "Test task took to long to execute.",
    "Please check if Glean was initialized.",
    "Bailing out."
);

@Dexterp37
Copy link
Contributor Author

I think we should keep the timeout part. Otherwise tests will hang forever in case Glean.initialize is not called before using the testing APIs.

A clearer error message can be logged in that case, to make the error more actionable for users:

console.error(
    "Test task took to long to execute.",
    "Please check if Glean was initialized.",
    "Bailing out."
);

I'm not sure it's worth the complexity to be honest. The whole observer mechanism added quite a few problems in the dispatcher only to account for the fact that Glean was not initialized. I think we should probably just have a boolean somewhere in the dispatcher that's set to true by Glean.js and, if test APIs are called and that's still false, we throw (this is roughly how other bindings do it).

@brizental
Copy link
Contributor

I'm not sure it's worth the complexity to be honest. The whole observer mechanism added quite a few problems in the dispatcher only to account for the fact that Glean was not initialized. I think we should probably just have a boolean somewhere in the dispatcher that's set to true by Glean.js and, if test APIs are called and that's still false, we throw (this is roughly how other bindings do it).

Yeah, now that you mention it you don't even need to set a boolean somewhere, you can just get it from the Context.

That was there in case people called testing APIs before Glean was initialized, but initialized Glean right after of something of the sort. Doesn't matter, if this becomes a problem we can file a bug.

@Dexterp37 Dexterp37 merged commit 7d913cd into mozilla:main Apr 27, 2021
@Dexterp37 Dexterp37 deleted the simplify_testlaunch branch April 27, 2021 08:10
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.

2 participants