prevent accidental calls to io.exit when asserts are active.#46210
Merged
jonahwilliams merged 9 commits intoflutter:masterfrom Dec 9, 2019
Merged
prevent accidental calls to io.exit when asserts are active.#46210jonahwilliams merged 9 commits intoflutter:masterfrom
jonahwilliams merged 9 commits intoflutter:masterfrom
Conversation
Contributor
Author
|
Errm, right - assertions in integration tests. If we could detect that we are in a package:test isolate maybe this could be more narrowly focused. |
zanderso
reviewed
Dec 6, 2019
| final ProcessResult result = await processManager.run(command, | ||
| workingDirectory: folder, | ||
| environment: <String, String>{ | ||
| 'FLUTTER_INTEGRATION_TEST': 'true' |
Member
There was a problem hiding this comment.
In the previous two instances of this it's set to 'test' rather than 'true'.
| /// Throws [StateError] if assertions are enabled and the dart:io exit | ||
| /// is still active when called. This may indicate exit was called in | ||
| /// a test without being configured correctly. This behavior can be | ||
| /// removed by setting the `FLUTTER_INTEGRATION_TEST` environment |
Member
There was a problem hiding this comment.
Is FLUTTER_INTEGRATION_TEST new? Is there any pre-existing one that could work?
Contributor
Author
There was a problem hiding this comment.
there is a FLUTTER_TEST value that is set by flutter test and for some reason by the test_driver.dart. I could reuse that field since I don't think it is used otherwise for pub run test
Contributor
Author
There was a problem hiding this comment.
Switched to FLUTTER_TEST
zanderso
reviewed
Dec 6, 2019
| /// `dart:io`. | ||
| ExitFunction get exit => _exitFunction; | ||
| ExitFunction get exit { | ||
| assert(() { |
Member
There was a problem hiding this comment.
Does this work?
assert(
_exitFunction != io.exit || io.Platform.environment['FLUTTER_TEST'] != null,
'io.exit was called with assertions active. If this is an integration test, '
'ensure that the environment variable FLUTTER_TEST is set '
'to a non-null String.',
);
zanderso
approved these changes
Dec 6, 2019
added 2 commits
December 6, 2019 14:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
To prevent a scenario such as #46142 for occurring again in the future, prevent calls to dart:io's exit when asserts are enabled. Allow an env variable to override to allow for integration tests, which run the full flutter process with asserts enabled