From f383b1a8b7d2c07b9733d3cf0637eeee7cfe6fa7 Mon Sep 17 00:00:00 2001 From: James Talmage Date: Tue, 24 May 2016 00:55:45 -0400 Subject: [PATCH 1/3] Document current API design. --- api-design.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 api-design.md diff --git a/api-design.md b/api-design.md new file mode 100644 index 000000000..881ab6382 --- /dev/null +++ b/api-design.md @@ -0,0 +1,60 @@ +** This document is for team discussion. Not intended as documentation** + + +## Current API + +```js +new Api(apiOptions).run(files, runOptions) +``` + +### constructor + +#### apiOptions + +- **match** - `Array` of `strings` - Used to filter on test titles via `--match` flag. + +- **require** - `Array` of `strings` - Modules to be loaded before the test runs. + +- **timeout** - `string` - Human readable timeout (`10m`, `2s`, etc). + +- **cacheDir** - `string` - Path to the cacheDir. + +- **babelConfig** - `Object` - or shortcut `string` - The babel config. + +- **serial** - `boolean` - Run everything serially. + +- **explicitTitles** - `boolean` - Force inclusion of the filename in test titles. + +- **cacheEnabled** - `boolean` - Defaults true. Set to `false` with the `--no-cache` flag. + +- **concurrency** - `number` - How many processes at once. + + + +### run(files, runOptions) + + +#### files + +- `string` or `Array of strings`. + +#### runOptions + +- **runOnlyExclusive** - `boolean` - Used by watcher to handle `.only` tests. + + +## Watcher + +### constructor + +```js +new Watcher(logger, api, files, sources); +``` + +- **logger** - Instance of `lib/logger.js`, already populated with the correct reporter. Watcher currently needs this separately so it can reset the reporters between test runs (reset is needed by anything that uses control characters). + +- **api** - An instance of the API, already passed all it's options. + +- **files** - Glob patterns to watch + +- **files** - Glob patterns to restrict source watching. Otherwise any change to a file that is not a source causes a watcher rerun. From 657fc9452134f5663c5d0c549c541663d3f370ff Mon Sep 17 00:00:00 2001 From: James Talmage Date: Tue, 24 May 2016 01:04:41 -0400 Subject: [PATCH 2/3] add failFast option --- api-design.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api-design.md b/api-design.md index 881ab6382..67dbc1945 100644 --- a/api-design.md +++ b/api-design.md @@ -29,6 +29,8 @@ new Api(apiOptions).run(files, runOptions) - **concurrency** - `number` - How many processes at once. +- **failFast** - `boolean` - bail at first failure + ### run(files, runOptions) From 24e95ae28e42d68d96f375ae93585043b96a0701 Mon Sep 17 00:00:00 2001 From: James Talmage Date: Tue, 24 May 2016 12:25:58 -0400 Subject: [PATCH 3/3] IPC Events, Fork Events, Runner Events --- api-design.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/api-design.md b/api-design.md index 67dbc1945..262419dbf 100644 --- a/api-design.md +++ b/api-design.md @@ -60,3 +60,64 @@ new Watcher(logger, api, files, sources); - **files** - Glob patterns to watch - **files** - Glob patterns to restrict source watching. Otherwise any change to a file that is not a source causes a watcher rerun. + + +# Events + +## IPC Events + +- :arrow_up: `no-tests` - `{avaRequired: boolean}` + +- :arrow_up: `uncaughtException` - `{exception: serializedError}` + + Parent will immediately send the `teardown` event. + +- :arrow_up: `unhandledRejections` - `{rejections: serializedError[]}` + + Sent in response to a `ava-teardown` event from parent. + +- :arrow_up: `teardown` - `{dependencies: strings[]}` + + Sent in response to `ava-teardown` event from parent. + +- :arrow_up: `test` - Reports a test result. + +- :arrow_up: `results` - All the test results. (Why two events that send results?). + + Sent in response to `init-exit`, or immediately on an error in `fail-fast` mode. + + `{stats: ???}` + +- :arrow_up: `stats` + + Parent sends `run` event in response. Does so immediately if `fork.run()` is already called, otherwise waits for it. + + `{testCount: number, hasExclusive: boolean}` + +- :arrow_down: `ava-teardown` - no data - tells the child to prepare for shutdown and send the list of dependencies and rejections. + +- :arrow_down: `ava-exit` - no data - actually kill the process + +- :arrow_down: `ava-run` - start running tests + +- :arrow_down: `init-exit` - inits the exit? This sounds like `ava-teardown` + +## Fork Events + +Re-emits all the :arrow_up: IPC events. As well as `stdout` and `stderr` events. + +## Runner Events + +Emits only one from what I can tell: `test` - The event has props: + +```js +opts = { + duration: number, + title: string, + error: error, + type: test.metadata.type, + skip: test.metadata.skipped, + todo: test.metadata.todo, + failing: test.metadata.failing +} +```