@cucumber/cucumber 7.1.0 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -1
- package/README.md +2 -1
- package/lib/cli/configuration_builder.js +4 -3
- package/lib/cli/configuration_builder.js.map +1 -1
- package/lib/cli/helpers.js +40 -18
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/index.js +23 -15
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/profile_loader.d.ts +1 -2
- package/lib/cli/profile_loader.js.map +1 -1
- package/lib/cli/publish_banner.js +1 -1
- package/lib/cli/publish_banner.js.map +1 -1
- package/lib/formatter/get_color_fns.d.ts +6 -2
- package/lib/formatter/get_color_fns.js +18 -12
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +14 -17
- package/lib/formatter/helpers/event_data_collector.js +14 -8
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -6
- package/lib/formatter/helpers/gherkin_document_parser.js +1 -4
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +6 -6
- package/lib/formatter/helpers/issue_helpers.js +5 -6
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.d.ts +9 -10
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -2
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.d.ts +2 -2
- package/lib/formatter/helpers/summary_helpers.js +32 -14
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +33 -14
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +5 -5
- package/lib/formatter/helpers/test_case_attempt_parser.js +27 -9
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.d.ts +3 -3
- package/lib/formatter/helpers/usage_helpers/index.js +30 -13
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.js +1 -1
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +21 -27
- package/lib/formatter/json_formatter.js +50 -23
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.js +1 -1
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +6 -6
- package/lib/formatter/progress_bar_formatter.js +3 -3
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +2 -2
- package/lib/formatter/progress_formatter.js +29 -10
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.js +22 -4
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.js +21 -2
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +3 -3
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
- package/lib/formatter/summary_formatter.d.ts +2 -2
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.js +22 -3
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/index.d.ts +14 -12
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.d.ts +3 -4
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/definition.d.ts +2 -2
- package/lib/models/definition.js.map +1 -1
- package/lib/models/test_case_hook_definition.d.ts +2 -2
- package/lib/models/test_case_hook_definition.js.map +1 -1
- package/lib/models/test_step_hook_definition.d.ts +2 -2
- package/lib/models/test_step_hook_definition.js.map +1 -1
- package/lib/pickle_filter.d.ts +9 -11
- package/lib/pickle_filter.js +4 -4
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.d.ts +13 -0
- package/lib/runtime/assemble_test_cases.js +88 -0
- package/lib/runtime/assemble_test_cases.js.map +1 -0
- package/lib/runtime/attachment_manager/index.d.ts +2 -2
- package/lib/runtime/attachment_manager/index.js +23 -4
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/helpers.d.ts +2 -2
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +4 -3
- package/lib/runtime/index.js +31 -13
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/command_types.d.ts +10 -9
- package/lib/runtime/parallel/command_types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +10 -9
- package/lib/runtime/parallel/coordinator.js +54 -43
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -2
- package/lib/runtime/parallel/worker.js +8 -14
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/step_runner.d.ts +3 -3
- package/lib/runtime/step_runner.js +16 -12
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.d.ts +4 -4
- package/lib/runtime/stopwatch.js +21 -2
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/{pickle_runner.d.ts → test_case_runner.d.ts} +16 -32
- package/lib/runtime/{pickle_runner.js → test_case_runner.js} +104 -147
- package/lib/runtime/test_case_runner.js.map +1 -0
- package/lib/step_arguments.d.ts +4 -4
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +9 -7
- package/lib/support_code_library_builder/index.js +11 -10
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +21 -23
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/support_code_library_builder/validate_arguments.js.map +1 -1
- package/lib/support_code_library_builder/world.d.ts +7 -1
- package/lib/support_code_library_builder/world.js.map +1 -1
- package/lib/time.d.ts +2 -10
- package/lib/time.js +24 -48
- package/lib/time.js.map +1 -1
- package/package.json +33 -33
- package/lib/runtime/pickle_runner.js.map +0 -1
- package/lib/status.d.ts +0 -3
- package/lib/status.js +0 -5
- package/lib/status.js.map +0 -1
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
23
|
};
|
|
5
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
25
|
const is_stream_1 = __importDefault(require("is-stream"));
|
|
7
|
-
const
|
|
26
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
8
27
|
const value_checker_1 = require("../../value_checker");
|
|
9
28
|
class AttachmentManager {
|
|
10
29
|
constructor(onAttachment) {
|
|
@@ -32,13 +51,13 @@ class AttachmentManager {
|
|
|
32
51
|
}
|
|
33
52
|
if (mediaType.startsWith('base64:')) {
|
|
34
53
|
this.createStringAttachment(data, {
|
|
35
|
-
encoding:
|
|
54
|
+
encoding: messages.AttachmentContentEncoding.BASE64,
|
|
36
55
|
contentType: mediaType.replace('base64:', ''),
|
|
37
56
|
});
|
|
38
57
|
}
|
|
39
58
|
else {
|
|
40
59
|
this.createStringAttachment(data, {
|
|
41
|
-
encoding:
|
|
60
|
+
encoding: messages.AttachmentContentEncoding.IDENTITY,
|
|
42
61
|
contentType: mediaType,
|
|
43
62
|
});
|
|
44
63
|
}
|
|
@@ -49,7 +68,7 @@ class AttachmentManager {
|
|
|
49
68
|
}
|
|
50
69
|
createBufferAttachment(data, mediaType) {
|
|
51
70
|
this.createStringAttachment(data.toString('base64'), {
|
|
52
|
-
encoding:
|
|
71
|
+
encoding: messages.AttachmentContentEncoding.BASE64,
|
|
53
72
|
contentType: mediaType,
|
|
54
73
|
});
|
|
55
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/attachment_manager/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/attachment_manager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAgC;AAEhC,6DAA8C;AAC9C,uDAAqE;AAoBrE,MAAqB,iBAAiB;IAGpC,YAAY,YAA6B;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,2BAA2B,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,CACJ,IAAgC,EAChC,SAAkB,EAClB,QAAqB;QAErB,IA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AW,EAAE,SAAS;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,sBAAsB,CACpB,IAAc,EACd,SAAiB,EACjB,QAAoB;QAEpB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpD,MAAM,OAAO,GAAiB,EAAE,CAAA;YAChC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBACxB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACrB,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBAClB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAA;gBAC9D,OAAO,EAAE,CAAA;YACX,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;QACF,IAAI,6BAAa,CAAC,QAAQ,CAAC,EAAE;YAC3B,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;SACjC;aAAM;YACL,OAAO,OAAO,CAAA;SACf;IACH,CAAC;IAED,sBAAsB,CAAC,IAAY,EAAE,KAAuB;QAC1D,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACpC,CAAC;CACF;AAjFD,oCAiFC","sourcesContent":["import isStream from 'is-stream'\nimport { Readable } from 'stream'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, doesNotHaveValue } from '../../value_checker'\n\nexport interface IAttachmentMedia {\n encoding: messages.AttachmentContentEncoding\n contentType: string\n}\n\nexport interface IAttachment {\n data: string\n media: IAttachmentMedia\n}\n\nexport type IAttachFunction = (attachment: IAttachment) => void\nexport type ICreateAttachment = (\n data: Buffer | Readable | string,\n mediaType?: string,\n callback?: () => void\n) => void | Promise<void>\nexport type ICreateLog = (text: string) => void | Promise<void>\n\nexport default class AttachmentManager {\n private readonly onAttachment: IAttachFunction\n\n constructor(onAttachment: IAttachFunction) {\n this.onAttachment = onAttachment\n }\n\n log(text: string): void | Promise<void> {\n return this.create(text, 'text/x.cucumber.log+plain')\n }\n\n create(\n data: Buffer | Readable | string,\n mediaType?: string,\n callback?: () => void\n ): void | Promise<void> {\n if (Buffer.isBuffer(data)) {\n if (doesNotHaveValue(mediaType)) {\n throw Error('Buffer attachments must specify a media type')\n }\n this.createBufferAttachment(data, mediaType)\n } else if (isStream.readable(data)) {\n if (doesNotHaveValue(mediaType)) {\n throw Error('Stream attachments must specify a media type')\n }\n return this.createStreamAttachment(data, mediaType, callback)\n } else if (typeof data === 'string') {\n if (doesNotHaveValue(mediaType)) {\n mediaType = 'text/plain'\n }\n if (mediaType.startsWith('base64:')) {\n this.createStringAttachment(data, {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: mediaType.replace('base64:', ''),\n })\n } else {\n this.createStringAttachment(data, {\n encoding: messages.AttachmentContentEncoding.IDENTITY,\n contentType: mediaType,\n })\n }\n } else {\n throw Error(\n 'Invalid attachment data: must be a buffer, readable stream, or string'\n )\n }\n }\n\n createBufferAttachment(data: Buffer, mediaType: string): void {\n this.createStringAttachment(data.toString('base64'), {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: mediaType,\n })\n }\n\n createStreamAttachment(\n data: Readable,\n mediaType: string,\n callback: () => void\n ): void | Promise<void> {\n const promise = new Promise<void>((resolve, reject) => {\n const buffers: Uint8Array[] = []\n data.on('data', (chunk) => {\n buffers.push(chunk)\n })\n data.on('end', () => {\n this.createBufferAttachment(Buffer.concat(buffers), mediaType)\n resolve()\n })\n data.on('error', reject)\n })\n if (doesHaveValue(callback)) {\n promise.then(callback, callback)\n } else {\n return promise\n }\n }\n\n createStringAttachment(data: string, media: IAttachmentMedia): void {\n this.onAttachment({ data, media })\n }\n}\n"]}
|
package/lib/runtime/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import StepDefinition from '../models/step_definition';
|
|
2
|
-
import
|
|
2
|
+
import * as messages from '@cucumber/messages';
|
|
3
3
|
import { IRuntimeOptions } from '.';
|
|
4
4
|
export declare function getAmbiguousStepException(stepDefinitions: StepDefinition[]): string;
|
|
5
|
-
export declare function retriesForPickle(pickle: messages.
|
|
5
|
+
export declare function retriesForPickle(pickle: messages.Pickle, options: IRuntimeOptions): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,4EAAsE;AACtE,4DAA8B;AAC9B,kEAAwC;AACxC,oDAAkD;AAKlD,SAAgB,yBAAyB,CACvC,eAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,GAAG,EAAE,EAAE;YACP,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,EAAE;YACT,WAAW,EAAE,EAAE;YACf,GAAG,EAAE,EAAE;YACP,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,EAAE;YACb,WAAW,EAAE,EAAE;SAChB;QACD,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,cAAc,EAAE,CAAC;YACjB,eAAe,EAAE,CAAC;SACnB;KACF,CAAC,CAAA;IACF,KAAK,CAAC,IAAI,CACR,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;QACxC,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAA;QACjD,OAAO,CAAC,OAAO,EAAE,iCAAc,CAAC,cAA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,QAAQ,EAAE,EAChB,CAAC,CACF,EAAE,CAAA;AACL,CAAC;AArCD,8DAqCC;AAED,SAAgB,gBAAgB,CAC9B,MAAuB,EACvB,OAAwB;IAExB,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7B,IAAI,OAAO,KAAK,CAAC,EAAE;QACjB,OAAO,CAAC,CAAA;KACT;IACD,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;IAC7C,IAAI,cAAc,KAAK,EAAE,EAAE;QACzB,OAAO,OAAO,CAAA;KACf;IACD,MAAM,eAAe,GAAG,IAAI,+BAAe,CAAC,cAAc,CAAC,CAAA;IAC3D,IAAI,eAAe,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE;QACpD,OAAO,OAAO,CAAA;KACf;IACD,OAAO,CAAC,CAAA;AACV,CAAC;AAjBD,4CAiBC","sourcesContent":["import { formatLocation } from '../formatter/helpers/location_helpers'\nimport Table from 'cli-table3'\nimport indentString from 'indent-string'\nimport { PickleTagFilter } from '../pickle_filter'\nimport StepDefinition from '../models/step_definition'\nimport * as messages from '@cucumber/messages'\nimport { IRuntimeOptions } from '.'\n\nexport function getAmbiguousStepException(\n stepDefinitions: StepDefinition[]\n): string {\n const table = new Table({\n chars: {\n bottom: '',\n 'bottom-left': '',\n 'bottom-mid': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n middle: ' - ',\n right: '',\n 'right-mid': '',\n top: '',\n 'top-left': '',\n 'top-mid': '',\n 'top-right': '',\n },\n style: {\n border: [],\n 'padding-left': 0,\n 'padding-right': 0,\n },\n })\n table.push(\n ...stepDefinitions.map((stepDefinition) => {\n const pattern = stepDefinition.pattern.toString()\n return [pattern, formatLocation(stepDefinition)]\n })\n )\n return `${'Multiple step definitions match:' + '\\n'}${indentString(\n table.toString(),\n 2\n )}`\n}\n\nexport function retriesForPickle(\n pickle: messages.Pickle,\n options: IRuntimeOptions\n): number {\n const retries = options.retry\n if (retries === 0) {\n return 0\n }\n const retryTagFilter = options.retryTagFilter\n if (retryTagFilter === '') {\n return retries\n }\n const pickleTagFilter = new PickleTagFilter(retryTagFilter)\n if (pickleTagFilter.matchesAllTagExpressions(pickle)) {\n return retries\n }\n return 0\n}\n"]}
|
package/lib/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventDataCollector } from '../formatter/helpers';
|
|
3
|
-
import { IdGenerator
|
|
3
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
4
|
+
import * as messages from '@cucumber/messages';
|
|
4
5
|
import { EventEmitter } from 'events';
|
|
5
6
|
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
6
7
|
import TestRunHookDefinition from '../models/test_run_hook_definition';
|
|
@@ -34,7 +35,7 @@ export default class Runtime {
|
|
|
34
35
|
private success;
|
|
35
36
|
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }: INewRuntimeOptions);
|
|
36
37
|
runTestRunHooks(definitions: TestRunHookDefinition[], name: string): Promise<void>;
|
|
37
|
-
|
|
38
|
+
runTestCase(pickleId: string, testCase: messages.TestCase): Promise<void>;
|
|
38
39
|
start(): Promise<boolean>;
|
|
39
|
-
shouldCauseFailure(status: messages.
|
|
40
|
+
shouldCauseFailure(status: messages.TestStepResultStatus): boolean;
|
|
40
41
|
}
|
package/lib/runtime/index.js
CHANGED
|
@@ -26,14 +26,14 @@ const lodash_1 = __importStar(require("lodash"));
|
|
|
26
26
|
const helpers_1 = require("../formatter/helpers");
|
|
27
27
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
28
28
|
const stack_trace_filter_1 = __importDefault(require("../stack_trace_filter"));
|
|
29
|
-
const status_1 = __importDefault(require("../status"));
|
|
30
29
|
const user_code_runner_1 = __importDefault(require("../user_code_runner"));
|
|
31
30
|
const verror_1 = __importDefault(require("verror"));
|
|
32
31
|
const helpers_2 = require("./helpers");
|
|
33
|
-
const
|
|
34
|
-
const
|
|
32
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
33
|
+
const test_case_runner_1 = __importDefault(require("./test_case_runner"));
|
|
35
34
|
const value_checker_1 = require("../value_checker");
|
|
36
35
|
const stopwatch_1 = require("./stopwatch");
|
|
36
|
+
const assemble_test_cases_1 = require("./assemble_test_cases");
|
|
37
37
|
class Runtime {
|
|
38
38
|
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }) {
|
|
39
39
|
this.eventBroadcaster = eventBroadcaster;
|
|
@@ -65,22 +65,23 @@ class Runtime {
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
async
|
|
68
|
+
async runTestCase(pickleId, testCase) {
|
|
69
69
|
const pickle = this.eventDataCollector.getPickle(pickleId);
|
|
70
70
|
const retries = helpers_2.retriesForPickle(pickle, this.options);
|
|
71
71
|
const skip = this.options.dryRun || (this.options.failFast && !this.success);
|
|
72
|
-
const
|
|
72
|
+
const testCaseRunner = new test_case_runner_1.default({
|
|
73
73
|
eventBroadcaster: this.eventBroadcaster,
|
|
74
74
|
stopwatch: this.stopwatch,
|
|
75
75
|
gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),
|
|
76
76
|
newId: this.newId,
|
|
77
77
|
pickle,
|
|
78
|
+
testCase,
|
|
78
79
|
retries,
|
|
79
80
|
skip,
|
|
80
81
|
supportCodeLibrary: this.supportCodeLibrary,
|
|
81
82
|
worldParameters: this.options.worldParameters,
|
|
82
83
|
});
|
|
83
|
-
const status = await
|
|
84
|
+
const status = await testCaseRunner.run();
|
|
84
85
|
if (this.shouldCauseFailure(status)) {
|
|
85
86
|
this.success = false;
|
|
86
87
|
}
|
|
@@ -89,29 +90,46 @@ class Runtime {
|
|
|
89
90
|
if (this.options.filterStacktraces) {
|
|
90
91
|
this.stackTraceFilter.filter();
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
const testRunStarted = {
|
|
93
94
|
testRunStarted: {
|
|
94
95
|
timestamp: this.stopwatch.timestamp(),
|
|
95
96
|
},
|
|
96
|
-
}
|
|
97
|
+
};
|
|
98
|
+
this.eventBroadcaster.emit('envelope', testRunStarted);
|
|
97
99
|
this.stopwatch.start();
|
|
98
100
|
await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
|
|
99
|
-
await
|
|
101
|
+
const assembledTestCases = await assemble_test_cases_1.assembleTestCases({
|
|
102
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
103
|
+
newId: this.newId,
|
|
104
|
+
pickles: this.pickleIds.map((pickleId) => this.eventDataCollector.getPickle(pickleId)),
|
|
105
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
106
|
+
});
|
|
107
|
+
await bluebird_1.default.each(this.pickleIds, async (pickleId) => {
|
|
108
|
+
await this.runTestCase(pickleId, assembledTestCases[pickleId]);
|
|
109
|
+
});
|
|
100
110
|
await this.runTestRunHooks(lodash_1.clone(this.supportCodeLibrary.afterTestRunHookDefinitions).reverse(), 'an AfterAll');
|
|
101
111
|
this.stopwatch.stop();
|
|
102
|
-
|
|
112
|
+
const testRunFinished = {
|
|
103
113
|
testRunFinished: {
|
|
104
114
|
timestamp: this.stopwatch.timestamp(),
|
|
115
|
+
success: this.success,
|
|
105
116
|
},
|
|
106
|
-
}
|
|
117
|
+
};
|
|
118
|
+
this.eventBroadcaster.emit('envelope', testRunFinished);
|
|
107
119
|
if (this.options.filterStacktraces) {
|
|
108
120
|
this.stackTraceFilter.unfilter();
|
|
109
121
|
}
|
|
110
122
|
return this.success;
|
|
111
123
|
}
|
|
112
124
|
shouldCauseFailure(status) {
|
|
113
|
-
|
|
114
|
-
|
|
125
|
+
const failureStatuses = [
|
|
126
|
+
messages.TestStepResultStatus.AMBIGUOUS,
|
|
127
|
+
messages.TestStepResultStatus.FAILED,
|
|
128
|
+
messages.TestStepResultStatus.UNDEFINED,
|
|
129
|
+
];
|
|
130
|
+
if (this.options.strict)
|
|
131
|
+
failureStatuses.push(messages.TestStepResultStatus.PENDING);
|
|
132
|
+
return lodash_1.default.includes(failureStatuses, status);
|
|
115
133
|
}
|
|
116
134
|
}
|
|
117
135
|
exports.default = Runtime;
|
package/lib/runtime/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiC;AACjC,kDAAyE;AACzE,wDAA+B;AAC/B,+EAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiC;AACjC,kDAAyE;AACzE,wDAA+B;AAC/B,+EAAoD;AACpD,2EAAgD;AAChD,oDAA2B;AAC3B,uCAA4C;AAE5C,6DAA8C;AAC9C,0EAA+C;AAI/C,oDAAgE;AAChE,2CAIoB;AACpB,+DAAyD;AAsBzD,MAAqB,OAAO;IAW1B,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,GACC;QACnB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,cAAc;YACrC,CAAC,CAAC,IAAI,uCAA2B,EAAE;YACnC,CAAC,CAAC,IAAI,gCAAoB,EAAE,CAAA;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,4BAAgB,EAAE,CAAA;QAC9C,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QA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ebird from 'bluebird'\nimport StackTraceFilter from '../stack_trace_filter'\nimport UserCodeRunner from '../user_code_runner'\nimport VError from 'verror'\nimport { retriesForPickle } from './helpers'\nimport { IdGenerator } from '@cucumber/messages'\nimport * as messages from '@cucumber/messages'\nimport TestCaseRunner from './test_case_runner'\nimport { EventEmitter } from 'events'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport {\n ITestRunStopwatch,\n PredictableTestRunStopwatch,\n RealTestRunStopwatch,\n} from './stopwatch'\nimport { assembleTestCases } from './assemble_test_cases'\n\nexport interface INewRuntimeOptions {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n newId: IdGenerator.NewId\n options: IRuntimeOptions\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IRuntimeOptions {\n dryRun: boolean\n predictableIds: boolean\n failFast: boolean\n filterStacktraces: boolean\n retry: number\n retryTagFilter: string\n strict: boolean\n worldParameters: any\n}\n\nexport default class Runtime {\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: ITestRunStopwatch\n private readonly newId: IdGenerator.NewId\n private readonly options: IRuntimeOptions\n private readonly pickleIds: string[]\n private readonly stackTraceFilter: StackTraceFilter\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private success: boolean\n\n constructor({\n eventBroadcaster,\n eventDataCollector,\n newId,\n options,\n pickleIds,\n supportCodeLibrary,\n }: INewRuntimeOptions) {\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = options.predictableIds\n ? new PredictableTestRunStopwatch()\n : new RealTestRunStopwatch()\n this.newId = newId\n this.options = options\n this.pickleIds = pickleIds\n this.stackTraceFilter = new StackTraceFilter()\n this.supportCodeLibrary = supportCodeLibrary\n this.success = true\n }\n\n async runTestRunHooks(\n definitions: TestRunHookDefinition[],\n name: string\n ): Promise<void> {\n if (this.options.dryRun) {\n return\n }\n await bluebird.each(\n definitions,\n async (hookDefinition: TestRunHookDefinition) => {\n const { error } = await UserCodeRunner.run({\n argsArray: [],\n fn: hookDefinition.code,\n thisArg: null,\n timeoutInMilliseconds: valueOrDefault(\n hookDefinition.options.timeout,\n this.supportCodeLibrary.defaultTimeout\n ),\n })\n if (doesHaveValue(error)) {\n const location = formatLocation(hookDefinition)\n throw new VError(\n error,\n `${name} hook errored, process exiting: ${location}`\n )\n }\n }\n )\n }\n\n async runTestCase(\n pickleId: string,\n testCase: messages.TestCase\n ): Promise<void> {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch: this.stopwatch,\n gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.options.worldParameters,\n })\n const status = await testCaseRunner.run()\n if (this.shouldCauseFailure(status)) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n if (this.options.filterStacktraces) {\n this.stackTraceFilter.filter()\n }\n const testRunStarted: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testRunStarted)\n this.stopwatch.start()\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n const assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n await bluebird.each(this.pickleIds, async (pickleId) => {\n await this.runTestCase(pickleId, assembledTestCases[pickleId])\n })\n await this.runTestRunHooks(\n clone(this.supportCodeLibrary.afterTestRunHookDefinitions).reverse(),\n 'an AfterAll'\n )\n this.stopwatch.stop()\n const testRunFinished: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success: this.success,\n },\n }\n this.eventBroadcaster.emit('envelope', testRunFinished)\n if (this.options.filterStacktraces) {\n this.stackTraceFilter.unfilter()\n }\n return this.success\n }\n\n shouldCauseFailure(status: messages.TestStepResultStatus): boolean {\n const failureStatuses: messages.TestStepResultStatus[] = [\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.FAILED,\n messages.TestStepResultStatus.UNDEFINED,\n ]\n if (this.options.strict)\n failureStatuses.push(messages.TestStepResultStatus.PENDING)\n return _.includes(failureStatuses, status)\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
2
|
import { IRuntimeOptions } from '../index';
|
|
3
3
|
export interface IWorkerCommand {
|
|
4
4
|
initialize?: IWorkerCommandInitialize;
|
|
@@ -9,22 +9,23 @@ export interface IWorkerCommandInitialize {
|
|
|
9
9
|
filterStacktraces: boolean;
|
|
10
10
|
supportCodePaths: string[];
|
|
11
11
|
supportCodeRequiredModules: string[];
|
|
12
|
+
supportCodeIds?: ICanonicalSupportCodeIds;
|
|
12
13
|
options: IRuntimeOptions;
|
|
13
14
|
}
|
|
15
|
+
export interface ICanonicalSupportCodeIds {
|
|
16
|
+
stepDefinitionIds: string[];
|
|
17
|
+
beforeTestCaseHookDefinitionIds: string[];
|
|
18
|
+
afterTestCaseHookDefinitionIds: string[];
|
|
19
|
+
}
|
|
14
20
|
export interface IWorkerCommandRun {
|
|
15
21
|
retries: number;
|
|
16
22
|
skip: boolean;
|
|
17
23
|
elapsed: number;
|
|
18
|
-
pickle: messages.
|
|
19
|
-
|
|
24
|
+
pickle: messages.Pickle;
|
|
25
|
+
testCase: messages.TestCase;
|
|
26
|
+
gherkinDocument: messages.GherkinDocument;
|
|
20
27
|
}
|
|
21
28
|
export interface ICoordinatorReport {
|
|
22
29
|
jsonEnvelope?: string;
|
|
23
30
|
ready?: boolean;
|
|
24
|
-
supportCodeIds?: ICoordinatorReportSupportCodeIds;
|
|
25
|
-
}
|
|
26
|
-
export interface ICoordinatorReportSupportCodeIds {
|
|
27
|
-
stepDefinitionIds: string[];
|
|
28
|
-
beforeTestCaseHookDefinitionIds: string[];
|
|
29
|
-
afterTestCaseHookDefinitionIds: string[];
|
|
30
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command_types.js","sourceRoot":"","sources":["../../../src/runtime/parallel/command_types.ts"],"names":[],"mappings":"","sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"command_types.js","sourceRoot":"","sources":["../../../src/runtime/parallel/command_types.ts"],"names":[],"mappings":"","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IRuntimeOptions } from '../index'\n\n// Messages from Coordinator to Worker\n\nexport interface IWorkerCommand {\n initialize?: IWorkerCommandInitialize\n run?: IWorkerCommandRun\n finalize?: boolean\n}\n\nexport interface IWorkerCommandInitialize {\n filterStacktraces: boolean\n supportCodePaths: string[]\n supportCodeRequiredModules: string[]\n supportCodeIds?: ICanonicalSupportCodeIds\n options: IRuntimeOptions\n}\n\nexport interface ICanonicalSupportCodeIds {\n stepDefinitionIds: string[]\n beforeTestCaseHookDefinitionIds: string[]\n afterTestCaseHookDefinitionIds: string[]\n}\n\nexport interface IWorkerCommandRun {\n retries: number\n skip: boolean\n elapsed: number\n pickle: messages.Pickle\n testCase: messages.TestCase\n gherkinDocument: messages.GherkinDocument\n}\n\n// Messages from Worker to Coordinator\n\nexport interface ICoordinatorReport {\n jsonEnvelope?: string\n ready?: boolean\n}\n"]}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ChildProcess } from 'child_process';
|
|
3
|
-
import
|
|
3
|
+
import * as messages from '@cucumber/messages';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
import { EventDataCollector } from '../../formatter/helpers';
|
|
6
6
|
import { IRuntimeOptions } from '..';
|
|
7
7
|
import { ISupportCodeLibrary } from '../../support_code_library_builder/types';
|
|
8
|
-
import { ICoordinatorReport
|
|
8
|
+
import { ICoordinatorReport } from './command_types';
|
|
9
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
9
10
|
export interface INewCoordinatorOptions {
|
|
10
11
|
cwd: string;
|
|
11
12
|
eventBroadcaster: EventEmitter;
|
|
12
13
|
eventDataCollector: EventDataCollector;
|
|
13
14
|
options: IRuntimeOptions;
|
|
15
|
+
newId: IdGenerator.NewId;
|
|
14
16
|
pickleIds: string[];
|
|
15
17
|
supportCodeLibrary: ISupportCodeLibrary;
|
|
16
18
|
supportCodePaths: string[];
|
|
@@ -28,22 +30,21 @@ export default class Coordinator {
|
|
|
28
30
|
private onFinish;
|
|
29
31
|
private nextPickleIdIndex;
|
|
30
32
|
private readonly options;
|
|
33
|
+
private readonly newId;
|
|
31
34
|
private readonly pickleIds;
|
|
35
|
+
private assembledTestCases;
|
|
32
36
|
private workers;
|
|
33
|
-
private supportCodeIdMap;
|
|
34
37
|
private readonly supportCodeLibrary;
|
|
35
38
|
private readonly supportCodePaths;
|
|
36
39
|
private readonly supportCodeRequiredModules;
|
|
37
40
|
private success;
|
|
38
|
-
constructor({ cwd, eventBroadcaster, eventDataCollector, pickleIds, options, supportCodeLibrary, supportCodePaths, supportCodeRequiredModules, }: INewCoordinatorOptions);
|
|
41
|
+
constructor({ cwd, eventBroadcaster, eventDataCollector, pickleIds, options, newId, supportCodeLibrary, supportCodePaths, supportCodeRequiredModules, }: INewCoordinatorOptions);
|
|
39
42
|
parseWorkerMessage(worker: IWorker, message: ICoordinatorReport): void;
|
|
40
|
-
saveDefinitionIdMapping(message: ICoordinatorReportSupportCodeIds): void;
|
|
41
|
-
remapDefinitionIds(testCase: messages.ITestCase): void;
|
|
42
43
|
startWorker(id: string, total: number): void;
|
|
43
44
|
onWorkerProcessClose(exitCode: number): void;
|
|
44
|
-
parseTestCaseResult(testCaseFinished: messages.
|
|
45
|
-
run(numberOfWorkers: number
|
|
45
|
+
parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void;
|
|
46
|
+
run(numberOfWorkers: number): Promise<boolean>;
|
|
46
47
|
giveWork(worker: IWorker): void;
|
|
47
|
-
shouldCauseFailure(status: messages.
|
|
48
|
+
shouldCauseFailure(status: messages.TestStepResultStatus): boolean;
|
|
48
49
|
}
|
|
49
50
|
export {};
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
23
|
};
|
|
@@ -6,14 +25,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
25
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
26
|
const child_process_1 = require("child_process");
|
|
8
27
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const status_1 = __importDefault(require("../../status"));
|
|
10
28
|
const helpers_1 = require("../helpers");
|
|
11
|
-
const
|
|
29
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
12
30
|
const value_checker_1 = require("../../value_checker");
|
|
13
31
|
const stopwatch_1 = require("../stopwatch");
|
|
32
|
+
const assemble_test_cases_1 = require("../assemble_test_cases");
|
|
14
33
|
const runWorkerPath = path_1.default.resolve(__dirname, 'run_worker.js');
|
|
15
34
|
class Coordinator {
|
|
16
|
-
constructor({ cwd, eventBroadcaster, eventDataCollector, pickleIds, options, supportCodeLibrary, supportCodePaths, supportCodeRequiredModules, }) {
|
|
35
|
+
constructor({ cwd, eventBroadcaster, eventDataCollector, pickleIds, options, newId, supportCodeLibrary, supportCodePaths, supportCodeRequiredModules, }) {
|
|
17
36
|
this.cwd = cwd;
|
|
18
37
|
this.eventBroadcaster = eventBroadcaster;
|
|
19
38
|
this.eventDataCollector = eventDataCollector;
|
|
@@ -21,6 +40,7 @@ class Coordinator {
|
|
|
21
40
|
? new stopwatch_1.PredictableTestRunStopwatch()
|
|
22
41
|
: new stopwatch_1.RealTestRunStopwatch();
|
|
23
42
|
this.options = options;
|
|
43
|
+
this.newId = newId;
|
|
24
44
|
this.supportCodeLibrary = supportCodeLibrary;
|
|
25
45
|
this.supportCodePaths = supportCodePaths;
|
|
26
46
|
this.supportCodeRequiredModules = supportCodeRequiredModules;
|
|
@@ -28,21 +48,14 @@ class Coordinator {
|
|
|
28
48
|
this.nextPickleIdIndex = 0;
|
|
29
49
|
this.success = true;
|
|
30
50
|
this.workers = {};
|
|
31
|
-
this.supportCodeIdMap = {};
|
|
32
51
|
}
|
|
33
52
|
parseWorkerMessage(worker, message) {
|
|
34
|
-
if (
|
|
35
|
-
this.saveDefinitionIdMapping(message.supportCodeIds);
|
|
36
|
-
}
|
|
37
|
-
else if (message.ready) {
|
|
53
|
+
if (message.ready) {
|
|
38
54
|
this.giveWork(worker);
|
|
39
55
|
}
|
|
40
56
|
else if (value_checker_1.doesHaveValue(message.jsonEnvelope)) {
|
|
41
|
-
const envelope =
|
|
57
|
+
const envelope = messages.parseEnvelope(message.jsonEnvelope);
|
|
42
58
|
this.eventBroadcaster.emit('envelope', envelope);
|
|
43
|
-
if (value_checker_1.doesHaveValue(envelope.testCase)) {
|
|
44
|
-
this.remapDefinitionIds(envelope.testCase);
|
|
45
|
-
}
|
|
46
59
|
if (value_checker_1.doesHaveValue(envelope.testCaseFinished)) {
|
|
47
60
|
this.parseTestCaseResult(envelope.testCaseFinished);
|
|
48
61
|
}
|
|
@@ -51,27 +64,6 @@ class Coordinator {
|
|
|
51
64
|
throw new Error(`Unexpected message from worker: ${JSON.stringify(message)}`);
|
|
52
65
|
}
|
|
53
66
|
}
|
|
54
|
-
saveDefinitionIdMapping(message) {
|
|
55
|
-
lodash_1.default.each(message.stepDefinitionIds, (id, index) => {
|
|
56
|
-
this.supportCodeIdMap[id] = this.supportCodeLibrary.stepDefinitions[index].id;
|
|
57
|
-
});
|
|
58
|
-
lodash_1.default.each(message.beforeTestCaseHookDefinitionIds, (id, index) => {
|
|
59
|
-
this.supportCodeIdMap[id] = this.supportCodeLibrary.beforeTestCaseHookDefinitions[index].id;
|
|
60
|
-
});
|
|
61
|
-
lodash_1.default.each(message.afterTestCaseHookDefinitionIds, (id, index) => {
|
|
62
|
-
this.supportCodeIdMap[id] = this.supportCodeLibrary.afterTestCaseHookDefinitions[index].id;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
remapDefinitionIds(testCase) {
|
|
66
|
-
for (const testStep of testCase.testSteps) {
|
|
67
|
-
if (testStep.hookId !== '') {
|
|
68
|
-
testStep.hookId = this.supportCodeIdMap[testStep.hookId];
|
|
69
|
-
}
|
|
70
|
-
if (value_checker_1.doesHaveValue(testStep.stepDefinitionIds)) {
|
|
71
|
-
testStep.stepDefinitionIds = testStep.stepDefinitionIds.map((id) => this.supportCodeIdMap[id]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
67
|
startWorker(id, total) {
|
|
76
68
|
const workerProcess = child_process_1.fork(runWorkerPath, [], {
|
|
77
69
|
cwd: this.cwd,
|
|
@@ -96,21 +88,29 @@ class Coordinator {
|
|
|
96
88
|
filterStacktraces: this.options.filterStacktraces,
|
|
97
89
|
supportCodePaths: this.supportCodePaths,
|
|
98
90
|
supportCodeRequiredModules: this.supportCodeRequiredModules,
|
|
91
|
+
supportCodeIds: {
|
|
92
|
+
stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map((s) => s.id),
|
|
93
|
+
beforeTestCaseHookDefinitionIds: this.supportCodeLibrary.beforeTestCaseHookDefinitions.map((h) => h.id),
|
|
94
|
+
afterTestCaseHookDefinitionIds: this.supportCodeLibrary.afterTestCaseHookDefinitions.map((h) => h.id),
|
|
95
|
+
},
|
|
99
96
|
options: this.options,
|
|
100
97
|
},
|
|
101
98
|
};
|
|
102
99
|
worker.process.send(initializeCommand);
|
|
103
100
|
}
|
|
104
101
|
onWorkerProcessClose(exitCode) {
|
|
105
|
-
|
|
102
|
+
const success = exitCode === 0;
|
|
103
|
+
if (!success) {
|
|
106
104
|
this.success = false;
|
|
107
105
|
}
|
|
108
106
|
if (lodash_1.default.every(this.workers, 'closed')) {
|
|
109
|
-
|
|
107
|
+
const envelope = {
|
|
110
108
|
testRunFinished: {
|
|
111
109
|
timestamp: this.stopwatch.timestamp(),
|
|
110
|
+
success,
|
|
112
111
|
},
|
|
113
|
-
}
|
|
112
|
+
};
|
|
113
|
+
this.eventBroadcaster.emit('envelope', envelope);
|
|
114
114
|
this.onFinish(this.success);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -121,15 +121,24 @@ class Coordinator {
|
|
|
121
121
|
this.success = false;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
run(numberOfWorkers
|
|
125
|
-
|
|
124
|
+
async run(numberOfWorkers) {
|
|
125
|
+
const envelope = {
|
|
126
126
|
testRunStarted: {
|
|
127
127
|
timestamp: this.stopwatch.timestamp(),
|
|
128
128
|
},
|
|
129
|
-
}
|
|
129
|
+
};
|
|
130
|
+
this.eventBroadcaster.emit('envelope', envelope);
|
|
130
131
|
this.stopwatch.start();
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
this.assembledTestCases = await assemble_test_cases_1.assembleTestCases({
|
|
133
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
134
|
+
newId: this.newId,
|
|
135
|
+
pickles: this.pickleIds.map((pickleId) => this.eventDataCollector.getPickle(pickleId)),
|
|
136
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
137
|
+
});
|
|
138
|
+
return await new Promise((resolve) => {
|
|
139
|
+
lodash_1.default.times(numberOfWorkers, (id) => this.startWorker(id.toString(), numberOfWorkers));
|
|
140
|
+
this.onFinish = resolve;
|
|
141
|
+
});
|
|
133
142
|
}
|
|
134
143
|
giveWork(worker) {
|
|
135
144
|
if (this.nextPickleIdIndex === this.pickleIds.length) {
|
|
@@ -140,6 +149,7 @@ class Coordinator {
|
|
|
140
149
|
const pickleId = this.pickleIds[this.nextPickleIdIndex];
|
|
141
150
|
this.nextPickleIdIndex += 1;
|
|
142
151
|
const pickle = this.eventDataCollector.getPickle(pickleId);
|
|
152
|
+
const testCase = this.assembledTestCases[pickleId];
|
|
143
153
|
const gherkinDocument = this.eventDataCollector.getGherkinDocument(pickle.uri);
|
|
144
154
|
const retries = helpers_1.retriesForPickle(pickle, this.options);
|
|
145
155
|
const skip = this.options.dryRun || (this.options.failFast && !this.success);
|
|
@@ -149,14 +159,15 @@ class Coordinator {
|
|
|
149
159
|
skip,
|
|
150
160
|
elapsed: this.stopwatch.duration().nanos(),
|
|
151
161
|
pickle,
|
|
162
|
+
testCase,
|
|
152
163
|
gherkinDocument,
|
|
153
164
|
},
|
|
154
165
|
};
|
|
155
166
|
worker.process.send(runCommand);
|
|
156
167
|
}
|
|
157
168
|
shouldCauseFailure(status) {
|
|
158
|
-
return (lodash_1.default.includes([
|
|
159
|
-
(status ===
|
|
169
|
+
return (lodash_1.default.includes(['AMBIGUOUS', 'FAILED', 'UNDEFINED'], status) ||
|
|
170
|
+
(status === 'PENDING' && this.options.strict));
|
|
160
171
|
}
|
|
161
172
|
}
|
|
162
173
|
exports.default = Coordinator;
|