@dev-blinq/cucumber-js 1.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/LICENSE +22 -0
- package/README.md +124 -0
- package/api/index.d.ts +6 -0
- package/bin/cucumber-js +3 -0
- package/bin/cucumber.js +3 -0
- package/lib/api/console_logger.d.ts +12 -0
- package/lib/api/console_logger.js +24 -0
- package/lib/api/console_logger.js.map +1 -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 +14 -0
- package/lib/api/environment.js.map +1 -0
- package/lib/api/formatters.d.ts +20 -0
- package/lib/api/formatters.js +61 -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 +12 -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 +41 -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 +30 -0
- package/lib/api/load_support.js.map +1 -0
- package/lib/api/paths.d.ts +8 -0
- package/lib/api/paths.js +102 -0
- package/lib/api/paths.js.map +1 -0
- package/lib/api/plugins.d.ts +4 -0
- package/lib/api/plugins.js +19 -0
- package/lib/api/plugins.js.map +1 -0
- package/lib/api/run_cucumber.d.ts +11 -0
- package/lib/api/run_cucumber.js +115 -0
- package/lib/api/run_cucumber.js.map +1 -0
- package/lib/api/runtime.d.ts +21 -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 +26 -0
- package/lib/api/support.js.map +1 -0
- package/lib/api/test_helpers.d.ts +3 -0
- package/lib/api/test_helpers.js +36 -0
- package/lib/api/test_helpers.js.map +1 -0
- package/lib/api/types.d.ts +175 -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 +37 -0
- package/lib/cli/helpers.js +203 -0
- package/lib/cli/helpers.js.map +1 -0
- package/lib/cli/i18n.d.ts +2 -0
- package/lib/cli/i18n.js +70 -0
- package/lib/cli/i18n.js.map +1 -0
- package/lib/cli/index.d.ts +21 -0
- package/lib/cli/index.js +59 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/cli/install_validator.d.ts +1 -0
- package/lib/cli/install_validator.js +18 -0
- package/lib/cli/install_validator.js.map +1 -0
- package/lib/cli/run.d.ts +1 -0
- package/lib/cli/run.js +44 -0
- package/lib/cli/run.js.map +1 -0
- 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/configuration/argv_parser.js +102 -0
- 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 +3 -0
- package/lib/configuration/from_file.js +85 -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 +21 -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/configuration/option_splitter.js +23 -0
- package/lib/configuration/option_splitter.js.map +1 -0
- package/lib/configuration/types.d.ts +28 -0
- package/lib/configuration/types.js +3 -0
- package/lib/configuration/types.js.map +1 -0
- package/lib/configuration/validate_configuration.d.ts +3 -0
- package/lib/configuration/validate_configuration.js +13 -0
- package/lib/configuration/validate_configuration.js.map +1 -0
- package/lib/filter_stack_trace.d.ts +3 -0
- package/lib/filter_stack_trace.js +38 -0
- package/lib/filter_stack_trace.js.map +1 -0
- package/lib/formatter/builder.d.ts +37 -0
- package/lib/formatter/builder.js +101 -0
- package/lib/formatter/builder.js.map +1 -0
- 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.d.ts +15 -0
- package/lib/formatter/get_color_fns.js +56 -0
- package/lib/formatter/get_color_fns.js.map +1 -0
- package/lib/formatter/helpers/duration_helpers.d.ts +2 -0
- package/lib/formatter/helpers/duration_helpers.js +9 -0
- package/lib/formatter/helpers/duration_helpers.js.map +1 -0
- package/lib/formatter/helpers/event_data_collector.d.ts +30 -0
- package/lib/formatter/helpers/event_data_collector.js +126 -0
- package/lib/formatter/helpers/event_data_collector.js.map +1 -0
- package/lib/formatter/helpers/formatters.d.ts +6 -0
- package/lib/formatter/helpers/formatters.js +43 -0
- package/lib/formatter/helpers/formatters.js.map +1 -0
- package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -0
- package/lib/formatter/helpers/gherkin_document_parser.js +66 -0
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -0
- package/lib/formatter/helpers/index.d.ts +10 -0
- package/lib/formatter/helpers/index.js +52 -0
- package/lib/formatter/helpers/index.js.map +1 -0
- package/lib/formatter/helpers/issue_helpers.d.ts +19 -0
- package/lib/formatter/helpers/issue_helpers.js +59 -0
- package/lib/formatter/helpers/issue_helpers.js.map +1 -0
- package/lib/formatter/helpers/keyword_type.d.ts +11 -0
- package/lib/formatter/helpers/keyword_type.js +32 -0
- package/lib/formatter/helpers/keyword_type.js.map +1 -0
- package/lib/formatter/helpers/location_helpers.d.ts +2 -0
- package/lib/formatter/helpers/location_helpers.js +17 -0
- package/lib/formatter/helpers/location_helpers.js.map +1 -0
- package/lib/formatter/helpers/pickle_parser.d.ts +17 -0
- package/lib/formatter/helpers/pickle_parser.js +28 -0
- package/lib/formatter/helpers/pickle_parser.js.map +1 -0
- package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -0
- package/lib/formatter/helpers/step_argument_formatter.js +48 -0
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -0
- package/lib/formatter/helpers/summary_helpers.d.ts +9 -0
- package/lib/formatter/helpers/summary_helpers.js +96 -0
- package/lib/formatter/helpers/summary_helpers.js.map +1 -0
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +12 -0
- package/lib/formatter/helpers/test_case_attempt_formatter.js +114 -0
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -0
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +32 -0
- package/lib/formatter/helpers/test_case_attempt_parser.js +135 -0
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -0
- package/lib/formatter/helpers/usage_helpers/index.d.ts +23 -0
- package/lib/formatter/helpers/usage_helpers/index.js +111 -0
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -0
- package/lib/formatter/html_formatter.d.ts +7 -0
- package/lib/formatter/html_formatter.js +30 -0
- package/lib/formatter/html_formatter.js.map +1 -0
- package/lib/formatter/index.d.ts +53 -0
- package/lib/formatter/index.js +21 -0
- package/lib/formatter/index.js.map +1 -0
- package/lib/formatter/json_formatter.d.ts +78 -0
- package/lib/formatter/json_formatter.js +230 -0
- package/lib/formatter/json_formatter.js.map +1 -0
- package/lib/formatter/junit_formatter.d.ts +17 -0
- package/lib/formatter/junit_formatter.js +181 -0
- package/lib/formatter/junit_formatter.js.map +1 -0
- package/lib/formatter/message_formatter.d.ts +5 -0
- package/lib/formatter/message_formatter.js +15 -0
- package/lib/formatter/message_formatter.js.map +1 -0
- package/lib/formatter/progress_bar_formatter.d.ts +18 -0
- package/lib/formatter/progress_bar_formatter.js +99 -0
- package/lib/formatter/progress_bar_formatter.js.map +1 -0
- package/lib/formatter/progress_formatter.d.ts +9 -0
- package/lib/formatter/progress_formatter.js +59 -0
- package/lib/formatter/progress_formatter.js.map +1 -0
- package/lib/formatter/rerun_formatter.d.ts +13 -0
- package/lib/formatter/rerun_formatter.js +80 -0
- package/lib/formatter/rerun_formatter.js.map +1 -0
- package/lib/formatter/snippets_formatter.d.ts +6 -0
- package/lib/formatter/snippets_formatter.js +61 -0
- package/lib/formatter/snippets_formatter.js.map +1 -0
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +20 -0
- package/lib/formatter/step_definition_snippet_builder/index.js +46 -0
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +7 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +46 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -0
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +16 -0
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +11 -0
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -0
- package/lib/formatter/summary_formatter.d.ts +14 -0
- package/lib/formatter/summary_formatter.js +68 -0
- package/lib/formatter/summary_formatter.js.map +1 -0
- package/lib/formatter/usage_formatter.d.ts +6 -0
- package/lib/formatter/usage_formatter.js +98 -0
- package/lib/formatter/usage_formatter.js.map +1 -0
- package/lib/formatter/usage_json_formatter.d.ts +7 -0
- package/lib/formatter/usage_json_formatter.js +34 -0
- package/lib/formatter/usage_json_formatter.js.map +1 -0
- package/lib/importer.js +13 -0
- package/lib/index.d.ts +58 -0
- package/lib/index.js +109 -0
- package/lib/index.js.map +1 -0
- package/lib/logger.d.ts +5 -0
- package/lib/logger.js +3 -0
- package/lib/logger.js.map +1 -0
- package/lib/models/data_table.d.ts +10 -0
- package/lib/models/data_table.js +46 -0
- package/lib/models/data_table.js.map +1 -0
- package/lib/models/definition.d.ts +55 -0
- package/lib/models/definition.js +22 -0
- package/lib/models/definition.js.map +1 -0
- package/lib/models/gherkin_step_keyword.d.ts +1 -0
- package/lib/models/gherkin_step_keyword.js +3 -0
- package/lib/models/gherkin_step_keyword.js.map +1 -0
- 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.d.ts +11 -0
- package/lib/models/step_definition.js +37 -0
- package/lib/models/step_definition.js.map +1 -0
- package/lib/models/test_case_hook_definition.d.ts +10 -0
- package/lib/models/test_case_hook_definition.js +27 -0
- package/lib/models/test_case_hook_definition.js.map +1 -0
- package/lib/models/test_run_hook_definition.d.ts +3 -0
- package/lib/models/test_run_hook_definition.js +10 -0
- package/lib/models/test_run_hook_definition.js.map +1 -0
- package/lib/models/test_step_hook_definition.d.ts +9 -0
- package/lib/models/test_step_hook_definition.js +26 -0
- package/lib/models/test_step_hook_definition.js.map +1 -0
- package/lib/pickle_filter.d.ts +42 -0
- package/lib/pickle_filter.js +99 -0
- package/lib/pickle_filter.js.map +1 -0
- package/lib/plugin/index.d.ts +2 -0
- package/lib/plugin/index.js +19 -0
- package/lib/plugin/index.js.map +1 -0
- package/lib/plugin/plugin_manager.d.ts +13 -0
- package/lib/plugin/plugin_manager.js +36 -0
- package/lib/plugin/plugin_manager.js.map +1 -0
- package/lib/plugin/types.d.ts +14 -0
- package/lib/plugin/types.js +3 -0
- package/lib/plugin/types.js.map +1 -0
- package/lib/publish/http_stream.d.ts +30 -0
- package/lib/publish/http_stream.js +112 -0
- package/lib/publish/http_stream.js.map +1 -0
- package/lib/publish/index.d.ts +2 -0
- package/lib/publish/index.js +5 -0
- package/lib/publish/index.js.map +1 -0
- package/lib/publish/publish_plugin.d.ts +2 -0
- package/lib/publish/publish_plugin.js +48 -0
- package/lib/publish/publish_plugin.js.map +1 -0
- 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 +33 -0
- package/lib/runtime/attachment_manager/index.js +119 -0
- package/lib/runtime/attachment_manager/index.js.map +1 -0
- package/lib/runtime/format_error.d.ts +2 -0
- package/lib/runtime/format_error.js +36 -0
- package/lib/runtime/format_error.js.map +1 -0
- package/lib/runtime/helpers.d.ts +6 -0
- package/lib/runtime/helpers.js +101 -0
- package/lib/runtime/helpers.js.map +1 -0
- package/lib/runtime/index.d.ts +40 -0
- package/lib/runtime/index.js +76 -0
- package/lib/runtime/index.js.map +1 -0
- package/lib/runtime/parallel/command_types.d.ts +32 -0
- package/lib/runtime/parallel/command_types.js +3 -0
- package/lib/runtime/parallel/command_types.js.map +1 -0
- package/lib/runtime/parallel/coordinator.d.ts +72 -0
- package/lib/runtime/parallel/coordinator.js +222 -0
- package/lib/runtime/parallel/coordinator.js.map +1 -0
- package/lib/runtime/parallel/run_worker.d.ts +1 -0
- package/lib/runtime/parallel/run_worker.js +29 -0
- package/lib/runtime/parallel/run_worker.js.map +1 -0
- package/lib/runtime/parallel/worker.d.ts +26 -0
- package/lib/runtime/parallel/worker.js +87 -0
- package/lib/runtime/parallel/worker.js.map +1 -0
- 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.d.ts +16 -0
- package/lib/runtime/step_runner.js +88 -0
- package/lib/runtime/step_runner.js.map +1 -0
- package/lib/runtime/stopwatch.d.ts +12 -0
- package/lib/runtime/stopwatch.js +34 -0
- package/lib/runtime/stopwatch.js.map +1 -0
- package/lib/runtime/test_case_runner.d.ts +54 -0
- package/lib/runtime/test_case_runner.js +268 -0
- package/lib/runtime/test_case_runner.js.map +1 -0
- package/lib/step_arguments.d.ts +6 -0
- package/lib/step_arguments.js +19 -0
- package/lib/step_arguments.js.map +1 -0
- package/lib/support_code_library_builder/build_parameter_type.d.ts +3 -0
- 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 +29 -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 +74 -0
- package/lib/support_code_library_builder/index.js +304 -0
- package/lib/support_code_library_builder/index.js.map +1 -0
- 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/sourced_parameter_type_registry.d.ts +7 -0
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js +19 -0
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -0
- package/lib/support_code_library_builder/types.d.ts +88 -0
- package/lib/support_code_library_builder/types.js +3 -0
- package/lib/support_code_library_builder/types.js.map +1 -0
- package/lib/support_code_library_builder/validate_arguments.d.ts +12 -0
- package/lib/support_code_library_builder/validate_arguments.js +73 -0
- package/lib/support_code_library_builder/validate_arguments.js.map +1 -0
- package/lib/support_code_library_builder/world.d.ts +18 -0
- package/lib/support_code_library_builder/world.js +11 -0
- package/lib/support_code_library_builder/world.js.map +1 -0
- package/lib/time.d.ts +18 -0
- package/lib/time.js +61 -0
- package/lib/time.js.map +1 -0
- package/lib/try_require.d.ts +7 -0
- package/lib/try_require.js +26 -0
- package/lib/try_require.js.map +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.js +3 -0
- package/lib/types/index.js.map +1 -0
- package/lib/uncaught_exception_manager.d.ts +7 -0
- package/lib/uncaught_exception_manager.js +12 -0
- package/lib/uncaught_exception_manager.js.map +1 -0
- package/lib/user_code_runner.d.ts +14 -0
- package/lib/user_code_runner.js +82 -0
- package/lib/user_code_runner.js.map +1 -0
- package/lib/value_checker.d.ts +3 -0
- package/lib/value_checker.js +19 -0
- package/lib/value_checker.js.map +1 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +6 -0
- package/lib/version.js.map +1 -0
- package/lib/wrapper.mjs +44 -0
- package/package.json +189 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;AAKA,+DAAyD;AACzD,uCAAgE;AAChE,6DAA4E;AAC5E,2CAAgD;AAChD,0EAA+C;AAyB/C,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,IAAA,kBAAM,GAAE,CAAA;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,eAAe,GAAG,IAAA,wCAAmB,EACxC,IAAI,CAAC,OAAO,CAAC,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C","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\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 { IStopwatch, create } 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: IStopwatch\n private readonly newId: IdGenerator.NewId\n private readonly options: IRuntimeOptions\n private readonly pickleIds: string[]\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 = create()\n this.newId = newId\n this.options = options\n this.pickleIds = pickleIds\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 filterStackTraces: this.options.filterStacktraces,\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 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 return this.success\n }\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
|
+
import { IRuntimeOptions } from '../index';
|
|
3
|
+
export interface IWorkerCommand {
|
|
4
|
+
initialize?: IWorkerCommandInitialize;
|
|
5
|
+
run?: IWorkerCommandRun;
|
|
6
|
+
finalize?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface IWorkerCommandInitialize {
|
|
9
|
+
filterStacktraces: boolean;
|
|
10
|
+
requireModules: string[];
|
|
11
|
+
requirePaths: string[];
|
|
12
|
+
importPaths: string[];
|
|
13
|
+
supportCodeIds?: ICanonicalSupportCodeIds;
|
|
14
|
+
options: IRuntimeOptions;
|
|
15
|
+
}
|
|
16
|
+
export interface ICanonicalSupportCodeIds {
|
|
17
|
+
stepDefinitionIds: string[];
|
|
18
|
+
beforeTestCaseHookDefinitionIds: string[];
|
|
19
|
+
afterTestCaseHookDefinitionIds: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface IWorkerCommandRun {
|
|
22
|
+
retries: number;
|
|
23
|
+
skip: boolean;
|
|
24
|
+
elapsed: messages.Duration;
|
|
25
|
+
pickle: messages.Pickle;
|
|
26
|
+
testCase: messages.TestCase;
|
|
27
|
+
gherkinDocument: messages.GherkinDocument;
|
|
28
|
+
}
|
|
29
|
+
export interface ICoordinatorReport {
|
|
30
|
+
jsonEnvelope?: string;
|
|
31
|
+
ready?: boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +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 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: messages.Duration\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"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { ChildProcess } from 'child_process';
|
|
4
|
+
import * as messages from '@cucumber/messages';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import { EventDataCollector } from '../../formatter/helpers';
|
|
7
|
+
import { IRuntime, IRuntimeOptions } from '..';
|
|
8
|
+
import { ISupportCodeLibrary } from '../../support_code_library_builder/types';
|
|
9
|
+
import { ICoordinatorReport } from './command_types';
|
|
10
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
11
|
+
import { ILogger } from '../../logger';
|
|
12
|
+
export interface INewCoordinatorOptions {
|
|
13
|
+
cwd: string;
|
|
14
|
+
logger: ILogger;
|
|
15
|
+
eventBroadcaster: EventEmitter;
|
|
16
|
+
eventDataCollector: EventDataCollector;
|
|
17
|
+
options: IRuntimeOptions;
|
|
18
|
+
newId: IdGenerator.NewId;
|
|
19
|
+
pickleIds: string[];
|
|
20
|
+
supportCodeLibrary: ISupportCodeLibrary;
|
|
21
|
+
requireModules: string[];
|
|
22
|
+
requirePaths: string[];
|
|
23
|
+
importPaths: string[];
|
|
24
|
+
numberOfWorkers: number;
|
|
25
|
+
}
|
|
26
|
+
declare const enum WorkerState {
|
|
27
|
+
'idle' = 0,
|
|
28
|
+
'closed' = 1,
|
|
29
|
+
'running' = 2,
|
|
30
|
+
'new' = 3
|
|
31
|
+
}
|
|
32
|
+
interface IWorker {
|
|
33
|
+
state: WorkerState;
|
|
34
|
+
process: ChildProcess;
|
|
35
|
+
id: string;
|
|
36
|
+
}
|
|
37
|
+
interface IPicklePlacement {
|
|
38
|
+
index: number;
|
|
39
|
+
pickle: messages.Pickle;
|
|
40
|
+
}
|
|
41
|
+
export default class Coordinator implements IRuntime {
|
|
42
|
+
private readonly cwd;
|
|
43
|
+
private readonly eventBroadcaster;
|
|
44
|
+
private readonly eventDataCollector;
|
|
45
|
+
private readonly stopwatch;
|
|
46
|
+
private onFinish;
|
|
47
|
+
private readonly options;
|
|
48
|
+
private readonly newId;
|
|
49
|
+
private readonly pickleIds;
|
|
50
|
+
private assembledTestCases;
|
|
51
|
+
private inProgressPickles;
|
|
52
|
+
private workers;
|
|
53
|
+
private readonly supportCodeLibrary;
|
|
54
|
+
private readonly requireModules;
|
|
55
|
+
private readonly requirePaths;
|
|
56
|
+
private readonly importPaths;
|
|
57
|
+
private readonly numberOfWorkers;
|
|
58
|
+
private readonly logger;
|
|
59
|
+
private success;
|
|
60
|
+
private idleInterventions;
|
|
61
|
+
constructor({ cwd, logger, eventBroadcaster, eventDataCollector, pickleIds, options, newId, supportCodeLibrary, requireModules, requirePaths, importPaths, numberOfWorkers, }: INewCoordinatorOptions);
|
|
62
|
+
parseWorkerMessage(worker: IWorker, message: ICoordinatorReport): void;
|
|
63
|
+
awakenWorkers(triggeringWorker: IWorker): void;
|
|
64
|
+
startWorker(id: string, total: number): void;
|
|
65
|
+
onWorkerProcessClose(exitCode: number): void;
|
|
66
|
+
parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void;
|
|
67
|
+
start(): Promise<boolean>;
|
|
68
|
+
nextPicklePlacement(): IPicklePlacement;
|
|
69
|
+
placementAt(index: number): IPicklePlacement;
|
|
70
|
+
giveWork(worker: IWorker, force?: boolean): void;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const child_process_1 = require("child_process");
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const helpers_1 = require("../helpers");
|
|
32
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
33
|
+
const value_checker_1 = require("../../value_checker");
|
|
34
|
+
const stopwatch_1 = require("../stopwatch");
|
|
35
|
+
const assemble_test_cases_1 = require("../assemble_test_cases");
|
|
36
|
+
const runWorkerPath = path_1.default.resolve(__dirname, 'run_worker.js');
|
|
37
|
+
class Coordinator {
|
|
38
|
+
constructor({ cwd, logger, eventBroadcaster, eventDataCollector, pickleIds, options, newId, supportCodeLibrary, requireModules, requirePaths, importPaths, numberOfWorkers, }) {
|
|
39
|
+
this.cwd = cwd;
|
|
40
|
+
this.logger = logger;
|
|
41
|
+
this.eventBroadcaster = eventBroadcaster;
|
|
42
|
+
this.eventDataCollector = eventDataCollector;
|
|
43
|
+
this.stopwatch = (0, stopwatch_1.create)();
|
|
44
|
+
this.options = options;
|
|
45
|
+
this.newId = newId;
|
|
46
|
+
this.supportCodeLibrary = supportCodeLibrary;
|
|
47
|
+
this.requireModules = requireModules;
|
|
48
|
+
this.requirePaths = requirePaths;
|
|
49
|
+
this.importPaths = importPaths;
|
|
50
|
+
this.pickleIds = Array.from(pickleIds);
|
|
51
|
+
this.numberOfWorkers = numberOfWorkers;
|
|
52
|
+
this.success = true;
|
|
53
|
+
this.workers = {};
|
|
54
|
+
this.inProgressPickles = {};
|
|
55
|
+
this.idleInterventions = 0;
|
|
56
|
+
}
|
|
57
|
+
parseWorkerMessage(worker, message) {
|
|
58
|
+
if (message.ready) {
|
|
59
|
+
worker.state = 0 /* WorkerState.idle */;
|
|
60
|
+
this.awakenWorkers(worker);
|
|
61
|
+
}
|
|
62
|
+
else if ((0, value_checker_1.doesHaveValue)(message.jsonEnvelope)) {
|
|
63
|
+
const envelope = messages.parseEnvelope(message.jsonEnvelope);
|
|
64
|
+
this.eventBroadcaster.emit('envelope', envelope);
|
|
65
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.testCaseFinished)) {
|
|
66
|
+
delete this.inProgressPickles[worker.id];
|
|
67
|
+
this.parseTestCaseResult(envelope.testCaseFinished);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error(`Unexpected message from worker: ${JSON.stringify(message)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
awakenWorkers(triggeringWorker) {
|
|
75
|
+
Object.values(this.workers).forEach((worker) => {
|
|
76
|
+
if (worker.state === 0 /* WorkerState.idle */) {
|
|
77
|
+
this.giveWork(worker);
|
|
78
|
+
}
|
|
79
|
+
return worker.state !== 0 /* WorkerState.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
|
+
}
|
|
87
|
+
startWorker(id, total) {
|
|
88
|
+
const workerProcess = (0, child_process_1.fork)(runWorkerPath, [], {
|
|
89
|
+
cwd: this.cwd,
|
|
90
|
+
env: {
|
|
91
|
+
...process.env,
|
|
92
|
+
CUCUMBER_PARALLEL: 'true',
|
|
93
|
+
CUCUMBER_TOTAL_WORKERS: total.toString(),
|
|
94
|
+
CUCUMBER_WORKER_ID: id,
|
|
95
|
+
},
|
|
96
|
+
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
97
|
+
});
|
|
98
|
+
const worker = { state: 3 /* WorkerState.new */, process: workerProcess, id };
|
|
99
|
+
this.workers[id] = worker;
|
|
100
|
+
worker.process.on('message', (message) => {
|
|
101
|
+
this.parseWorkerMessage(worker, message);
|
|
102
|
+
});
|
|
103
|
+
worker.process.on('close', (exitCode) => {
|
|
104
|
+
worker.state = 1 /* WorkerState.closed */;
|
|
105
|
+
this.onWorkerProcessClose(exitCode);
|
|
106
|
+
});
|
|
107
|
+
const initializeCommand = {
|
|
108
|
+
initialize: {
|
|
109
|
+
filterStacktraces: this.options.filterStacktraces,
|
|
110
|
+
requireModules: this.requireModules,
|
|
111
|
+
requirePaths: this.requirePaths,
|
|
112
|
+
importPaths: this.importPaths,
|
|
113
|
+
supportCodeIds: {
|
|
114
|
+
stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map((s) => s.id),
|
|
115
|
+
beforeTestCaseHookDefinitionIds: this.supportCodeLibrary.beforeTestCaseHookDefinitions.map((h) => h.id),
|
|
116
|
+
afterTestCaseHookDefinitionIds: this.supportCodeLibrary.afterTestCaseHookDefinitions.map((h) => h.id),
|
|
117
|
+
},
|
|
118
|
+
options: this.options,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
worker.process.send(initializeCommand);
|
|
122
|
+
}
|
|
123
|
+
onWorkerProcessClose(exitCode) {
|
|
124
|
+
const success = exitCode === 0;
|
|
125
|
+
if (!success) {
|
|
126
|
+
this.success = false;
|
|
127
|
+
}
|
|
128
|
+
if (Object.values(this.workers).every((x) => x.state === 1 /* WorkerState.closed */)) {
|
|
129
|
+
const envelope = {
|
|
130
|
+
testRunFinished: {
|
|
131
|
+
timestamp: this.stopwatch.timestamp(),
|
|
132
|
+
success,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
this.eventBroadcaster.emit('envelope', envelope);
|
|
136
|
+
this.onFinish(this.success);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
parseTestCaseResult(testCaseFinished) {
|
|
140
|
+
const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
|
|
141
|
+
if (!testCaseFinished.willBeRetried &&
|
|
142
|
+
(0, helpers_1.shouldCauseFailure)(worstTestStepResult.status, this.options)) {
|
|
143
|
+
this.success = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async start() {
|
|
147
|
+
const envelope = {
|
|
148
|
+
testRunStarted: {
|
|
149
|
+
timestamp: this.stopwatch.timestamp(),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
this.eventBroadcaster.emit('envelope', envelope);
|
|
153
|
+
this.stopwatch.start();
|
|
154
|
+
this.assembledTestCases = await (0, assemble_test_cases_1.assembleTestCases)({
|
|
155
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
156
|
+
newId: this.newId,
|
|
157
|
+
pickles: this.pickleIds.map((pickleId) => this.eventDataCollector.getPickle(pickleId)),
|
|
158
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
159
|
+
});
|
|
160
|
+
return await new Promise((resolve) => {
|
|
161
|
+
for (let i = 0; i < this.numberOfWorkers; i++) {
|
|
162
|
+
this.startWorker(i.toString(), this.numberOfWorkers);
|
|
163
|
+
}
|
|
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
|
+
};
|
|
170
|
+
});
|
|
171
|
+
}
|
|
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) {
|
|
189
|
+
const finalizeCommand = { finalize: true };
|
|
190
|
+
worker.state = 2 /* WorkerState.running */;
|
|
191
|
+
worker.process.send(finalizeCommand);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
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];
|
|
204
|
+
const gherkinDocument = this.eventDataCollector.getGherkinDocument(pickle.uri);
|
|
205
|
+
const retries = (0, helpers_1.retriesForPickle)(pickle, this.options);
|
|
206
|
+
const skip = this.options.dryRun || (this.options.failFast && !this.success);
|
|
207
|
+
const runCommand = {
|
|
208
|
+
run: {
|
|
209
|
+
retries,
|
|
210
|
+
skip,
|
|
211
|
+
elapsed: this.stopwatch.duration(),
|
|
212
|
+
pickle,
|
|
213
|
+
testCase,
|
|
214
|
+
gherkinDocument,
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
worker.state = 2 /* WorkerState.running */;
|
|
218
|
+
worker.process.send(runCommand);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.default = Coordinator;
|
|
222
|
+
//# sourceMappingURL=coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/runtime/parallel/coordinator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkD;AAClD,gDAAuB;AACvB,wCAAiE;AACjE,6DAA8C;AAM9C,uDAAmD;AACnD,4CAAiD;AACjD,gEAA+E;AAI/E,MAAM,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;AAmC9D,MAAqB,WAAW;IAqB9B,YAAY,EACV,GAAG,EACH,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,KAAK,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,GACQ;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAA,kBAAM,GAAE,CAAA;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;QACp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C,eAAe,CAAC,CAAA;YACpC,OAAM;SACP;QAED,MAAM,eAAe,GAAG,KAAK;YAC3B,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAE9B,IAAI,eAAe,KAAK,IAAI,EAAE;YAC5B,OAAM;SACP;QAED,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,eAAe,CAAA;QAE1D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAA;QACzC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAA;QAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACnD,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,CAChE,MAAM,CAAC,GAAG,CACX,CAAA;QACD,MAAM,OAAO,GAAG,IAAA,0BAAgB,EAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5E,MAAM,UAAU,GAAmB;YACjC,GAAG,EAAE;gBACH,OAAO;gBACP,IAAI;gBACJ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;gBAClC,MAAM;gBACN,QAAQ;gBACR,eAAe;aAChB;SACF,CAAA;QACD,MAAM,CAAC,KAAK,8BAAsB,CAAA;QAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACjC,CAAC;CACF;AApQD,8BAoQC","sourcesContent":["import { ChildProcess, fork } from 'child_process'\nimport path from 'path'\nimport { retriesForPickle, shouldCauseFailure } from '../helpers'\nimport * as messages from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../../formatter/helpers'\nimport { IRuntime, IRuntimeOptions } from '..'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { ICoordinatorReport, IWorkerCommand } from './command_types'\nimport { doesHaveValue } from '../../value_checker'\nimport { IStopwatch, create } from '../stopwatch'\nimport { assembleTestCases, IAssembledTestCases } from '../assemble_test_cases'\nimport { IdGenerator } from '@cucumber/messages'\nimport { ILogger } from '../../logger'\n\nconst runWorkerPath = path.resolve(__dirname, 'run_worker.js')\n\nexport interface INewCoordinatorOptions {\n cwd: string\n logger: ILogger\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n options: IRuntimeOptions\n newId: IdGenerator.NewId\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n numberOfWorkers: number\n}\n\nconst enum WorkerState {\n 'idle',\n 'closed',\n 'running',\n 'new',\n}\n\ninterface IWorker {\n state: WorkerState\n process: ChildProcess\n id: string\n}\n\ninterface IPicklePlacement {\n index: number\n pickle: messages.Pickle\n}\n\nexport default class Coordinator implements IRuntime {\n private readonly cwd: string\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: IStopwatch\n private onFinish: (success: boolean) => void\n private readonly options: IRuntimeOptions\n private readonly newId: IdGenerator.NewId\n private readonly pickleIds: string[]\n private assembledTestCases: IAssembledTestCases\n private inProgressPickles: Record<string, messages.Pickle>\n private workers: Record<string, IWorker>\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private readonly requireModules: string[]\n private readonly requirePaths: string[]\n private readonly importPaths: string[]\n private readonly numberOfWorkers: number\n private readonly logger: ILogger\n private success: boolean\n private idleInterventions: number\n\n constructor({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n options,\n newId,\n supportCodeLibrary,\n requireModules,\n requirePaths,\n importPaths,\n numberOfWorkers,\n }: INewCoordinatorOptions) {\n this.cwd = cwd\n this.logger = logger\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = create()\n this.options = options\n this.newId = newId\n this.supportCodeLibrary = supportCodeLibrary\n this.requireModules = requireModules\n this.requirePaths = requirePaths\n this.importPaths = importPaths\n this.pickleIds = Array.from(pickleIds)\n this.numberOfWorkers = numberOfWorkers\n this.success = true\n this.workers = {}\n this.inProgressPickles = {}\n this.idleInterventions = 0\n }\n\n parseWorkerMessage(worker: IWorker, message: ICoordinatorReport): void {\n if (message.ready) {\n worker.state = WorkerState.idle\n this.awakenWorkers(worker)\n } else if (doesHaveValue(message.jsonEnvelope)) {\n const envelope = messages.parseEnvelope(message.jsonEnvelope)\n this.eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.testCaseFinished)) {\n delete this.inProgressPickles[worker.id]\n this.parseTestCaseResult(envelope.testCaseFinished)\n }\n } else {\n throw new Error(\n `Unexpected message from worker: ${JSON.stringify(message)}`\n )\n }\n }\n\n awakenWorkers(triggeringWorker: IWorker): void {\n Object.values(this.workers).forEach((worker) => {\n if (worker.state === WorkerState.idle) {\n this.giveWork(worker)\n }\n return worker.state !== WorkerState.idle\n })\n\n if (\n Object.keys(this.inProgressPickles).length == 0 &&\n this.pickleIds.length > 0\n ) {\n this.giveWork(triggeringWorker, true)\n this.idleInterventions++\n }\n }\n\n startWorker(id: string, total: number): void {\n const workerProcess = fork(runWorkerPath, [], {\n cwd: this.cwd,\n env: {\n ...process.env,\n CUCUMBER_PARALLEL: 'true',\n CUCUMBER_TOTAL_WORKERS: total.toString(),\n CUCUMBER_WORKER_ID: id,\n },\n stdio: ['inherit', 'inherit', 'inherit', 'ipc'],\n })\n const worker = { state: WorkerState.new, process: workerProcess, id }\n this.workers[id] = worker\n worker.process.on('message', (message: ICoordinatorReport) => {\n this.parseWorkerMessage(worker, message)\n })\n worker.process.on('close', (exitCode) => {\n worker.state = WorkerState.closed\n this.onWorkerProcessClose(exitCode)\n })\n const initializeCommand: IWorkerCommand = {\n initialize: {\n filterStacktraces: this.options.filterStacktraces,\n requireModules: this.requireModules,\n requirePaths: this.requirePaths,\n importPaths: this.importPaths,\n supportCodeIds: {\n stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map(\n (s) => s.id\n ),\n beforeTestCaseHookDefinitionIds:\n this.supportCodeLibrary.beforeTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n afterTestCaseHookDefinitionIds:\n this.supportCodeLibrary.afterTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n },\n options: this.options,\n },\n }\n worker.process.send(initializeCommand)\n }\n\n onWorkerProcessClose(exitCode: number): void {\n const success = exitCode === 0\n if (!success) {\n this.success = false\n }\n\n if (\n Object.values(this.workers).every((x) => x.state === WorkerState.closed)\n ) {\n const envelope: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success,\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.onFinish(this.success)\n }\n }\n\n parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (\n !testCaseFinished.willBeRetried &&\n shouldCauseFailure(worstTestStepResult.status, this.options)\n ) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n const envelope: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.stopwatch.start()\n this.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 return await new Promise<boolean>((resolve) => {\n for (let i = 0; i < this.numberOfWorkers; i++) {\n this.startWorker(i.toString(), this.numberOfWorkers)\n }\n this.onFinish = (status) => {\n if (this.idleInterventions > 0) {\n this.logger.warn(\n `WARNING: All workers went idle ${this.idleInterventions} time(s). Consider revising handler passed to setParallelCanAssign.`\n )\n }\n\n resolve(status)\n }\n })\n }\n\n nextPicklePlacement(): IPicklePlacement {\n for (let index = 0; index < this.pickleIds.length; index++) {\n const placement = this.placementAt(index)\n if (\n this.supportCodeLibrary.parallelCanAssign(\n placement.pickle,\n Object.values(this.inProgressPickles)\n )\n ) {\n return placement\n }\n }\n\n return null\n }\n\n placementAt(index: number): IPicklePlacement {\n return {\n index,\n pickle: this.eventDataCollector.getPickle(this.pickleIds[index]),\n }\n }\n\n giveWork(worker: IWorker, force: boolean = false): void {\n if (this.pickleIds.length < 1) {\n const finalizeCommand: IWorkerCommand = { finalize: true }\n worker.state = WorkerState.running\n worker.process.send(finalizeCommand)\n return\n }\n\n const picklePlacement = force\n ? this.placementAt(0)\n : this.nextPicklePlacement()\n\n if (picklePlacement === null) {\n return\n }\n\n const { index: nextPickleIndex, pickle } = picklePlacement\n\n this.pickleIds.splice(nextPickleIndex, 1)\n this.inProgressPickles[worker.id] = pickle\n const testCase = this.assembledTestCases[pickle.id]\n const gherkinDocument = this.eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const runCommand: IWorkerCommand = {\n run: {\n retries,\n skip,\n elapsed: this.stopwatch.duration(),\n pickle,\n testCase,\n gherkinDocument,\n },\n }\n worker.state = WorkerState.running\n worker.process.send(runCommand)\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const worker_1 = __importDefault(require("./worker"));
|
|
7
|
+
const verror_1 = __importDefault(require("verror"));
|
|
8
|
+
const value_checker_1 = require("../../value_checker");
|
|
9
|
+
function run() {
|
|
10
|
+
const exit = (exitCode, error, message) => {
|
|
11
|
+
if ((0, value_checker_1.doesHaveValue)(error)) {
|
|
12
|
+
console.error(verror_1.default.fullStack(new verror_1.default(error, message))); // eslint-disable-line no-console
|
|
13
|
+
}
|
|
14
|
+
process.exit(exitCode);
|
|
15
|
+
};
|
|
16
|
+
const worker = new worker_1.default({
|
|
17
|
+
id: process.env.CUCUMBER_WORKER_ID,
|
|
18
|
+
sendMessage: (message) => process.send(message),
|
|
19
|
+
cwd: process.cwd(),
|
|
20
|
+
exit,
|
|
21
|
+
});
|
|
22
|
+
process.on('message', (m) => {
|
|
23
|
+
worker
|
|
24
|
+
.receiveMessage(m)
|
|
25
|
+
.catch((error) => exit(1, error, 'Unexpected error on worker.receiveMessage'));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
run();
|
|
29
|
+
//# sourceMappingURL=run_worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/run_worker.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,oDAA2B;AAC3B,uDAAmD;AAEnD,SAAS,GAAG;IACV,MAAM,IAAI,GAAG,CAAC,QAAgB,EAAE,KAAa,EAAE,OAAgB,EAAQ,EAAE;QACvE,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE;YACxB,OAAO,CAAC,KAAK,CAAC,gBAAM,CAAC,SAAS,CAAC,IAAI,gBAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA,CAAC,iCAAiC;SAC9F;QACD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACxB,CAAC,CAAA;IACD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC;QACxB,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;QAClC,WAAW,EAAE,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACpD,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI;KACL,CAAC,CAAA;IACF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAM,EAAQ,EAAE;QACrC,MAAM;aACH,cAAc,CAAC,CAAC,CAAC;aACjB,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE,CACtB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,2CAA2C,CAAC,CAC5D,CAAA;IACL,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,GAAG,EAAE,CAAA","sourcesContent":["import Worker from './worker'\nimport VError from 'verror'\nimport { doesHaveValue } from '../../value_checker'\n\nfunction run(): void {\n const exit = (exitCode: number, error?: Error, message?: string): void => {\n if (doesHaveValue(error)) {\n console.error(VError.fullStack(new VError(error, message))) // eslint-disable-line no-console\n }\n process.exit(exitCode)\n }\n const worker = new Worker({\n id: process.env.CUCUMBER_WORKER_ID,\n sendMessage: (message: any) => process.send(message),\n cwd: process.cwd(),\n exit,\n })\n process.on('message', (m: any): void => {\n worker\n .receiveMessage(m)\n .catch((error: Error) =>\n exit(1, error, 'Unexpected error on worker.receiveMessage')\n )\n })\n}\n\nrun()\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ICoordinatorReport, IWorkerCommand, IWorkerCommandInitialize, IWorkerCommandRun } from './command_types';
|
|
2
|
+
type IExitFunction = (exitCode: number, error?: Error, message?: string) => void;
|
|
3
|
+
type IMessageSender = (command: ICoordinatorReport) => void;
|
|
4
|
+
export default class Worker {
|
|
5
|
+
private readonly cwd;
|
|
6
|
+
private readonly exit;
|
|
7
|
+
private readonly id;
|
|
8
|
+
private readonly eventBroadcaster;
|
|
9
|
+
private filterStacktraces;
|
|
10
|
+
private readonly newId;
|
|
11
|
+
private readonly sendMessage;
|
|
12
|
+
private supportCodeLibrary;
|
|
13
|
+
private worldParameters;
|
|
14
|
+
private runTestRunHooks;
|
|
15
|
+
constructor({ cwd, exit, id, sendMessage, }: {
|
|
16
|
+
cwd: string;
|
|
17
|
+
exit: IExitFunction;
|
|
18
|
+
id: string;
|
|
19
|
+
sendMessage: IMessageSender;
|
|
20
|
+
});
|
|
21
|
+
initialize({ filterStacktraces, requireModules, requirePaths, importPaths, supportCodeIds, options, }: IWorkerCommandInitialize): Promise<void>;
|
|
22
|
+
finalize(): Promise<void>;
|
|
23
|
+
receiveMessage(message: IWorkerCommand): Promise<void>;
|
|
24
|
+
runTestCase({ gherkinDocument, pickle, testCase, elapsed, retries, skip, }: IWorkerCommandRun): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const messages_1 = require("@cucumber/messages");
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
const support_code_library_builder_1 = __importDefault(require("../../support_code_library_builder"));
|
|
10
|
+
const value_checker_1 = require("../../value_checker");
|
|
11
|
+
const run_test_run_hooks_1 = require("../run_test_run_hooks");
|
|
12
|
+
const stopwatch_1 = require("../stopwatch");
|
|
13
|
+
const test_case_runner_1 = __importDefault(require("../test_case_runner"));
|
|
14
|
+
const try_require_1 = __importDefault(require("../../try_require"));
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
|
+
const { importer } = require('../../importer');
|
|
17
|
+
const { uuid } = messages_1.IdGenerator;
|
|
18
|
+
class Worker {
|
|
19
|
+
constructor({ cwd, exit, id, sendMessage, }) {
|
|
20
|
+
this.id = id;
|
|
21
|
+
this.newId = uuid();
|
|
22
|
+
this.cwd = cwd;
|
|
23
|
+
this.exit = exit;
|
|
24
|
+
this.sendMessage = sendMessage;
|
|
25
|
+
this.eventBroadcaster = new events_1.EventEmitter();
|
|
26
|
+
this.eventBroadcaster.on('envelope', (envelope) => {
|
|
27
|
+
// assign `workerId` property only for the `testCaseStarted` message
|
|
28
|
+
if (envelope.testCaseStarted) {
|
|
29
|
+
envelope.testCaseStarted.workerId = this.id;
|
|
30
|
+
}
|
|
31
|
+
this.sendMessage({ jsonEnvelope: JSON.stringify(envelope) });
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async initialize({ filterStacktraces, requireModules, requirePaths, importPaths, supportCodeIds, options, }) {
|
|
35
|
+
support_code_library_builder_1.default.reset(this.cwd, this.newId, {
|
|
36
|
+
requireModules,
|
|
37
|
+
requirePaths,
|
|
38
|
+
importPaths,
|
|
39
|
+
});
|
|
40
|
+
requireModules.map((module) => (0, try_require_1.default)(module));
|
|
41
|
+
requirePaths.map((module) => (0, try_require_1.default)(module));
|
|
42
|
+
for (const path of importPaths) {
|
|
43
|
+
await importer((0, url_1.pathToFileURL)(path));
|
|
44
|
+
}
|
|
45
|
+
this.supportCodeLibrary = support_code_library_builder_1.default.finalize(supportCodeIds);
|
|
46
|
+
this.worldParameters = options.worldParameters;
|
|
47
|
+
this.filterStacktraces = filterStacktraces;
|
|
48
|
+
this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(options.dryRun, this.supportCodeLibrary.defaultTimeout, (name, location) => `${name} hook errored on worker ${this.id}, process exiting: ${location}`);
|
|
49
|
+
await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
|
|
50
|
+
this.sendMessage({ ready: true });
|
|
51
|
+
}
|
|
52
|
+
async finalize() {
|
|
53
|
+
await this.runTestRunHooks(this.supportCodeLibrary.afterTestRunHookDefinitions, 'an AfterAll');
|
|
54
|
+
this.exit(0);
|
|
55
|
+
}
|
|
56
|
+
async receiveMessage(message) {
|
|
57
|
+
if ((0, value_checker_1.doesHaveValue)(message.initialize)) {
|
|
58
|
+
await this.initialize(message.initialize);
|
|
59
|
+
}
|
|
60
|
+
else if (message.finalize) {
|
|
61
|
+
await this.finalize();
|
|
62
|
+
}
|
|
63
|
+
else if ((0, value_checker_1.doesHaveValue)(message.run)) {
|
|
64
|
+
await this.runTestCase(message.run);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async runTestCase({ gherkinDocument, pickle, testCase, elapsed, retries, skip, }) {
|
|
68
|
+
const stopwatch = (0, stopwatch_1.create)(elapsed);
|
|
69
|
+
const testCaseRunner = new test_case_runner_1.default({
|
|
70
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
71
|
+
stopwatch,
|
|
72
|
+
gherkinDocument,
|
|
73
|
+
newId: this.newId,
|
|
74
|
+
pickle,
|
|
75
|
+
testCase,
|
|
76
|
+
retries,
|
|
77
|
+
skip,
|
|
78
|
+
filterStackTraces: this.filterStacktraces,
|
|
79
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
80
|
+
worldParameters: this.worldParameters,
|
|
81
|
+
});
|
|
82
|
+
await testCaseRunner.run();
|
|
83
|
+
this.sendMessage({ ready: true });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.default = Worker;
|
|
87
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/worker.ts"],"names":[],"mappings":";;;;;AACA,iDAAgD;AAChD,mCAAqC;AACrC,6BAAmC;AACnC,sGAA0E;AAE1E,uDAAmD;AACnD,8DAA6E;AAC7E,4CAAqC;AACrC,2EAAgD;AAOhD,oEAA0C;AAE1C,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,sBAAW,CAAA;AAK5B,MA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AAe,EACf,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,GACc;QAClB,MAAM,SAAS,GAAG,IAAA,kBAAM,EAAC,OAAO,CAAC,CAAA;QACjC,MAAM,cAAc,GAAG,IAAI,0BAAc,CAAC;YACxC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,SAAS;YACT,eAAe;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM;YACN,QAAQ;YACR,OAAO;YACP,IAAI;YACJ,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAA;QACF,MAAM,cAAc,CAAC,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnC,CAAC;CACF;AArHD,yBAqHC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { pathToFileURL } from 'url'\nimport supportCodeLibraryBuilder from '../../support_code_library_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue } from '../../value_checker'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from '../run_test_run_hooks'\nimport { create } from '../stopwatch'\nimport TestCaseRunner from '../test_case_runner'\nimport {\n ICoordinatorReport,\n IWorkerCommand,\n IWorkerCommandInitialize,\n IWorkerCommandRun,\n} from './command_types'\nimport tryRequire from '../../try_require'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../../importer')\nconst { uuid } = IdGenerator\n\ntype IExitFunction = (exitCode: number, error?: Error, message?: string) => void\ntype IMessageSender = (command: ICoordinatorReport) => void\n\nexport default class Worker {\n private readonly cwd: string\n private readonly exit: IExitFunction\n\n private readonly id: string\n private readonly eventBroadcaster: EventEmitter\n private filterStacktraces: boolean\n private readonly newId: IdGenerator.NewId\n private readonly sendMessage: IMessageSender\n private supportCodeLibrary: ISupportCodeLibrary\n private worldParameters: any\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n cwd,\n exit,\n id,\n sendMessage,\n }: {\n cwd: string\n exit: IExitFunction\n id: string\n sendMessage: IMessageSender\n }) {\n this.id = id\n this.newId = uuid()\n this.cwd = cwd\n this.exit = exit\n this.sendMessage = sendMessage\n this.eventBroadcaster = new EventEmitter()\n this.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n // assign `workerId` property only for the `testCaseStarted` message\n if (envelope.testCaseStarted) {\n envelope.testCaseStarted.workerId = this.id\n }\n this.sendMessage({ jsonEnvelope: JSON.stringify(envelope) })\n })\n }\n\n async initialize({\n filterStacktraces,\n requireModules,\n requirePaths,\n importPaths,\n supportCodeIds,\n options,\n }: IWorkerCommandInitialize): Promise<void> {\n supportCodeLibraryBuilder.reset(this.cwd, this.newId, {\n requireModules,\n requirePaths,\n importPaths,\n })\n requireModules.map((module) => tryRequire(module))\n requirePaths.map((module) => tryRequire(module))\n for (const path of importPaths) {\n await importer(pathToFileURL(path))\n }\n this.supportCodeLibrary = supportCodeLibraryBuilder.finalize(supportCodeIds)\n\n this.worldParameters = options.worldParameters\n this.filterStacktraces = filterStacktraces\n this.runTestRunHooks = makeRunTestRunHooks(\n options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n (name, location) =>\n `${name} hook errored on worker ${this.id}, process exiting: ${location}`\n )\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n this.sendMessage({ ready: true })\n }\n\n async finalize(): Promise<void> {\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions,\n 'an AfterAll'\n )\n this.exit(0)\n }\n\n async receiveMessage(message: IWorkerCommand): Promise<void> {\n if (doesHaveValue(message.initialize)) {\n await this.initialize(message.initialize)\n } else if (message.finalize) {\n await this.finalize()\n } else if (doesHaveValue(message.run)) {\n await this.runTestCase(message.run)\n }\n }\n\n async runTestCase({\n gherkinDocument,\n pickle,\n testCase,\n elapsed,\n retries,\n skip,\n }: IWorkerCommandRun): Promise<void> {\n const stopwatch = create(elapsed)\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n filterStackTraces: this.filterStacktraces,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.worldParameters,\n })\n await testCaseRunner.run()\n this.sendMessage({ ready: true })\n }\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import TestRunHookDefinition from '../models/test_run_hook_definition';
|
|
2
|
+
export type RunsTestRunHooks = (definitions: TestRunHookDefinition[], name: string) => Promise<void>;
|
|
3
|
+
export declare const makeRunTestRunHooks: (dryRun: boolean, defaultTimeout: number, errorMessage: (name: string, location: string) => string) => RunsTestRunHooks;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeRunTestRunHooks = void 0;
|
|
7
|
+
const user_code_runner_1 = __importDefault(require("../user_code_runner"));
|
|
8
|
+
const verror_1 = __importDefault(require("verror"));
|
|
9
|
+
const helpers_1 = require("../formatter/helpers");
|
|
10
|
+
const value_checker_1 = require("../value_checker");
|
|
11
|
+
const makeRunTestRunHooks = (dryRun, defaultTimeout, errorMessage) => dryRun
|
|
12
|
+
? async () => { }
|
|
13
|
+
: async (definitions, name) => {
|
|
14
|
+
for (const hookDefinition of definitions) {
|
|
15
|
+
const { error } = await user_code_runner_1.default.run({
|
|
16
|
+
argsArray: [],
|
|
17
|
+
fn: hookDefinition.code,
|
|
18
|
+
thisArg: null,
|
|
19
|
+
timeoutInMilliseconds: (0, value_checker_1.valueOrDefault)(hookDefinition.options.timeout, defaultTimeout),
|
|
20
|
+
});
|
|
21
|
+
if ((0, value_checker_1.doesHaveValue)(error)) {
|
|
22
|
+
const location = (0, helpers_1.formatLocation)(hookDefinition);
|
|
23
|
+
throw new verror_1.default(error, errorMessage(name, location));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.makeRunTestRunHooks = makeRunTestRunHooks;
|
|
28
|
+
//# sourceMappingURL=run_test_run_hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_test_run_hooks.js","sourceRoot":"","sources":["../../src/runtime/run_test_run_hooks.ts"],"names":[],"mappings":";;;;;;AAAA,2EAAgD;AAChD,oDAA2B;AAC3B,kDAAqD;AACrD,oDAAgE;AAQzD,MAAM,mBAAmB,GAAG,CACjC,MAAe,EACf,cAAsB,EACtB,YAAwD,EACtC,EAAE,CACpB,MAAM;IACJ,CAAC,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC;IAChB,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;QAC1B,KAAK,MAAM,cAAc,IAAI,WAAW,EAAE;YACxC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,0BAAc,CAAC,GAAG,CAAC;gBACzC,SAAS,EAAE,EAAE;gBACb,EAAE,EAAE,cAAc,CAAC,IAAI;gBACvB,OAAO,EAAE,IAAI;gBACb,qBAAqB,EAAE,IAAA,8BAAc,EACnC,cAAc,CAAC,OAAO,CAAC,OAAO,EAC9B,cAAc,CACf;aACF,CAAC,CAAA;YACF,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE;gBACxB,MAAM,QAAQ,GAAG,IAAA,wBAAc,EAAC,cAAc,CAAC,CAAA;gBAC/C,MAAM,IAAI,gBAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;aACtD;SACF;IACH,CAAC,CAAA;AAvBM,QAAA,mBAAmB,uBAuBzB","sourcesContent":["import UserCodeRunner from '../user_code_runner'\nimport VError from 'verror'\nimport { formatLocation } from '../formatter/helpers'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\n\nexport type RunsTestRunHooks = (\n definitions: TestRunHookDefinition[],\n name: string\n) => Promise<void>\n\nexport const makeRunTestRunHooks = (\n dryRun: boolean,\n defaultTimeout: number,\n errorMessage: (name: string, location: string) => string\n): RunsTestRunHooks =>\n dryRun\n ? async () => {}\n : async (definitions, name) => {\n for (const hookDefinition of definitions) {\n const { error } = await UserCodeRunner.run({\n argsArray: [],\n fn: hookDefinition.code,\n thisArg: null,\n timeoutInMilliseconds: valueOrDefault(\n hookDefinition.options.timeout,\n defaultTimeout\n ),\n })\n if (doesHaveValue(error)) {\n const location = formatLocation(hookDefinition)\n throw new VError(error, errorMessage(name, location))\n }\n }\n }\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
|
+
import { ITestCaseHookParameter } from '../support_code_library_builder/types';
|
|
3
|
+
import { IDefinition } from '../models/definition';
|
|
4
|
+
export interface IRunOptions {
|
|
5
|
+
defaultTimeout: number;
|
|
6
|
+
filterStackTraces: boolean;
|
|
7
|
+
hookParameter: ITestCaseHookParameter;
|
|
8
|
+
step: messages.PickleStep;
|
|
9
|
+
stepDefinition: IDefinition;
|
|
10
|
+
world: any;
|
|
11
|
+
}
|
|
12
|
+
export declare function run({ defaultTimeout, filterStackTraces, hookParameter, step, stepDefinition, world, }: IRunOptions): Promise<messages.TestStepResult>;
|
|
13
|
+
declare const _default: {
|
|
14
|
+
run: typeof run;
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|