Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

update to the test package #84

Merged
merged 1 commit into from
Dec 16, 2015
Merged

update to the test package #84

merged 1 commit into from
Dec 16, 2015

Conversation

jakemac53
Copy link
Contributor

No description provided.

/// Custom implementations of the functions from `package:test`. These ensure
/// that the body of all test function are run in the dirty checking zone.
test(String description, body()) => original_test.test(
description, () => dirtyCheckZone().bindCallback(body)());
Copy link
Contributor

Choose a reason for hiding this comment

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

cool that you figured it out!

@nex3 - is there anything that can be changed in the test package to make it easier to work with code that uses zones without having to add workarounds like this one?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what's bad about this solution. If you want a test body to be run in a zone, run it in the zone. It seems like the most straightforward way to express what you mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only issue is that previously we could define a single top level function which runs all tests, and just run that one function in the zone (all the test bodies would also be ran in the same zone). This is no longer the case in the test runner.

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by "a function that runs all tests"? Is this something you were defining on Configuration?

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 just mean a top level function which contained all the invocations of test, see https://github.com/dart-lang/observe/pull/84/files#diff-d0b4c4bde478579a03ae3898a56bb2edL13.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose we could bind test callbacks to the zone they're declared in, but if the zone is stateful then you're setting yourself up for hidden state dependencies between tests.

Another possibility would be to provide a surround() function that would work like a combination of setUp() and tearDown(). For example:

void main() {
  surround((runTest) {
    dirtyCheckZone().bindCallback(runTest)();
  });

  // ...
}

I'm not sure this is feasible—there are a lot of tricky corner cases about how it would interact with tearDown(), errors, and asynchrony that I'd probably have to implement it to fully understand—but if it is, would it help this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

One other note: it's important to be sure that the test package's own zones are still in the body's zone hierarchy. Does your dirtyCheckZone() function do that?

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 suppose we could bind test callbacks to the zone they're declared in, but if the zone is stateful then you're setting yourself up for hidden state dependencies between tests.

Good point, although I don't think it would be any worse than the solution implemented here in that regard.

Another possibility would be to provide a surround() function that would work like a combination of setUp() and tearDown()

This sounds like it would help, but I don't know if its worth investing time in or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like it would help, but I don't know if its worth investing time in or not.

May as well file an issue: dart-lang/test#337

@sigmundch
Copy link
Contributor

lgtm

jakemac53 added a commit that referenced this pull request Dec 16, 2015
@jakemac53 jakemac53 merged commit 02a609b into master Dec 16, 2015
@jakemac53 jakemac53 deleted the test-package branch December 16, 2015 18:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants