@dev-blinq/cucumber-js 1.0.0-amdocs

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.
Files changed (371) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/api/index.d.ts +6 -0
  4. package/bin/cucumber-js +3 -0
  5. package/bin/cucumber.js +3 -0
  6. package/bin/cucumber.ts +2 -0
  7. package/bin/download-install.js +167 -0
  8. package/lib/api/console_logger.d.ts +12 -0
  9. package/lib/api/console_logger.js +24 -0
  10. package/lib/api/console_logger.js.map +1 -0
  11. package/lib/api/convert_configuration.d.ts +4 -0
  12. package/lib/api/convert_configuration.js +66 -0
  13. package/lib/api/convert_configuration.js.map +1 -0
  14. package/lib/api/environment.d.ts +2 -0
  15. package/lib/api/environment.js +14 -0
  16. package/lib/api/environment.js.map +1 -0
  17. package/lib/api/formatters.d.ts +20 -0
  18. package/lib/api/formatters.js +61 -0
  19. package/lib/api/formatters.js.map +1 -0
  20. package/lib/api/gherkin.d.ts +21 -0
  21. package/lib/api/gherkin.js +146 -0
  22. package/lib/api/gherkin.js.map +1 -0
  23. package/lib/api/index.d.ts +12 -0
  24. package/lib/api/index.js +28 -0
  25. package/lib/api/index.js.map +1 -0
  26. package/lib/api/load_configuration.d.ts +9 -0
  27. package/lib/api/load_configuration.js +41 -0
  28. package/lib/api/load_configuration.js.map +1 -0
  29. package/lib/api/load_sources.d.ts +9 -0
  30. package/lib/api/load_sources.js +53 -0
  31. package/lib/api/load_sources.js.map +1 -0
  32. package/lib/api/load_support.d.ts +10 -0
  33. package/lib/api/load_support.js +30 -0
  34. package/lib/api/load_support.js.map +1 -0
  35. package/lib/api/paths.d.ts +8 -0
  36. package/lib/api/paths.js +102 -0
  37. package/lib/api/paths.js.map +1 -0
  38. package/lib/api/plugins.d.ts +4 -0
  39. package/lib/api/plugins.js +19 -0
  40. package/lib/api/plugins.js.map +1 -0
  41. package/lib/api/run_cucumber.d.ts +11 -0
  42. package/lib/api/run_cucumber.js +115 -0
  43. package/lib/api/run_cucumber.js.map +1 -0
  44. package/lib/api/runtime.d.ts +21 -0
  45. package/lib/api/runtime.js +36 -0
  46. package/lib/api/runtime.js.map +1 -0
  47. package/lib/api/support.d.ts +9 -0
  48. package/lib/api/support.js +26 -0
  49. package/lib/api/support.js.map +1 -0
  50. package/lib/api/test_helpers.d.ts +3 -0
  51. package/lib/api/test_helpers.js +36 -0
  52. package/lib/api/test_helpers.js.map +1 -0
  53. package/lib/api/types.d.ts +177 -0
  54. package/lib/api/types.js +3 -0
  55. package/lib/api/types.js.map +1 -0
  56. package/lib/api/wrapper.mjs +6 -0
  57. package/lib/cli/helpers.d.ts +39 -0
  58. package/lib/cli/helpers.js +224 -0
  59. package/lib/cli/helpers.js.map +1 -0
  60. package/lib/cli/i18n.d.ts +2 -0
  61. package/lib/cli/i18n.js +70 -0
  62. package/lib/cli/i18n.js.map +1 -0
  63. package/lib/cli/index.d.ts +21 -0
  64. package/lib/cli/index.js +64 -0
  65. package/lib/cli/index.js.map +1 -0
  66. package/lib/cli/install_validator.d.ts +1 -0
  67. package/lib/cli/install_validator.js +18 -0
  68. package/lib/cli/install_validator.js.map +1 -0
  69. package/lib/cli/run.d.ts +1 -0
  70. package/lib/cli/run.js +44 -0
  71. package/lib/cli/run.js.map +1 -0
  72. package/lib/cli/validate_node_engine_version.d.ts +10 -0
  73. package/lib/cli/validate_node_engine_version.js +24 -0
  74. package/lib/cli/validate_node_engine_version.js.map +1 -0
  75. package/lib/configuration/argv_parser.d.ts +20 -0
  76. package/lib/configuration/argv_parser.js +104 -0
  77. package/lib/configuration/argv_parser.js.map +1 -0
  78. package/lib/configuration/axios_client.d.ts +1 -0
  79. package/lib/configuration/axios_client.js +40 -0
  80. package/lib/configuration/axios_client.js.map +1 -0
  81. package/lib/configuration/check_schema.d.ts +2 -0
  82. package/lib/configuration/check_schema.js +60 -0
  83. package/lib/configuration/check_schema.js.map +1 -0
  84. package/lib/configuration/default_configuration.d.ts +2 -0
  85. package/lib/configuration/default_configuration.js +29 -0
  86. package/lib/configuration/default_configuration.js.map +1 -0
  87. package/lib/configuration/from_file.d.ts +3 -0
  88. package/lib/configuration/from_file.js +85 -0
  89. package/lib/configuration/from_file.js.map +1 -0
  90. package/lib/configuration/helpers.d.ts +1 -0
  91. package/lib/configuration/helpers.js +11 -0
  92. package/lib/configuration/helpers.js.map +1 -0
  93. package/lib/configuration/index.d.ts +7 -0
  94. package/lib/configuration/index.js +29 -0
  95. package/lib/configuration/index.js.map +1 -0
  96. package/lib/configuration/locate_file.d.ts +1 -0
  97. package/lib/configuration/locate_file.js +21 -0
  98. package/lib/configuration/locate_file.js.map +1 -0
  99. package/lib/configuration/merge_configurations.d.ts +2 -0
  100. package/lib/configuration/merge_configurations.js +48 -0
  101. package/lib/configuration/merge_configurations.js.map +1 -0
  102. package/lib/configuration/option_splitter.d.ts +3 -0
  103. package/lib/configuration/option_splitter.js +23 -0
  104. package/lib/configuration/option_splitter.js.map +1 -0
  105. package/lib/configuration/types.d.ts +30 -0
  106. package/lib/configuration/types.js +3 -0
  107. package/lib/configuration/types.js.map +1 -0
  108. package/lib/configuration/validate_configuration.d.ts +3 -0
  109. package/lib/configuration/validate_configuration.js +13 -0
  110. package/lib/configuration/validate_configuration.js.map +1 -0
  111. package/lib/filter_stack_trace.d.ts +3 -0
  112. package/lib/filter_stack_trace.js +38 -0
  113. package/lib/filter_stack_trace.js.map +1 -0
  114. package/lib/formatter/api.d.ts +2 -0
  115. package/lib/formatter/api.js +53 -0
  116. package/lib/formatter/api.js.map +1 -0
  117. package/lib/formatter/builder.d.ts +37 -0
  118. package/lib/formatter/builder.js +101 -0
  119. package/lib/formatter/builder.js.map +1 -0
  120. package/lib/formatter/bvt_analysis_formatter.d.ts +30 -0
  121. package/lib/formatter/bvt_analysis_formatter.js +334 -0
  122. package/lib/formatter/bvt_analysis_formatter.js.map +1 -0
  123. package/lib/formatter/feature_data_format.d.ts +23 -0
  124. package/lib/formatter/feature_data_format.js +182 -0
  125. package/lib/formatter/feature_data_format.js.map +1 -0
  126. package/lib/formatter/fixtures/typescript.d.ts +2 -0
  127. package/lib/formatter/fixtures/typescript.js +6 -0
  128. package/lib/formatter/fixtures/typescript.js.map +1 -0
  129. package/lib/formatter/get_color_fns.d.ts +15 -0
  130. package/lib/formatter/get_color_fns.js +56 -0
  131. package/lib/formatter/get_color_fns.js.map +1 -0
  132. package/lib/formatter/helpers/constants.d.ts +44 -0
  133. package/lib/formatter/helpers/constants.js +50 -0
  134. package/lib/formatter/helpers/constants.js.map +1 -0
  135. package/lib/formatter/helpers/duration_helpers.d.ts +2 -0
  136. package/lib/formatter/helpers/duration_helpers.js +9 -0
  137. package/lib/formatter/helpers/duration_helpers.js.map +1 -0
  138. package/lib/formatter/helpers/event_data_collector.d.ts +30 -0
  139. package/lib/formatter/helpers/event_data_collector.js +126 -0
  140. package/lib/formatter/helpers/event_data_collector.js.map +1 -0
  141. package/lib/formatter/helpers/formatters.d.ts +6 -0
  142. package/lib/formatter/helpers/formatters.js +45 -0
  143. package/lib/formatter/helpers/formatters.js.map +1 -0
  144. package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -0
  145. package/lib/formatter/helpers/gherkin_document_parser.js +66 -0
  146. package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -0
  147. package/lib/formatter/helpers/index.d.ts +10 -0
  148. package/lib/formatter/helpers/index.js +52 -0
  149. package/lib/formatter/helpers/index.js.map +1 -0
  150. package/lib/formatter/helpers/issue_helpers.d.ts +19 -0
  151. package/lib/formatter/helpers/issue_helpers.js +59 -0
  152. package/lib/formatter/helpers/issue_helpers.js.map +1 -0
  153. package/lib/formatter/helpers/keyword_type.d.ts +11 -0
  154. package/lib/formatter/helpers/keyword_type.js +32 -0
  155. package/lib/formatter/helpers/keyword_type.js.map +1 -0
  156. package/lib/formatter/helpers/location_helpers.d.ts +2 -0
  157. package/lib/formatter/helpers/location_helpers.js +17 -0
  158. package/lib/formatter/helpers/location_helpers.js.map +1 -0
  159. package/lib/formatter/helpers/pickle_parser.d.ts +17 -0
  160. package/lib/formatter/helpers/pickle_parser.js +28 -0
  161. package/lib/formatter/helpers/pickle_parser.js.map +1 -0
  162. package/lib/formatter/helpers/report_generator.d.ts +148 -0
  163. package/lib/formatter/helpers/report_generator.js +573 -0
  164. package/lib/formatter/helpers/report_generator.js.map +1 -0
  165. package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -0
  166. package/lib/formatter/helpers/step_argument_formatter.js +48 -0
  167. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -0
  168. package/lib/formatter/helpers/summary_helpers.d.ts +9 -0
  169. package/lib/formatter/helpers/summary_helpers.js +96 -0
  170. package/lib/formatter/helpers/summary_helpers.js.map +1 -0
  171. package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +12 -0
  172. package/lib/formatter/helpers/test_case_attempt_formatter.js +114 -0
  173. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -0
  174. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +32 -0
  175. package/lib/formatter/helpers/test_case_attempt_parser.js +135 -0
  176. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -0
  177. package/lib/formatter/helpers/upload_serivce.d.ts +26 -0
  178. package/lib/formatter/helpers/upload_serivce.js +237 -0
  179. package/lib/formatter/helpers/upload_serivce.js.map +1 -0
  180. package/lib/formatter/helpers/uploader.d.ts +12 -0
  181. package/lib/formatter/helpers/uploader.js +151 -0
  182. package/lib/formatter/helpers/uploader.js.map +1 -0
  183. package/lib/formatter/helpers/usage_helpers/index.d.ts +23 -0
  184. package/lib/formatter/helpers/usage_helpers/index.js +111 -0
  185. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -0
  186. package/lib/formatter/html_formatter.d.ts +7 -0
  187. package/lib/formatter/html_formatter.js +30 -0
  188. package/lib/formatter/html_formatter.js.map +1 -0
  189. package/lib/formatter/index.d.ts +53 -0
  190. package/lib/formatter/index.js +21 -0
  191. package/lib/formatter/index.js.map +1 -0
  192. package/lib/formatter/json_formatter.d.ts +78 -0
  193. package/lib/formatter/json_formatter.js +230 -0
  194. package/lib/formatter/json_formatter.js.map +1 -0
  195. package/lib/formatter/junit_formatter.d.ts +17 -0
  196. package/lib/formatter/junit_formatter.js +181 -0
  197. package/lib/formatter/junit_formatter.js.map +1 -0
  198. package/lib/formatter/message_formatter.d.ts +5 -0
  199. package/lib/formatter/message_formatter.js +15 -0
  200. package/lib/formatter/message_formatter.js.map +1 -0
  201. package/lib/formatter/progress_bar_formatter.d.ts +18 -0
  202. package/lib/formatter/progress_bar_formatter.js +99 -0
  203. package/lib/formatter/progress_bar_formatter.js.map +1 -0
  204. package/lib/formatter/progress_formatter.d.ts +9 -0
  205. package/lib/formatter/progress_formatter.js +59 -0
  206. package/lib/formatter/progress_formatter.js.map +1 -0
  207. package/lib/formatter/rerun_formatter.d.ts +13 -0
  208. package/lib/formatter/rerun_formatter.js +80 -0
  209. package/lib/formatter/rerun_formatter.js.map +1 -0
  210. package/lib/formatter/snippets_formatter.d.ts +6 -0
  211. package/lib/formatter/snippets_formatter.js +61 -0
  212. package/lib/formatter/snippets_formatter.js.map +1 -0
  213. package/lib/formatter/step_definition_snippet_builder/index.d.ts +20 -0
  214. package/lib/formatter/step_definition_snippet_builder/index.js +46 -0
  215. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -0
  216. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +7 -0
  217. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +46 -0
  218. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -0
  219. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +16 -0
  220. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +11 -0
  221. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -0
  222. package/lib/formatter/summary_formatter.d.ts +14 -0
  223. package/lib/formatter/summary_formatter.js +68 -0
  224. package/lib/formatter/summary_formatter.js.map +1 -0
  225. package/lib/formatter/usage_formatter.d.ts +6 -0
  226. package/lib/formatter/usage_formatter.js +98 -0
  227. package/lib/formatter/usage_formatter.js.map +1 -0
  228. package/lib/formatter/usage_json_formatter.d.ts +7 -0
  229. package/lib/formatter/usage_json_formatter.js +34 -0
  230. package/lib/formatter/usage_json_formatter.js.map +1 -0
  231. package/lib/importer.js +13 -0
  232. package/lib/index.d.ts +58 -0
  233. package/lib/index.js +109 -0
  234. package/lib/index.js.map +1 -0
  235. package/lib/logger.d.ts +5 -0
  236. package/lib/logger.js +3 -0
  237. package/lib/logger.js.map +1 -0
  238. package/lib/models/data_table.d.ts +10 -0
  239. package/lib/models/data_table.js +46 -0
  240. package/lib/models/data_table.js.map +1 -0
  241. package/lib/models/definition.d.ts +55 -0
  242. package/lib/models/definition.js +22 -0
  243. package/lib/models/definition.js.map +1 -0
  244. package/lib/models/gherkin_step_keyword.d.ts +1 -0
  245. package/lib/models/gherkin_step_keyword.js +3 -0
  246. package/lib/models/gherkin_step_keyword.js.map +1 -0
  247. package/lib/models/pickle_order.d.ts +1 -0
  248. package/lib/models/pickle_order.js +3 -0
  249. package/lib/models/pickle_order.js.map +1 -0
  250. package/lib/models/step_definition.d.ts +11 -0
  251. package/lib/models/step_definition.js +37 -0
  252. package/lib/models/step_definition.js.map +1 -0
  253. package/lib/models/test_case_hook_definition.d.ts +10 -0
  254. package/lib/models/test_case_hook_definition.js +27 -0
  255. package/lib/models/test_case_hook_definition.js.map +1 -0
  256. package/lib/models/test_run_hook_definition.d.ts +3 -0
  257. package/lib/models/test_run_hook_definition.js +10 -0
  258. package/lib/models/test_run_hook_definition.js.map +1 -0
  259. package/lib/models/test_step_hook_definition.d.ts +9 -0
  260. package/lib/models/test_step_hook_definition.js +26 -0
  261. package/lib/models/test_step_hook_definition.js.map +1 -0
  262. package/lib/pickle_filter.d.ts +42 -0
  263. package/lib/pickle_filter.js +99 -0
  264. package/lib/pickle_filter.js.map +1 -0
  265. package/lib/plugin/index.d.ts +2 -0
  266. package/lib/plugin/index.js +19 -0
  267. package/lib/plugin/index.js.map +1 -0
  268. package/lib/plugin/plugin_manager.d.ts +13 -0
  269. package/lib/plugin/plugin_manager.js +36 -0
  270. package/lib/plugin/plugin_manager.js.map +1 -0
  271. package/lib/plugin/types.d.ts +14 -0
  272. package/lib/plugin/types.js +3 -0
  273. package/lib/plugin/types.js.map +1 -0
  274. package/lib/publish/http_stream.d.ts +30 -0
  275. package/lib/publish/http_stream.js +112 -0
  276. package/lib/publish/http_stream.js.map +1 -0
  277. package/lib/publish/index.d.ts +2 -0
  278. package/lib/publish/index.js +5 -0
  279. package/lib/publish/index.js.map +1 -0
  280. package/lib/publish/publish_plugin.d.ts +2 -0
  281. package/lib/publish/publish_plugin.js +48 -0
  282. package/lib/publish/publish_plugin.js.map +1 -0
  283. package/lib/runtime/assemble_test_cases.d.ts +13 -0
  284. package/lib/runtime/assemble_test_cases.js +88 -0
  285. package/lib/runtime/assemble_test_cases.js.map +1 -0
  286. package/lib/runtime/attachment_manager/index.d.ts +33 -0
  287. package/lib/runtime/attachment_manager/index.js +119 -0
  288. package/lib/runtime/attachment_manager/index.js.map +1 -0
  289. package/lib/runtime/format_error.d.ts +2 -0
  290. package/lib/runtime/format_error.js +36 -0
  291. package/lib/runtime/format_error.js.map +1 -0
  292. package/lib/runtime/helpers.d.ts +6 -0
  293. package/lib/runtime/helpers.js +101 -0
  294. package/lib/runtime/helpers.js.map +1 -0
  295. package/lib/runtime/index.d.ts +40 -0
  296. package/lib/runtime/index.js +76 -0
  297. package/lib/runtime/index.js.map +1 -0
  298. package/lib/runtime/parallel/command_types.d.ts +32 -0
  299. package/lib/runtime/parallel/command_types.js +3 -0
  300. package/lib/runtime/parallel/command_types.js.map +1 -0
  301. package/lib/runtime/parallel/coordinator.d.ts +72 -0
  302. package/lib/runtime/parallel/coordinator.js +222 -0
  303. package/lib/runtime/parallel/coordinator.js.map +1 -0
  304. package/lib/runtime/parallel/run_worker.d.ts +1 -0
  305. package/lib/runtime/parallel/run_worker.js +29 -0
  306. package/lib/runtime/parallel/run_worker.js.map +1 -0
  307. package/lib/runtime/parallel/worker.d.ts +26 -0
  308. package/lib/runtime/parallel/worker.js +87 -0
  309. package/lib/runtime/parallel/worker.js.map +1 -0
  310. package/lib/runtime/run_test_run_hooks.d.ts +3 -0
  311. package/lib/runtime/run_test_run_hooks.js +28 -0
  312. package/lib/runtime/run_test_run_hooks.js.map +1 -0
  313. package/lib/runtime/step_runner.d.ts +16 -0
  314. package/lib/runtime/step_runner.js +88 -0
  315. package/lib/runtime/step_runner.js.map +1 -0
  316. package/lib/runtime/stopwatch.d.ts +12 -0
  317. package/lib/runtime/stopwatch.js +34 -0
  318. package/lib/runtime/stopwatch.js.map +1 -0
  319. package/lib/runtime/test_case_runner.d.ts +55 -0
  320. package/lib/runtime/test_case_runner.js +277 -0
  321. package/lib/runtime/test_case_runner.js.map +1 -0
  322. package/lib/step_arguments.d.ts +6 -0
  323. package/lib/step_arguments.js +19 -0
  324. package/lib/step_arguments.js.map +1 -0
  325. package/lib/support_code_library_builder/build_parameter_type.d.ts +3 -0
  326. package/lib/support_code_library_builder/build_parameter_type.js +13 -0
  327. package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
  328. package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
  329. package/lib/support_code_library_builder/get_definition_line_and_uri.js +29 -0
  330. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
  331. package/lib/support_code_library_builder/index.d.ts +74 -0
  332. package/lib/support_code_library_builder/index.js +304 -0
  333. package/lib/support_code_library_builder/index.js.map +1 -0
  334. package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
  335. package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
  336. package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
  337. package/lib/support_code_library_builder/sourced_parameter_type_registry.d.ts +7 -0
  338. package/lib/support_code_library_builder/sourced_parameter_type_registry.js +19 -0
  339. package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -0
  340. package/lib/support_code_library_builder/types.d.ts +88 -0
  341. package/lib/support_code_library_builder/types.js +3 -0
  342. package/lib/support_code_library_builder/types.js.map +1 -0
  343. package/lib/support_code_library_builder/validate_arguments.d.ts +12 -0
  344. package/lib/support_code_library_builder/validate_arguments.js +73 -0
  345. package/lib/support_code_library_builder/validate_arguments.js.map +1 -0
  346. package/lib/support_code_library_builder/world.d.ts +18 -0
  347. package/lib/support_code_library_builder/world.js +11 -0
  348. package/lib/support_code_library_builder/world.js.map +1 -0
  349. package/lib/time.d.ts +18 -0
  350. package/lib/time.js +61 -0
  351. package/lib/time.js.map +1 -0
  352. package/lib/try_require.d.ts +7 -0
  353. package/lib/try_require.js +26 -0
  354. package/lib/try_require.js.map +1 -0
  355. package/lib/types/index.d.ts +4 -0
  356. package/lib/types/index.js +3 -0
  357. package/lib/types/index.js.map +1 -0
  358. package/lib/uncaught_exception_manager.d.ts +7 -0
  359. package/lib/uncaught_exception_manager.js +12 -0
  360. package/lib/uncaught_exception_manager.js.map +1 -0
  361. package/lib/user_code_runner.d.ts +14 -0
  362. package/lib/user_code_runner.js +82 -0
  363. package/lib/user_code_runner.js.map +1 -0
  364. package/lib/value_checker.d.ts +3 -0
  365. package/lib/value_checker.js +19 -0
  366. package/lib/value_checker.js.map +1 -0
  367. package/lib/version.d.ts +1 -0
  368. package/lib/version.js +6 -0
  369. package/lib/version.js.map +1 -0
  370. package/lib/wrapper.mjs +44 -0
  371. package/package.json +197 -0
@@ -0,0 +1,101 @@
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
+ exports.shouldCauseFailure = exports.retriesForPickle = exports.getAmbiguousStepException = void 0;
30
+ const location_helpers_1 = require("../formatter/helpers/location_helpers");
31
+ const cli_table3_1 = __importDefault(require("cli-table3"));
32
+ const indent_string_1 = __importDefault(require("indent-string"));
33
+ const pickle_filter_1 = require("../pickle_filter");
34
+ const messages = __importStar(require("@cucumber/messages"));
35
+ function getAmbiguousStepException(stepDefinitions) {
36
+ const table = new cli_table3_1.default({
37
+ chars: {
38
+ bottom: '',
39
+ 'bottom-left': '',
40
+ 'bottom-mid': '',
41
+ 'bottom-right': '',
42
+ left: '',
43
+ 'left-mid': '',
44
+ mid: '',
45
+ 'mid-mid': '',
46
+ middle: ' - ',
47
+ right: '',
48
+ 'right-mid': '',
49
+ top: '',
50
+ 'top-left': '',
51
+ 'top-mid': '',
52
+ 'top-right': '',
53
+ },
54
+ style: {
55
+ border: [],
56
+ 'padding-left': 0,
57
+ 'padding-right': 0,
58
+ },
59
+ });
60
+ table.push(...stepDefinitions.map((stepDefinition) => {
61
+ const pattern = stepDefinition.pattern.toString();
62
+ return [pattern, (0, location_helpers_1.formatLocation)(stepDefinition)];
63
+ }));
64
+ return `${'Multiple step definitions match:' + '\n'}${(0, indent_string_1.default)(table.toString(), 2)}`;
65
+ }
66
+ exports.getAmbiguousStepException = getAmbiguousStepException;
67
+ function retriesForPickle(pickle, options) {
68
+ if (!options.retry) {
69
+ return 0;
70
+ }
71
+ const retries = options.retry;
72
+ if (retries === 0) {
73
+ return 0;
74
+ }
75
+ const retryTagFilter = options.retryTagFilter;
76
+ if (!retryTagFilter) {
77
+ return retries;
78
+ }
79
+ const pickleTagFilter = new pickle_filter_1.PickleTagFilter(retryTagFilter);
80
+ if (pickleTagFilter.matchesAllTagExpressions(pickle)) {
81
+ return retries;
82
+ }
83
+ return 0;
84
+ }
85
+ exports.retriesForPickle = retriesForPickle;
86
+ function shouldCauseFailure(status, options) {
87
+ if (options.dryRun) {
88
+ return false;
89
+ }
90
+ const failureStatuses = [
91
+ messages.TestStepResultStatus.AMBIGUOUS,
92
+ messages.TestStepResultStatus.FAILED,
93
+ messages.TestStepResultStatus.UNDEFINED,
94
+ ];
95
+ if (options.strict) {
96
+ failureStatuses.push(messages.TestStepResultStatus.PENDING);
97
+ }
98
+ return failureStatuses.includes(status);
99
+ }
100
+ exports.shouldCauseFailure = shouldCauseFailure;
101
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
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;YACL,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,GAAG,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AoBC;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"]}
@@ -0,0 +1,40 @@
1
+ /// <reference types="node" />
2
+ import * as messages from '@cucumber/messages';
3
+ import { IdGenerator } from '@cucumber/messages';
4
+ import { EventEmitter } from 'events';
5
+ import { EventDataCollector } from '../formatter/helpers';
6
+ import { ISupportCodeLibrary } from '../support_code_library_builder/types';
7
+ export interface IRuntime {
8
+ start: () => Promise<boolean>;
9
+ }
10
+ export interface INewRuntimeOptions {
11
+ eventBroadcaster: EventEmitter;
12
+ eventDataCollector: EventDataCollector;
13
+ newId: IdGenerator.NewId;
14
+ options: IRuntimeOptions;
15
+ pickleIds: string[];
16
+ supportCodeLibrary: ISupportCodeLibrary;
17
+ }
18
+ export interface IRuntimeOptions {
19
+ dryRun: boolean;
20
+ failFast: boolean;
21
+ filterStacktraces: boolean;
22
+ retry: number;
23
+ retryTagFilter: string;
24
+ strict: boolean;
25
+ worldParameters: any;
26
+ }
27
+ export default class Runtime implements IRuntime {
28
+ private readonly eventBroadcaster;
29
+ private readonly eventDataCollector;
30
+ private readonly stopwatch;
31
+ private readonly newId;
32
+ private readonly options;
33
+ private readonly pickleIds;
34
+ private readonly supportCodeLibrary;
35
+ private success;
36
+ private runTestRunHooks;
37
+ constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }: INewRuntimeOptions);
38
+ runTestCase(pickleId: string, testCase: messages.TestCase): Promise<void>;
39
+ start(): Promise<boolean>;
40
+ }
@@ -0,0 +1,76 @@
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 assemble_test_cases_1 = require("./assemble_test_cases");
7
+ const helpers_1 = require("./helpers");
8
+ const run_test_run_hooks_1 = require("./run_test_run_hooks");
9
+ const stopwatch_1 = require("./stopwatch");
10
+ const test_case_runner_1 = __importDefault(require("./test_case_runner"));
11
+ class Runtime {
12
+ constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }) {
13
+ this.eventBroadcaster = eventBroadcaster;
14
+ this.eventDataCollector = eventDataCollector;
15
+ this.stopwatch = (0, stopwatch_1.create)();
16
+ this.newId = newId;
17
+ this.options = options;
18
+ this.pickleIds = pickleIds;
19
+ this.supportCodeLibrary = supportCodeLibrary;
20
+ this.success = true;
21
+ this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(this.options.dryRun, this.supportCodeLibrary.defaultTimeout, (name, location) => `${name} hook errored, process exiting: ${location}`);
22
+ }
23
+ async runTestCase(pickleId, testCase) {
24
+ const pickle = this.eventDataCollector.getPickle(pickleId);
25
+ const retries = (0, helpers_1.retriesForPickle)(pickle, this.options);
26
+ const skip = this.options.dryRun || (this.options.failFast && !this.success);
27
+ const testCaseRunner = new test_case_runner_1.default({
28
+ eventBroadcaster: this.eventBroadcaster,
29
+ stopwatch: this.stopwatch,
30
+ gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),
31
+ newId: this.newId,
32
+ pickle,
33
+ testCase,
34
+ retries,
35
+ skip,
36
+ filterStackTraces: this.options.filterStacktraces,
37
+ supportCodeLibrary: this.supportCodeLibrary,
38
+ worldParameters: this.options.worldParameters,
39
+ });
40
+ const status = await testCaseRunner.run();
41
+ if ((0, helpers_1.shouldCauseFailure)(status, this.options)) {
42
+ this.success = false;
43
+ }
44
+ }
45
+ async start() {
46
+ const testRunStarted = {
47
+ testRunStarted: {
48
+ timestamp: this.stopwatch.timestamp(),
49
+ },
50
+ };
51
+ this.eventBroadcaster.emit('envelope', testRunStarted);
52
+ this.stopwatch.start();
53
+ await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
54
+ const assembledTestCases = await (0, assemble_test_cases_1.assembleTestCases)({
55
+ eventBroadcaster: this.eventBroadcaster,
56
+ newId: this.newId,
57
+ pickles: this.pickleIds.map((pickleId) => this.eventDataCollector.getPickle(pickleId)),
58
+ supportCodeLibrary: this.supportCodeLibrary,
59
+ });
60
+ for (const pickleId of this.pickleIds) {
61
+ await this.runTestCase(pickleId, assembledTestCases[pickleId]);
62
+ }
63
+ await this.runTestRunHooks(this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(), 'an AfterAll');
64
+ this.stopwatch.stop();
65
+ const testRunFinished = {
66
+ testRunFinished: {
67
+ timestamp: this.stopwatch.timestamp(),
68
+ success: this.success,
69
+ },
70
+ };
71
+ this.eventBroadcaster.emit('envelope', testRunFinished);
72
+ return this.success;
73
+ }
74
+ }
75
+ exports.default = Runtime;
76
+ //# sourceMappingURL=index.js.map
@@ -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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e,GAAsB;YACzC,eAAe,EAAE;gBACf,SAAS,EAAE,IAAI,CAAC,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,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAjGD,0BAiGC","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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=command_types.js.map
@@ -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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C,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