@cucumber/cucumber 8.0.0-rc.1 → 8.0.0
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/README.md +83 -51
- package/api/index.d.ts +6 -0
- package/lib/api/convert_configuration.d.ts +4 -0
- package/lib/api/convert_configuration.js +65 -0
- package/lib/api/convert_configuration.js.map +1 -0
- package/lib/api/environment.d.ts +2 -0
- package/lib/api/environment.js +13 -0
- package/lib/api/environment.js.map +1 -0
- package/lib/api/formatters.d.ts +16 -0
- package/lib/api/formatters.js +72 -0
- package/lib/api/formatters.js.map +1 -0
- package/lib/api/gherkin.d.ts +21 -0
- package/lib/api/gherkin.js +65 -0
- package/lib/api/gherkin.js.map +1 -0
- package/lib/api/index.d.ts +11 -0
- package/lib/api/index.js +28 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/load_configuration.d.ts +9 -0
- package/lib/api/load_configuration.js +32 -0
- package/lib/api/load_configuration.js.map +1 -0
- package/lib/api/load_sources.d.ts +9 -0
- package/lib/api/load_sources.js +53 -0
- package/lib/api/load_sources.js.map +1 -0
- package/lib/api/load_support.d.ts +10 -0
- package/lib/api/load_support.js +28 -0
- package/lib/api/load_support.js.map +1 -0
- package/lib/api/paths.d.ts +7 -0
- package/lib/api/paths.js +99 -0
- package/lib/api/paths.js.map +1 -0
- package/lib/api/run_cucumber.d.ts +11 -0
- package/lib/api/run_cucumber.js +108 -0
- package/lib/api/run_cucumber.js.map +1 -0
- package/lib/api/runtime.d.ts +20 -0
- package/lib/api/runtime.js +36 -0
- package/lib/api/runtime.js.map +1 -0
- package/lib/api/support.d.ts +9 -0
- package/lib/api/support.js +21 -0
- package/lib/api/support.js.map +1 -0
- package/lib/api/types.d.ts +168 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/api/wrapper.mjs +6 -0
- package/lib/cli/helpers.d.ts +16 -10
- package/lib/cli/helpers.js +54 -38
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/i18n.js +1 -1
- package/lib/cli/i18n.js.map +1 -1
- package/lib/cli/index.d.ts +6 -23
- package/lib/cli/index.js +38 -195
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/install_validator.js +1 -1
- package/lib/cli/install_validator.js.map +1 -1
- package/lib/cli/publish_banner.js +6 -6
- package/lib/cli/publish_banner.js.map +1 -1
- package/lib/cli/run.js +15 -7
- package/lib/cli/run.js.map +1 -1
- package/lib/cli/validate_node_engine_version.d.ts +10 -0
- package/lib/cli/validate_node_engine_version.js +24 -0
- package/lib/cli/validate_node_engine_version.js.map +1 -0
- package/lib/configuration/argv_parser.d.ts +20 -0
- package/lib/{cli → configuration}/argv_parser.js +47 -44
- package/lib/configuration/argv_parser.js.map +1 -0
- package/lib/configuration/check_schema.d.ts +2 -0
- package/lib/configuration/check_schema.js +60 -0
- package/lib/configuration/check_schema.js.map +1 -0
- package/lib/configuration/default_configuration.d.ts +2 -0
- package/lib/configuration/default_configuration.js +27 -0
- package/lib/configuration/default_configuration.js.map +1 -0
- package/lib/configuration/from_file.d.ts +2 -0
- package/lib/configuration/from_file.js +68 -0
- package/lib/configuration/from_file.js.map +1 -0
- package/lib/configuration/helpers.d.ts +1 -0
- package/lib/configuration/helpers.js +11 -0
- package/lib/configuration/helpers.js.map +1 -0
- package/lib/configuration/index.d.ts +7 -0
- package/lib/configuration/index.js +29 -0
- package/lib/configuration/index.js.map +1 -0
- package/lib/configuration/locate_file.d.ts +1 -0
- package/lib/configuration/locate_file.js +19 -0
- package/lib/configuration/locate_file.js.map +1 -0
- package/lib/configuration/merge_configurations.d.ts +2 -0
- package/lib/configuration/merge_configurations.js +48 -0
- package/lib/configuration/merge_configurations.js.map +1 -0
- package/lib/configuration/option_splitter.d.ts +3 -0
- package/lib/{cli → configuration}/option_splitter.js +4 -3
- package/lib/configuration/option_splitter.js.map +1 -0
- package/lib/configuration/types.d.ts +25 -0
- package/lib/configuration/types.js +3 -0
- package/lib/configuration/types.js.map +1 -0
- package/lib/configuration/validate_configuration.d.ts +2 -0
- package/lib/configuration/validate_configuration.js +10 -0
- package/lib/configuration/validate_configuration.js.map +1 -0
- package/lib/formatter/builder.d.ts +3 -3
- package/lib/formatter/builder.js +34 -8
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/fixtures/typescript.d.ts +2 -0
- package/lib/formatter/fixtures/typescript.js +6 -0
- package/lib/formatter/fixtures/typescript.js.map +1 -0
- package/lib/formatter/get_color_fns.js +15 -16
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.js +15 -11
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/gherkin_document_parser.js +6 -6
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/index.js +5 -1
- package/lib/formatter/helpers/index.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +2 -2
- package/lib/formatter/helpers/issue_helpers.js +4 -4
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/keyword_type.js +1 -1
- package/lib/formatter/helpers/keyword_type.js.map +1 -1
- package/lib/formatter/helpers/location_helpers.js +1 -1
- package/lib/formatter/helpers/location_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.js +1 -1
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.js +6 -2
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +2 -2
- package/lib/formatter/helpers/test_case_attempt_formatter.js +24 -19
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -2
- package/lib/formatter/helpers/test_case_attempt_parser.js +19 -15
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.d.ts +1 -2
- package/lib/formatter/helpers/usage_helpers/index.js +13 -9
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.js +4 -4
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/http_stream.js +6 -6
- package/lib/formatter/http_stream.js.map +1 -1
- package/lib/formatter/index.d.ts +14 -2
- package/lib/formatter/index.js +2 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.js +18 -14
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.js +16 -16
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.js +7 -3
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/publish.d.ts +1 -0
- package/lib/formatter/publish.js +5 -0
- package/lib/formatter/publish.js.map +1 -0
- package/lib/formatter/rerun_formatter.js +10 -6
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.js +7 -4
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.js +2 -2
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
- package/lib/formatter/summary_formatter.js +9 -9
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.js +11 -8
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.js +2 -3
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.js +13 -2
- package/lib/index.js.map +1 -1
- package/lib/models/pickle_order.d.ts +1 -0
- package/lib/models/pickle_order.js +3 -0
- package/lib/models/pickle_order.js.map +1 -0
- package/lib/models/step_definition.js +3 -3
- package/lib/models/step_definition.js.map +1 -1
- package/lib/pickle_filter.js +8 -8
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.js +1 -1
- package/lib/runtime/assemble_test_cases.js.map +1 -1
- package/lib/runtime/attachment_manager/index.js +9 -5
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/helpers.js +11 -4
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +7 -5
- package/lib/runtime/index.js +8 -27
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/command_types.d.ts +3 -2
- package/lib/runtime/parallel/command_types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +32 -11
- package/lib/runtime/parallel/coordinator.js +80 -28
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/run_worker.js +1 -1
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -4
- package/lib/runtime/parallel/worker.js +14 -37
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/run_test_run_hooks.d.ts +3 -0
- package/lib/runtime/run_test_run_hooks.js +28 -0
- package/lib/runtime/run_test_run_hooks.js.map +1 -0
- package/lib/runtime/step_runner.js +9 -5
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.js +9 -5
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.js +11 -7
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/stack_trace_filter.js +2 -2
- package/lib/stack_trace_filter.js.map +1 -1
- package/lib/step_arguments.js +2 -2
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/{build_helpers.d.ts → build_parameter_type.d.ts} +0 -2
- package/lib/support_code_library_builder/build_parameter_type.js +13 -0
- package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js +30 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
- package/lib/support_code_library_builder/index.d.ts +4 -2
- package/lib/support_code_library_builder/index.js +43 -19
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
- package/lib/support_code_library_builder/types.d.ts +9 -0
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/time.js +5 -1
- package/lib/time.js.map +1 -1
- package/lib/user_code_runner.js +4 -4
- package/lib/user_code_runner.js.map +1 -1
- package/lib/version.d.ts +1 -0
- package/lib/version.js +6 -0
- package/lib/version.js.map +1 -0
- package/lib/wrapper.mjs +5 -1
- package/package.json +72 -49
- package/lib/cli/argv_parser.d.ts +0 -50
- package/lib/cli/argv_parser.js.map +0 -1
- package/lib/cli/configuration_builder.d.ts +0 -45
- package/lib/cli/configuration_builder.js +0 -159
- package/lib/cli/configuration_builder.js.map +0 -1
- package/lib/cli/option_splitter.d.ts +0 -4
- package/lib/cli/option_splitter.js.map +0 -1
- package/lib/cli/profile_loader.d.ts +0 -7
- package/lib/cli/profile_loader.js +0 -49
- package/lib/cli/profile_loader.js.map +0 -1
- package/lib/support_code_library_builder/build_helpers.js +0 -45
- package/lib/support_code_library_builder/build_helpers.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble_test_cases.js","sourceRoot":"","sources":["../../src/runtime/assemble_test_cases.ts"],"names":[],"mappings":";;;AAKA,oDAAgD;AAWzC,KAAK,UAAU,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,kBAAkB,GACQ;IAC1B,MAAM,MAAM,GAAwB,EAAE,CAAA;IACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;QAC/B,MAAM,UAAU,GAAG,KAAK,EAAE,CAAA;QAC1B,MAAM,eAAe,GAAwB,mB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AG,CAAC,KAAK,CAAC;4BAClC,iBAAiB,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI;yBAC1C,CAAA;oBACH,CAAC,CAAC;iBACH,CAAA;YACH,CAAC,CAAC;SACH,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAY;IACpC,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,IAAA,6BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC;YACrC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACxD,CAAC,CAAC,SAAS;KACd,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { Group } from '@cucumber/cucumber-expressions'\nimport { doesHaveValue } from '../value_checker'\n\nexport declare type IAssembledTestCases = Record<string, messages.TestCase>\n\nexport interface IAssembleTestCasesOptions {\n eventBroadcaster: EventEmitter\n newId: IdGenerator.NewId\n pickles: messages.Pickle[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport async function assembleTestCases({\n eventBroadcaster,\n newId,\n pickles,\n supportCodeLibrary,\n}: IAssembleTestCasesOptions): Promise<IAssembledTestCases> {\n const result: IAssembledTestCases = {}\n for (const pickle of pickles) {\n const { id: pickleId } = pickle\n const testCaseId = newId()\n const fromBeforeHooks: messages.TestStep[] = makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const fromStepDefinitions: messages.TestStep[] = makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n })\n const fromAfterHooks: messages.TestStep[] = makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const testCase: messages.TestCase = {\n pickleId,\n id: testCaseId,\n testSteps: [\n ...fromBeforeHooks,\n ...fromStepDefinitions,\n ...fromAfterHooks,\n ],\n }\n eventBroadcaster.emit('envelope', { testCase })\n result[pickleId] = testCase\n }\n return result\n}\n\nfunction makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: ISupportCodeLibrary\n pickle: messages.Pickle\n newId: IdGenerator.NewId\n}): messages.TestStep[] {\n return supportCodeLibrary.afterTestCaseHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: ISupportCodeLibrary\n pickle: messages.Pickle\n newId: IdGenerator.NewId\n}): messages.TestStep[] {\n return supportCodeLibrary.beforeTestCaseHookDefinitions\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n}: {\n pickle: messages.Pickle\n supportCodeLibrary: ISupportCodeLibrary\n newId: () => string\n}): messages.TestStep[] {\n return pickle.steps.map((pickleStep) => {\n const stepDefinitions = supportCodeLibrary.stepDefinitions.filter(\n (stepDefinition) => stepDefinition.matchesStepName(pickleStep.text)\n )\n return {\n id: newId(),\n pickleStepId: pickleStep.id,\n stepDefinitionIds: stepDefinitions.map(\n (stepDefinition) => stepDefinition.id\n ),\n stepMatchArgumentsLists: stepDefinitions.map((stepDefinition) => {\n const result = stepDefinition.expression.match(pickleStep.text)\n return {\n stepMatchArguments: result.map((arg) => {\n return {\n group: mapArgumentGroup(arg.group),\n parameterTypeName: arg.parameterType.name,\n }\n }),\n }\n }),\n }\n })\n}\n\nfunction mapArgumentGroup(group: Group): messages.Group {\n return {\n start: group.start,\n value: group.value,\n children: doesHaveValue(group.children)\n ? group.children.map((child) => mapArgumentGroup(child))\n : undefined,\n }\n}\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -34,19 +38,19 @@ class AttachmentManager {
|
|
|
34
38
|
}
|
|
35
39
|
create(data, mediaType, callback) {
|
|
36
40
|
if (Buffer.isBuffer(data)) {
|
|
37
|
-
if (value_checker_1.doesNotHaveValue(mediaType)) {
|
|
41
|
+
if ((0, value_checker_1.doesNotHaveValue)(mediaType)) {
|
|
38
42
|
throw Error('Buffer attachments must specify a media type');
|
|
39
43
|
}
|
|
40
44
|
this.createBufferAttachment(data, mediaType);
|
|
41
45
|
}
|
|
42
46
|
else if (is_stream_1.default.readable(data)) {
|
|
43
|
-
if (value_checker_1.doesNotHaveValue(mediaType)) {
|
|
47
|
+
if ((0, value_checker_1.doesNotHaveValue)(mediaType)) {
|
|
44
48
|
throw Error('Stream attachments must specify a media type');
|
|
45
49
|
}
|
|
46
50
|
return this.createStreamAttachment(data, mediaType, callback);
|
|
47
51
|
}
|
|
48
52
|
else if (typeof data === 'string') {
|
|
49
|
-
if (value_checker_1.doesNotHaveValue(mediaType)) {
|
|
53
|
+
if ((0, value_checker_1.doesNotHaveValue)(mediaType)) {
|
|
50
54
|
mediaType = 'text/plain';
|
|
51
55
|
}
|
|
52
56
|
if (mediaType.startsWith('base64:')) {
|
|
@@ -84,7 +88,7 @@ class AttachmentManager {
|
|
|
84
88
|
});
|
|
85
89
|
data.on('error', reject);
|
|
86
90
|
});
|
|
87
|
-
if (value_checker_1.doesHaveValue(callback)) {
|
|
91
|
+
if ((0, value_checker_1.doesHaveValue)(callback)) {
|
|
88
92
|
promise.then(callback, callback);
|
|
89
93
|
}
|
|
90
94
|
else {
|
|
@@ -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,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,IAAI,IAAA,gCAAgB,EAAC,SAAS,CAAC,EAAE;gBAC/B,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAA;aAC5D;YACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;SAC7C;aAAM,IAAI,mBAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAClC,IAAI,IAAA,gCAAgB,EAAC,SAAS,CAAC,EAAE;gBAC/B,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAA;aAC5D;YACD,OAAO,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,S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AI,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,IAAA,6BAAa,EAAC,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.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -55,18 +59,21 @@ function getAmbiguousStepException(stepDefinitions) {
|
|
|
55
59
|
});
|
|
56
60
|
table.push(...stepDefinitions.map((stepDefinition) => {
|
|
57
61
|
const pattern = stepDefinition.pattern.toString();
|
|
58
|
-
return [pattern, location_helpers_1.formatLocation(stepDefinition)];
|
|
62
|
+
return [pattern, (0, location_helpers_1.formatLocation)(stepDefinition)];
|
|
59
63
|
}));
|
|
60
|
-
return `${'Multiple step definitions match:' + '\n'}${indent_string_1.default(table.toString(), 2)}`;
|
|
64
|
+
return `${'Multiple step definitions match:' + '\n'}${(0, indent_string_1.default)(table.toString(), 2)}`;
|
|
61
65
|
}
|
|
62
66
|
exports.getAmbiguousStepException = getAmbiguousStepException;
|
|
63
67
|
function retriesForPickle(pickle, options) {
|
|
68
|
+
if (!options.retry) {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
64
71
|
const retries = options.retry;
|
|
65
72
|
if (retries === 0) {
|
|
66
73
|
return 0;
|
|
67
74
|
}
|
|
68
75
|
const retryTagFilter = options.retryTagFilter;
|
|
69
|
-
if (retryTagFilter
|
|
76
|
+
if (!retryTagFilter) {
|
|
70
77
|
return retries;
|
|
71
78
|
}
|
|
72
79
|
const pickleTagFilter = new pickle_filter_1.PickleTagFilter(retryTagFilter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAsE;AACtE,4DAA8B;AAC9B,kEAAwC;AACxC,oDAAkD;AAElD,6DAA8C;AAG9C,SAAgB,yBAAyB,CACvC,eAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,KAAK,EAAE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CAAC,cAAc,CAAC,CAAA;IAC3D,IAAI,eAAe,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE;QACpD,OAAO,OAAO,CAAA;KACf;IACD,OAAO,CAAC,CAAA;AACV,CAAC;AApBD,4CAoBC;AAED,SAAgB,kBAAkB,CAChC,MAAqC,EACrC,OAAwB;IAExB,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,OAAO,KAAK,CAAA;KACb;IACD,MAAM,eAAe,GAAoC;QACvD,QAAQ,CAAC,oBAAoB,CAAC,SAAS;QACvC,QAAQ,CAAC,oBAAoB,CAAC,MAAM;QACpC,QAAQ,CAAC,oBAAoB,CAAC,SAAS;KACxC,CAAA;IACD,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KAC5D;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC;AAhBD,gDAgBC","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 if (!options.retry) {\n return 0\n }\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\nexport function shouldCauseFailure(\n status: messages.TestStepResultStatus,\n options: IRuntimeOptions\n): boolean {\n if (options.dryRun) {\n return false\n }\n const failureStatuses: messages.TestStepResultStatus[] = [\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.FAILED,\n messages.TestStepResultStatus.UNDEFINED,\n ]\n if (options.strict) {\n failureStatuses.push(messages.TestStepResultStatus.PENDING)\n }\n return failureStatuses.includes(status)\n}\n"]}
|
package/lib/runtime/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventDataCollector } from '../formatter/helpers';
|
|
3
|
-
import { IdGenerator } from '@cucumber/messages';
|
|
4
2
|
import * as messages from '@cucumber/messages';
|
|
3
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
5
4
|
import { EventEmitter } from 'events';
|
|
5
|
+
import { EventDataCollector } from '../formatter/helpers';
|
|
6
6
|
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
7
|
-
|
|
7
|
+
export interface IRuntime {
|
|
8
|
+
start: () => Promise<boolean>;
|
|
9
|
+
}
|
|
8
10
|
export interface INewRuntimeOptions {
|
|
9
11
|
eventBroadcaster: EventEmitter;
|
|
10
12
|
eventDataCollector: EventDataCollector;
|
|
@@ -22,7 +24,7 @@ export interface IRuntimeOptions {
|
|
|
22
24
|
strict: boolean;
|
|
23
25
|
worldParameters: any;
|
|
24
26
|
}
|
|
25
|
-
export default class Runtime {
|
|
27
|
+
export default class Runtime implements IRuntime {
|
|
26
28
|
private readonly eventBroadcaster;
|
|
27
29
|
private readonly eventDataCollector;
|
|
28
30
|
private readonly stopwatch;
|
|
@@ -32,8 +34,8 @@ export default class Runtime {
|
|
|
32
34
|
private readonly stackTraceFilter;
|
|
33
35
|
private readonly supportCodeLibrary;
|
|
34
36
|
private success;
|
|
37
|
+
private runTestRunHooks;
|
|
35
38
|
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }: INewRuntimeOptions);
|
|
36
|
-
runTestRunHooks(definitions: TestRunHookDefinition[], name: string): Promise<void>;
|
|
37
39
|
runTestCase(pickleId: string, testCase: messages.TestCase): Promise<void>;
|
|
38
40
|
start(): Promise<boolean>;
|
|
39
41
|
}
|
package/lib/runtime/index.js
CHANGED
|
@@ -3,15 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const helpers_1 = require("../formatter/helpers");
|
|
7
6
|
const stack_trace_filter_1 = __importDefault(require("../stack_trace_filter"));
|
|
8
|
-
const user_code_runner_1 = __importDefault(require("../user_code_runner"));
|
|
9
|
-
const verror_1 = __importDefault(require("verror"));
|
|
10
|
-
const helpers_2 = require("./helpers");
|
|
11
|
-
const test_case_runner_1 = __importDefault(require("./test_case_runner"));
|
|
12
|
-
const value_checker_1 = require("../value_checker");
|
|
13
|
-
const stopwatch_1 = require("./stopwatch");
|
|
14
7
|
const assemble_test_cases_1 = require("./assemble_test_cases");
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
9
|
+
const run_test_run_hooks_1 = require("./run_test_run_hooks");
|
|
10
|
+
const stopwatch_1 = require("./stopwatch");
|
|
11
|
+
const test_case_runner_1 = __importDefault(require("./test_case_runner"));
|
|
15
12
|
class Runtime {
|
|
16
13
|
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }) {
|
|
17
14
|
this.eventBroadcaster = eventBroadcaster;
|
|
@@ -23,27 +20,11 @@ class Runtime {
|
|
|
23
20
|
this.stackTraceFilter = new stack_trace_filter_1.default();
|
|
24
21
|
this.supportCodeLibrary = supportCodeLibrary;
|
|
25
22
|
this.success = true;
|
|
26
|
-
|
|
27
|
-
async runTestRunHooks(definitions, name) {
|
|
28
|
-
if (this.options.dryRun) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
for (const hookDefinition of definitions) {
|
|
32
|
-
const { error } = await user_code_runner_1.default.run({
|
|
33
|
-
argsArray: [],
|
|
34
|
-
fn: hookDefinition.code,
|
|
35
|
-
thisArg: null,
|
|
36
|
-
timeoutInMilliseconds: value_checker_1.valueOrDefault(hookDefinition.options.timeout, this.supportCodeLibrary.defaultTimeout),
|
|
37
|
-
});
|
|
38
|
-
if (value_checker_1.doesHaveValue(error)) {
|
|
39
|
-
const location = helpers_1.formatLocation(hookDefinition);
|
|
40
|
-
throw new verror_1.default(error, `${name} hook errored, process exiting: ${location}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
23
|
+
this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(this.options.dryRun, this.supportCodeLibrary.defaultTimeout, (name, location) => `${name} hook errored, process exiting: ${location}`);
|
|
43
24
|
}
|
|
44
25
|
async runTestCase(pickleId, testCase) {
|
|
45
26
|
const pickle = this.eventDataCollector.getPickle(pickleId);
|
|
46
|
-
const retries =
|
|
27
|
+
const retries = (0, helpers_1.retriesForPickle)(pickle, this.options);
|
|
47
28
|
const skip = this.options.dryRun || (this.options.failFast && !this.success);
|
|
48
29
|
const testCaseRunner = new test_case_runner_1.default({
|
|
49
30
|
eventBroadcaster: this.eventBroadcaster,
|
|
@@ -58,7 +39,7 @@ class Runtime {
|
|
|
58
39
|
worldParameters: this.options.worldParameters,
|
|
59
40
|
});
|
|
60
41
|
const status = await testCaseRunner.run();
|
|
61
|
-
if (
|
|
42
|
+
if ((0, helpers_1.shouldCauseFailure)(status, this.options)) {
|
|
62
43
|
this.success = false;
|
|
63
44
|
}
|
|
64
45
|
}
|
|
@@ -74,7 +55,7 @@ class Runtime {
|
|
|
74
55
|
this.eventBroadcaster.emit('envelope', testRunStarted);
|
|
75
56
|
this.stopwatch.start();
|
|
76
57
|
await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
|
|
77
|
-
const assembledTestCases = await assemble_test_cases_1.assembleTestCases({
|
|
58
|
+
const assembledTestCases = await (0, assemble_test_cases_1.assembleTestCases)({
|
|
78
59
|
eventBroadcaster: this.eventBroadcaster,
|
|
79
60
|
newId: this.newId,
|
|
80
61
|
pickles: this.pickleIds.map((pickleId) => this.eventDataCollector.getPickle(pickleId)),
|
package/lib/runtime/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;AAIA,+EAAoD;AAEpD,+DAAyD;AACzD,uCAAgE;AAChE,6DAA4E;AAC5E,2CAAqE;AACrE,0EAA+C;AAyB/C,MAAqB,OAAO;IAY1B,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,IAAI,gCAAoB,EAAE,CAAA;QAC3C,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;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C,SAAS,CAAC,SAAS,EAAE;gBACrC,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAA;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;QACvD,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;YAClC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAA;SACjC;QACD,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAxGD,0BAwGC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport StackTraceFilter from '../stack_trace_filter'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { assembleTestCases } from './assemble_test_cases'\nimport { retriesForPickle, shouldCauseFailure } from './helpers'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from './run_test_run_hooks'\nimport { ITestRunStopwatch, RealTestRunStopwatch } from './stopwatch'\nimport TestCaseRunner from './test_case_runner'\n\nexport interface IRuntime {\n start: () => Promise<boolean>\n}\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 failFast: boolean\n filterStacktraces: boolean\n retry: number\n retryTagFilter: string\n strict: boolean\n worldParameters: any\n}\n\nexport default class Runtime implements IRuntime {\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 private runTestRunHooks: RunsTestRunHooks\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 = 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 this.runTestRunHooks = makeRunTestRunHooks(\n this.options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n (name, location) => `${name} hook errored, process exiting: ${location}`\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 (shouldCauseFailure(status, this.options)) {\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 for (const pickleId of this.pickleIds) {\n await this.runTestCase(pickleId, assembledTestCases[pickleId])\n }\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).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"]}
|
|
@@ -7,8 +7,9 @@ export interface IWorkerCommand {
|
|
|
7
7
|
}
|
|
8
8
|
export interface IWorkerCommandInitialize {
|
|
9
9
|
filterStacktraces: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
requireModules: string[];
|
|
11
|
+
requirePaths: string[];
|
|
12
|
+
importPaths: string[];
|
|
12
13
|
supportCodeIds?: ICanonicalSupportCodeIds;
|
|
13
14
|
options: IRuntimeOptions;
|
|
14
15
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 requireModules: string[]\n requirePaths: string[]\n importPaths: 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"]}
|
|
@@ -3,47 +3,68 @@ import { ChildProcess } from 'child_process';
|
|
|
3
3
|
import * as messages from '@cucumber/messages';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
import { EventDataCollector } from '../../formatter/helpers';
|
|
6
|
-
import { IRuntimeOptions } from '..';
|
|
6
|
+
import { IRuntime, IRuntimeOptions } from '..';
|
|
7
7
|
import { ISupportCodeLibrary } from '../../support_code_library_builder/types';
|
|
8
8
|
import { ICoordinatorReport } from './command_types';
|
|
9
9
|
import { IdGenerator } from '@cucumber/messages';
|
|
10
10
|
export interface INewCoordinatorOptions {
|
|
11
11
|
cwd: string;
|
|
12
|
+
logger: Console;
|
|
12
13
|
eventBroadcaster: EventEmitter;
|
|
13
14
|
eventDataCollector: EventDataCollector;
|
|
14
15
|
options: IRuntimeOptions;
|
|
15
16
|
newId: IdGenerator.NewId;
|
|
16
17
|
pickleIds: string[];
|
|
17
18
|
supportCodeLibrary: ISupportCodeLibrary;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
requireModules: string[];
|
|
20
|
+
requirePaths: string[];
|
|
21
|
+
importPaths: string[];
|
|
22
|
+
numberOfWorkers: number;
|
|
23
|
+
}
|
|
24
|
+
declare const enum WorkerState {
|
|
25
|
+
'idle' = 0,
|
|
26
|
+
'closed' = 1,
|
|
27
|
+
'running' = 2,
|
|
28
|
+
'new' = 3
|
|
20
29
|
}
|
|
21
30
|
interface IWorker {
|
|
22
|
-
|
|
31
|
+
state: WorkerState;
|
|
23
32
|
process: ChildProcess;
|
|
33
|
+
id: string;
|
|
34
|
+
}
|
|
35
|
+
interface IPicklePlacement {
|
|
36
|
+
index: number;
|
|
37
|
+
pickle: messages.Pickle;
|
|
24
38
|
}
|
|
25
|
-
export default class Coordinator {
|
|
39
|
+
export default class Coordinator implements IRuntime {
|
|
26
40
|
private readonly cwd;
|
|
27
41
|
private readonly eventBroadcaster;
|
|
28
42
|
private readonly eventDataCollector;
|
|
29
43
|
private readonly stopwatch;
|
|
30
44
|
private onFinish;
|
|
31
|
-
private nextPickleIdIndex;
|
|
32
45
|
private readonly options;
|
|
33
46
|
private readonly newId;
|
|
34
47
|
private readonly pickleIds;
|
|
35
48
|
private assembledTestCases;
|
|
49
|
+
private inProgressPickles;
|
|
36
50
|
private workers;
|
|
37
51
|
private readonly supportCodeLibrary;
|
|
38
|
-
private readonly
|
|
39
|
-
private readonly
|
|
52
|
+
private readonly requireModules;
|
|
53
|
+
private readonly requirePaths;
|
|
54
|
+
private readonly importPaths;
|
|
55
|
+
private readonly numberOfWorkers;
|
|
56
|
+
private readonly logger;
|
|
40
57
|
private success;
|
|
41
|
-
|
|
58
|
+
private idleInterventions;
|
|
59
|
+
constructor({ cwd, logger, eventBroadcaster, eventDataCollector, pickleIds, options, newId, supportCodeLibrary, requireModules, requirePaths, importPaths, numberOfWorkers, }: INewCoordinatorOptions);
|
|
42
60
|
parseWorkerMessage(worker: IWorker, message: ICoordinatorReport): void;
|
|
61
|
+
awakenWorkers(triggeringWorker: IWorker): void;
|
|
43
62
|
startWorker(id: string, total: number): void;
|
|
44
63
|
onWorkerProcessClose(exitCode: number): void;
|
|
45
64
|
parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void;
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
start(): Promise<boolean>;
|
|
66
|
+
nextPicklePlacement(): IPicklePlacement;
|
|
67
|
+
placementAt(index: number): IPicklePlacement;
|
|
68
|
+
giveWork(worker: IWorker, force?: boolean): void;
|
|
48
69
|
}
|
|
49
70
|
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -31,29 +35,35 @@ const stopwatch_1 = require("../stopwatch");
|
|
|
31
35
|
const assemble_test_cases_1 = require("../assemble_test_cases");
|
|
32
36
|
const runWorkerPath = path_1.default.resolve(__dirname, 'run_worker.js');
|
|
33
37
|
class Coordinator {
|
|
34
|
-
constructor({ cwd, eventBroadcaster, eventDataCollector, pickleIds, options, newId, supportCodeLibrary,
|
|
38
|
+
constructor({ cwd, logger, eventBroadcaster, eventDataCollector, pickleIds, options, newId, supportCodeLibrary, requireModules, requirePaths, importPaths, numberOfWorkers, }) {
|
|
35
39
|
this.cwd = cwd;
|
|
40
|
+
this.logger = logger;
|
|
36
41
|
this.eventBroadcaster = eventBroadcaster;
|
|
37
42
|
this.eventDataCollector = eventDataCollector;
|
|
38
43
|
this.stopwatch = new stopwatch_1.RealTestRunStopwatch();
|
|
39
44
|
this.options = options;
|
|
40
45
|
this.newId = newId;
|
|
41
46
|
this.supportCodeLibrary = supportCodeLibrary;
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
47
|
+
this.requireModules = requireModules;
|
|
48
|
+
this.requirePaths = requirePaths;
|
|
49
|
+
this.importPaths = importPaths;
|
|
50
|
+
this.pickleIds = Array.from(pickleIds);
|
|
51
|
+
this.numberOfWorkers = numberOfWorkers;
|
|
46
52
|
this.success = true;
|
|
47
53
|
this.workers = {};
|
|
54
|
+
this.inProgressPickles = {};
|
|
55
|
+
this.idleInterventions = 0;
|
|
48
56
|
}
|
|
49
57
|
parseWorkerMessage(worker, message) {
|
|
50
58
|
if (message.ready) {
|
|
51
|
-
|
|
59
|
+
worker.state = 0 /* idle */;
|
|
60
|
+
this.awakenWorkers(worker);
|
|
52
61
|
}
|
|
53
|
-
else if (value_checker_1.doesHaveValue(message.jsonEnvelope)) {
|
|
62
|
+
else if ((0, value_checker_1.doesHaveValue)(message.jsonEnvelope)) {
|
|
54
63
|
const envelope = messages.parseEnvelope(message.jsonEnvelope);
|
|
55
64
|
this.eventBroadcaster.emit('envelope', envelope);
|
|
56
|
-
if (value_checker_1.doesHaveValue(envelope.testCaseFinished)) {
|
|
65
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.testCaseFinished)) {
|
|
66
|
+
delete this.inProgressPickles[worker.id];
|
|
57
67
|
this.parseTestCaseResult(envelope.testCaseFinished);
|
|
58
68
|
}
|
|
59
69
|
}
|
|
@@ -61,8 +71,21 @@ class Coordinator {
|
|
|
61
71
|
throw new Error(`Unexpected message from worker: ${JSON.stringify(message)}`);
|
|
62
72
|
}
|
|
63
73
|
}
|
|
74
|
+
awakenWorkers(triggeringWorker) {
|
|
75
|
+
Object.values(this.workers).forEach((worker) => {
|
|
76
|
+
if (worker.state === 0 /* idle */) {
|
|
77
|
+
this.giveWork(worker);
|
|
78
|
+
}
|
|
79
|
+
return worker.state !== 0 /* idle */;
|
|
80
|
+
});
|
|
81
|
+
if (Object.keys(this.inProgressPickles).length == 0 &&
|
|
82
|
+
this.pickleIds.length > 0) {
|
|
83
|
+
this.giveWork(triggeringWorker, true);
|
|
84
|
+
this.idleInterventions++;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
64
87
|
startWorker(id, total) {
|
|
65
|
-
const workerProcess = child_process_1.fork(runWorkerPath, [], {
|
|
88
|
+
const workerProcess = (0, child_process_1.fork)(runWorkerPath, [], {
|
|
66
89
|
cwd: this.cwd,
|
|
67
90
|
env: {
|
|
68
91
|
...process.env,
|
|
@@ -72,20 +95,21 @@ class Coordinator {
|
|
|
72
95
|
},
|
|
73
96
|
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
74
97
|
});
|
|
75
|
-
const worker = {
|
|
98
|
+
const worker = { state: 3 /* new */, process: workerProcess, id };
|
|
76
99
|
this.workers[id] = worker;
|
|
77
100
|
worker.process.on('message', (message) => {
|
|
78
101
|
this.parseWorkerMessage(worker, message);
|
|
79
102
|
});
|
|
80
103
|
worker.process.on('close', (exitCode) => {
|
|
81
|
-
worker.
|
|
104
|
+
worker.state = 1 /* closed */;
|
|
82
105
|
this.onWorkerProcessClose(exitCode);
|
|
83
106
|
});
|
|
84
107
|
const initializeCommand = {
|
|
85
108
|
initialize: {
|
|
86
109
|
filterStacktraces: this.options.filterStacktraces,
|
|
87
|
-
|
|
88
|
-
|
|
110
|
+
requireModules: this.requireModules,
|
|
111
|
+
requirePaths: this.requirePaths,
|
|
112
|
+
importPaths: this.importPaths,
|
|
89
113
|
supportCodeIds: {
|
|
90
114
|
stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map((s) => s.id),
|
|
91
115
|
beforeTestCaseHookDefinitionIds: this.supportCodeLibrary.beforeTestCaseHookDefinitions.map((h) => h.id),
|
|
@@ -101,7 +125,7 @@ class Coordinator {
|
|
|
101
125
|
if (!success) {
|
|
102
126
|
this.success = false;
|
|
103
127
|
}
|
|
104
|
-
if (Object.values(this.workers).every((x) => x.closed)) {
|
|
128
|
+
if (Object.values(this.workers).every((x) => x.state === 1 /* closed */)) {
|
|
105
129
|
const envelope = {
|
|
106
130
|
testRunFinished: {
|
|
107
131
|
timestamp: this.stopwatch.timestamp(),
|
|
@@ -115,11 +139,11 @@ class Coordinator {
|
|
|
115
139
|
parseTestCaseResult(testCaseFinished) {
|
|
116
140
|
const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
|
|
117
141
|
if (!testCaseFinished.willBeRetried &&
|
|
118
|
-
helpers_1.shouldCauseFailure(worstTestStepResult.status, this.options)) {
|
|
142
|
+
(0, helpers_1.shouldCauseFailure)(worstTestStepResult.status, this.options)) {
|
|
119
143
|
this.success = false;
|
|
120
144
|
}
|
|
121
145
|
}
|
|
122
|
-
async
|
|
146
|
+
async start() {
|
|
123
147
|
const envelope = {
|
|
124
148
|
testRunStarted: {
|
|
125
149
|
timestamp: this.stopwatch.timestamp(),
|
|
@@ -127,31 +151,58 @@ class Coordinator {
|
|
|
127
151
|
};
|
|
128
152
|
this.eventBroadcaster.emit('envelope', envelope);
|
|
129
153
|
this.stopwatch.start();
|
|
130
|
-
this.assembledTestCases = await assemble_test_cases_1.assembleTestCases({
|
|
154
|
+
this.assembledTestCases = await (0, assemble_test_cases_1.assembleTestCases)({
|
|
131
155
|
eventBroadcaster: this.eventBroadcaster,
|
|
132
156
|
newId: this.newId,
|
|
133
157
|
pickles: this.pickleIds.map((pickleId) => this.eventDataCollector.getPickle(pickleId)),
|
|
134
158
|
supportCodeLibrary: this.supportCodeLibrary,
|
|
135
159
|
});
|
|
136
160
|
return await new Promise((resolve) => {
|
|
137
|
-
for (let i = 0; i
|
|
138
|
-
this.startWorker(i.toString(), numberOfWorkers);
|
|
161
|
+
for (let i = 0; i < this.numberOfWorkers; i++) {
|
|
162
|
+
this.startWorker(i.toString(), this.numberOfWorkers);
|
|
139
163
|
}
|
|
140
|
-
this.onFinish =
|
|
164
|
+
this.onFinish = (status) => {
|
|
165
|
+
if (this.idleInterventions > 0) {
|
|
166
|
+
this.logger.warn(`WARNING: All workers went idle ${this.idleInterventions} time(s). Consider revising handler passed to setParallelCanAssign.`);
|
|
167
|
+
}
|
|
168
|
+
resolve(status);
|
|
169
|
+
};
|
|
141
170
|
});
|
|
142
171
|
}
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
nextPicklePlacement() {
|
|
173
|
+
for (let index = 0; index < this.pickleIds.length; index++) {
|
|
174
|
+
const placement = this.placementAt(index);
|
|
175
|
+
if (this.supportCodeLibrary.parallelCanAssign(placement.pickle, Object.values(this.inProgressPickles))) {
|
|
176
|
+
return placement;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
placementAt(index) {
|
|
182
|
+
return {
|
|
183
|
+
index,
|
|
184
|
+
pickle: this.eventDataCollector.getPickle(this.pickleIds[index]),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
giveWork(worker, force = false) {
|
|
188
|
+
if (this.pickleIds.length < 1) {
|
|
145
189
|
const finalizeCommand = { finalize: true };
|
|
190
|
+
worker.state = 2 /* running */;
|
|
146
191
|
worker.process.send(finalizeCommand);
|
|
147
192
|
return;
|
|
148
193
|
}
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
194
|
+
const picklePlacement = force
|
|
195
|
+
? this.placementAt(0)
|
|
196
|
+
: this.nextPicklePlacement();
|
|
197
|
+
if (picklePlacement === null) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const { index: nextPickleIndex, pickle } = picklePlacement;
|
|
201
|
+
this.pickleIds.splice(nextPickleIndex, 1);
|
|
202
|
+
this.inProgressPickles[worker.id] = pickle;
|
|
203
|
+
const testCase = this.assembledTestCases[pickle.id];
|
|
153
204
|
const gherkinDocument = this.eventDataCollector.getGherkinDocument(pickle.uri);
|
|
154
|
-
const retries = helpers_1.retriesForPickle(pickle, this.options);
|
|
205
|
+
const retries = (0, helpers_1.retriesForPickle)(pickle, this.options);
|
|
155
206
|
const skip = this.options.dryRun || (this.options.failFast && !this.success);
|
|
156
207
|
const runCommand = {
|
|
157
208
|
run: {
|
|
@@ -163,6 +214,7 @@ class Coordinator {
|
|
|
163
214
|
gherkinDocument,
|
|
164
215
|
},
|
|
165
216
|
};
|
|
217
|
+
worker.state = 2 /* running */;
|
|
166
218
|
worker.process.send(runCommand);
|
|
167
219
|
}
|
|
168
220
|
}
|