Add scaffolding, expect, hooks libraries (#1460)
Shuffles code around to make a more clear distinction between the
different types of use cases that are satisfied by the "frontend"
classes. Exposing an import which does not include `expect` and the
matchers will make it possible to write alternative matching frameworks
without worrying about name conflicts.
- `scaffolding` includes the code to define test cases and high level
utilities that user level test code might need. A test might import
`scaffolding` instead of `test` if they want to use a different
matching framework and don't need `expect`.
- `expect` includes the synchronous and asynchronous matchers, as well
as `expect` and `expectAsync*`.
Add a new library `test_api/hooks` which has lower level APIs for
interacting with the test runner. `expect` is written against only
`hooks`, and an alternative matching framework could have equivalent
capabilities using the same APIs. The primary capability which was
previously only available in `Invoker` is the ability to report that
some async work has not completed, and must complete before the test can
be considered done.
- Add `hooks.dart` and refactor all of `lib/src/expect/*` to use it.
- Move most code from `src/frontend` to either `src/scaffolding` or
`src/expect` as appropriate.
- Change the original entrypoints to export the new ones. Avoid exporting
deprecated members, and `registerException` which is not yet deprecated
but may not be quite the API we want in `hooks.dart`.
Fixes #1468. The new API in `hooks.dart` takes a `Future` instead of adding
and removing from a counter of unfinished callbacks. Since the handler on the
future won't run in the same Zone as the wrapped callback does, it doesn't
suffer the same issues of passing a callback to a non-test Zone.
We fold stack frames stemming from the `test*` packages specifically,
which means that frames beneath `expect` get handled for free. An
alternative matching framework defined outside this package would not
have the same advantage, so we may need to find an API to bring that to
49 files changed