From fb539500b05e997eda9e49a015031aa79b99d5de Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Thu, 22 Jul 2021 14:21:57 -0700 Subject: [PATCH 01/13] Extract functions into their own files --- .../build_parameter_type.ts | 21 +++++++++++++++++++ ...pers.ts => get_definition_line_and_uri.ts} | 21 ------------------- src/support_code_library_builder/index.ts | 3 ++- 3 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 src/support_code_library_builder/build_parameter_type.ts rename src/support_code_library_builder/{build_helpers.ts => get_definition_line_and_uri.ts} (61%) diff --git a/src/support_code_library_builder/build_parameter_type.ts b/src/support_code_library_builder/build_parameter_type.ts new file mode 100644 index 000000000..a05258370 --- /dev/null +++ b/src/support_code_library_builder/build_parameter_type.ts @@ -0,0 +1,21 @@ +import { ParameterType } from '@cucumber/cucumber-expressions' +import { IParameterTypeDefinition } from './types' + +export function buildParameterType({ + name, + regexp, + transformer, + useForSnippets, + preferForRegexpMatch, +}: IParameterTypeDefinition): ParameterType { + if (typeof useForSnippets !== 'boolean') useForSnippets = true + if (typeof preferForRegexpMatch !== 'boolean') preferForRegexpMatch = false + return new ParameterType( + name, + regexp, + null, + transformer, + useForSnippets, + preferForRegexpMatch + ) +} diff --git a/src/support_code_library_builder/build_helpers.ts b/src/support_code_library_builder/get_definition_line_and_uri.ts similarity index 61% rename from src/support_code_library_builder/build_helpers.ts rename to src/support_code_library_builder/get_definition_line_and_uri.ts index 3ff412caa..422714fe3 100644 --- a/src/support_code_library_builder/build_helpers.ts +++ b/src/support_code_library_builder/get_definition_line_and_uri.ts @@ -1,10 +1,8 @@ -import { ParameterType } from '@cucumber/cucumber-expressions' import path from 'path' import StackTrace from 'stacktrace-js' import { isFileNameInCucumber } from '../stack_trace_filter' import { doesHaveValue, valueOrDefault } from '../value_checker' import { ILineAndUri } from '../types' -import { IParameterTypeDefinition } from './types' export function getDefinitionLineAndUri(cwd: string): ILineAndUri { let line: number @@ -29,22 +27,3 @@ export function getDefinitionLineAndUri(cwd: string): ILineAndUri { uri: valueOrDefault(uri, 'unknown'), } } - -export function buildParameterType({ - name, - regexp, - transformer, - useForSnippets, - preferForRegexpMatch, -}: IParameterTypeDefinition): ParameterType { - if (typeof useForSnippets !== 'boolean') useForSnippets = true - if (typeof preferForRegexpMatch !== 'boolean') preferForRegexpMatch = false - return new ParameterType( - name, - regexp, - null, - transformer, - useForSnippets, - preferForRegexpMatch - ) -} diff --git a/src/support_code_library_builder/index.ts b/src/support_code_library_builder/index.ts index 4a7f04d55..4db940b02 100644 --- a/src/support_code_library_builder/index.ts +++ b/src/support_code_library_builder/index.ts @@ -1,4 +1,5 @@ -import { buildParameterType, getDefinitionLineAndUri } from './build_helpers' +import { buildParameterType } from './build_parameter_type' +import { getDefinitionLineAndUri } from './get_definition_line_and_uri' import { IdGenerator } from '@cucumber/messages' import * as messages from '@cucumber/messages' import TestCaseHookDefinition from '../models/test_case_hook_definition' From d9712b1002587ac31f263de05dbc56c6f5461fb8 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Fri, 23 Jul 2021 08:13:43 -0700 Subject: [PATCH 02/13] Allow injection of exclusion filter to make easier to test --- .../get_definition_line_and_uri.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/support_code_library_builder/get_definition_line_and_uri.ts b/src/support_code_library_builder/get_definition_line_and_uri.ts index 422714fe3..d6e2df1a4 100644 --- a/src/support_code_library_builder/get_definition_line_and_uri.ts +++ b/src/support_code_library_builder/get_definition_line_and_uri.ts @@ -4,13 +4,16 @@ import { isFileNameInCucumber } from '../stack_trace_filter' import { doesHaveValue, valueOrDefault } from '../value_checker' import { ILineAndUri } from '../types' -export function getDefinitionLineAndUri(cwd: string): ILineAndUri { +export function getDefinitionLineAndUri( + cwd: string, + exclude = isFileNameInCucumber +): ILineAndUri { let line: number let uri: string try { const stackframes = StackTrace.getSync() const stackframe = stackframes.find((frame) => { - return !isFileNameInCucumber(frame.getFileName()) + return !exclude(frame.getFileName()) }) if (stackframe != null) { line = stackframe.getLineNumber() From 8fcb75085f749a4618a2261ed99fb539ccd076b0 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Fri, 23 Jul 2021 11:58:11 -0700 Subject: [PATCH 03/13] Make sure we always exclude ourselves --- .../get_definition_line_and_uri.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/support_code_library_builder/get_definition_line_and_uri.ts b/src/support_code_library_builder/get_definition_line_and_uri.ts index d6e2df1a4..4172e6fe2 100644 --- a/src/support_code_library_builder/get_definition_line_and_uri.ts +++ b/src/support_code_library_builder/get_definition_line_and_uri.ts @@ -6,15 +6,16 @@ import { ILineAndUri } from '../types' export function getDefinitionLineAndUri( cwd: string, - exclude = isFileNameInCucumber + isExcluded = isFileNameInCucumber ): ILineAndUri { let line: number let uri: string try { const stackframes = StackTrace.getSync() - const stackframe = stackframes.find((frame) => { - return !exclude(frame.getFileName()) - }) + const stackframe = stackframes.find( + (frame) => + frame.getFileName() !== __filename && !isExcluded(frame.getFileName()) + ) if (stackframe != null) { line = stackframe.getLineNumber() uri = stackframe.getFileName() From db95b777adef8c9d2ec30979fee9b9e5b9b13fe4 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Fri, 23 Jul 2021 11:58:30 -0700 Subject: [PATCH 04/13] Add unit test for getDefinitionLineAndUri --- .../get_definition_line_and_uri_spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/support_code_library_builder/get_definition_line_and_uri_spec.ts diff --git a/src/support_code_library_builder/get_definition_line_and_uri_spec.ts b/src/support_code_library_builder/get_definition_line_and_uri_spec.ts new file mode 100644 index 000000000..28f9b6e67 --- /dev/null +++ b/src/support_code_library_builder/get_definition_line_and_uri_spec.ts @@ -0,0 +1,14 @@ +import assert from 'assert' +import { getDefinitionLineAndUri } from './get_definition_line_and_uri' + +describe(getDefinitionLineAndUri.name, () => { + it('correctly gets the filename of the caller', () => { + const includeAnyFile = (): boolean => false + const { uri, line } = getDefinitionLineAndUri('.', includeAnyFile) + assert.strictEqual( + uri, + 'src/support_code_library_builder/get_definition_line_and_uri_spec.ts' + ) + assert.strictEqual(line, 7) + }) +}) From ed45132ee5b9e469417ca1693cbfe36610e8bfeb Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Fri, 20 Aug 2021 13:05:25 -0400 Subject: [PATCH 05/13] -adds regex pattern for stack traces -removes dependencies for StackFram library --- .DS_Store | Bin 0 -> 6148 bytes package.json | 1 - .../get_definition_line_and_uri.ts | 16 +++++-- yarn.lock | 41 ------------------ 4 files changed, 13 insertions(+), 45 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a18d1c150f0c66e8bee67caf92bbd3e7cd6f054c GIT binary patch literal 6148 zcmeHKK~BR!4D_}Y1OZZx9QOl^q2Pv8eU0RF%W z7_Y51RiF|VgeqI|&cRVnras-__g1&Fr2FyHdZnGy!`o-HmxY`(uB_G>bXVKw(Q`PD&onUx zi~(a{7Z^azW{D03Z8Qdq0b^jr0Dm7mlrd3k1jDBTLudhj1DJzg&b8H=52q(P?ND4e9sB#>PA(C&(HJlWHW}#4W6bsc?C1V} zGsvEd0b^jN7;u9$OGkJmt*xDx<67&Xmrxe=YXnyzn1oUcUoOQb&>*mTo&XcYMi3T= O{SgQ>*kBC&DFa`Zhg0eR literal 0 HcmV?d00001 diff --git a/package.json b/package.json index 957909a67..13a7acbe9 100644 --- a/package.json +++ b/package.json @@ -193,7 +193,6 @@ "resolve": "^1.19.0", "resolve-pkg": "^2.0.0", "stack-chain": "^2.0.0", - "stacktrace-js": "^2.0.2", "string-argv": "^0.3.1", "tmp": "^0.2.1", "verror": "^1.10.0" diff --git a/src/support_code_library_builder/get_definition_line_and_uri.ts b/src/support_code_library_builder/get_definition_line_and_uri.ts index 4172e6fe2..2be97dddf 100644 --- a/src/support_code_library_builder/get_definition_line_and_uri.ts +++ b/src/support_code_library_builder/get_definition_line_and_uri.ts @@ -1,8 +1,9 @@ import path from 'path' -import StackTrace from 'stacktrace-js' +import stackChain from 'stack-chain' import { isFileNameInCucumber } from '../stack_trace_filter' import { doesHaveValue, valueOrDefault } from '../value_checker' import { ILineAndUri } from '../types' +import CallSite = NodeJS.CallSite export function getDefinitionLineAndUri( cwd: string, @@ -11,9 +12,18 @@ export function getDefinitionLineAndUri( let line: number let uri: string try { - const stackframes = StackTrace.getSync() + console.log(new Error().stack.split("\n").slice(1).map( + (line: String) => line.match(/(\/.*):(\d+):\d+/).slice(1,3) + )) + const stackframes = stackChain.callSite() + /*console.log( + stackframes.map((frame: CallSite) => [ + frame.getLineNumber(), + frame.getFileName(), + ]) + )*/ const stackframe = stackframes.find( - (frame) => + (frame: CallSite) => frame.getFileName() !== __filename && !isExcluded(frame.getFileName()) ) if (stackframe != null) { diff --git a/yarn.lock b/yarn.lock index 12b0d21b6..38e7119a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1506,13 +1506,6 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -error-stack-parser@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.0.6.tgz#5a99a707bd7a4c58a797902d48d82803ede6aad8" - integrity sha512-d51brTeqC+BHlwF0BhPtcYgF5nlzf9ZZ0ZIUQNZpc9ZB9qw5IJ2diTrBY9jlCJkTLITYPjmiX6OWCwH+fuyNgQ== - dependencies: - stackframe "^1.1.1" - es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2, es-abstract@^1.18.2: version "1.18.3" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.3.tgz#25c4c3380a27aa203c44b2b685bba94da31b63e0" @@ -3614,11 +3607,6 @@ source-map-support@0.5.19, source-map-support@^0.5.17: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@0.5.6: - version "0.5.6" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" - integrity sha1-dc449SvwczxafwwRjYEzSiu19BI= - source-map@^0.5.0: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -3677,35 +3665,6 @@ stack-chain@^2.0.0: resolved "https://registry.yarnpkg.com/stack-chain/-/stack-chain-2.0.0.tgz#d73d1172af89565f07438b5bcc086831b6689b2d" integrity sha512-GGrHXePi305aW7XQweYZZwiRwR7Js3MWoK/EHzzB9ROdc75nCnjSJVi21rdAGxFl+yCx2L2qdfl5y7NO4lTyqg== -stack-generator@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/stack-generator/-/stack-generator-2.0.5.tgz#fb00e5b4ee97de603e0773ea78ce944d81596c36" - integrity sha512-/t1ebrbHkrLrDuNMdeAcsvynWgoH/i4o8EGGfX7dEYDoTXOYVAkEpFdtshlvabzc6JlJ8Kf9YdFEoz7JkzGN9Q== - dependencies: - stackframe "^1.1.1" - -stackframe@^1.1.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.2.0.tgz#52429492d63c62eb989804c11552e3d22e779303" - integrity sha512-GrdeshiRmS1YLMYgzF16olf2jJ/IzxXY9lhKOskuVziubpTYcYqyOwYeJKzQkwy7uN0fYSsbsC4RQaXf9LCrYA== - -stacktrace-gps@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/stacktrace-gps/-/stacktrace-gps-3.0.4.tgz#7688dc2fc09ffb3a13165ebe0dbcaf41bcf0c69a" - integrity sha512-qIr8x41yZVSldqdqe6jciXEaSCKw1U8XTXpjDuy0ki/apyTn/r3w9hDAAQOhZdxvsC93H+WwwEu5cq5VemzYeg== - dependencies: - source-map "0.5.6" - stackframe "^1.1.1" - -stacktrace-js@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/stacktrace-js/-/stacktrace-js-2.0.2.tgz#4ca93ea9f494752d55709a081d400fdaebee897b" - integrity sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg== - dependencies: - error-stack-parser "^2.0.6" - stack-generator "^2.0.5" - stacktrace-gps "^3.0.4" - "statuses@>= 1.5.0 < 2", statuses@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" From d1217f0561fc280f14abc4500241a3429f58a227 Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Fri, 22 Oct 2021 12:02:57 -0400 Subject: [PATCH 06/13] - adds "source-map-support" dependency - progress towards fixing bug for paths with parentheses Cucumber's own features fail when parent directory contains parentheses #1735 - gets accurate line numbers for Error stacks in typescript Co-authored-by: Blaise Pabon Co-authored-by: Matt Wynne --- package-lock.json | 103 +----------------- package.json | 1 + .../get_definition_line_and_uri.ts | 12 +- 3 files changed, 5 insertions(+), 111 deletions(-) diff --git a/package-lock.json b/package-lock.json index 487ae9e68..0d14b7e80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "7.3.0", "license": "MIT", "dependencies": { + "@cspotcode/source-map-support": "^0.6.1", "@cucumber/create-meta": "6.0.1", "@cucumber/cucumber-expressions": "12.1.2", "@cucumber/gherkin": "20.0.1", @@ -34,7 +35,6 @@ "resolve": "^1.19.0", "resolve-pkg": "^2.0.0", "stack-chain": "^2.0.0", - "stacktrace-js": "^2.0.2", "string-argv": "^0.3.1", "tmp": "^0.2.1", "verror": "^1.10.0" @@ -515,7 +515,6 @@ "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true, "engines": { "node": ">= 12" } @@ -524,7 +523,6 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.6.1.tgz", "integrity": "sha512-DX3Z+T5dt1ockmPdobJS/FAsQPW4V4SrWEhD2iYQT2Cb2tQsiMnYxrcUH9By/Z3B+v0S5LMBkQtV/XOBbpLEOg==", - "dev": true, "dependencies": { "@cspotcode/source-map-consumer": "0.8.0" }, @@ -2439,14 +2437,6 @@ "is-arrayish": "^0.2.1" } }, - "node_modules/error-stack-parser": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.0.6.tgz", - "integrity": "sha512-d51brTeqC+BHlwF0BhPtcYgF5nlzf9ZZ0ZIUQNZpc9ZB9qw5IJ2diTrBY9jlCJkTLITYPjmiX6OWCwH+fuyNgQ==", - "dependencies": { - "stackframe": "^1.1.1" - } - }, "node_modules/es-abstract": { "version": "1.18.3", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.3.tgz", @@ -6315,46 +6305,6 @@ "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-2.0.0.tgz", "integrity": "sha512-GGrHXePi305aW7XQweYZZwiRwR7Js3MWoK/EHzzB9ROdc75nCnjSJVi21rdAGxFl+yCx2L2qdfl5y7NO4lTyqg==" }, - "node_modules/stack-generator": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/stack-generator/-/stack-generator-2.0.5.tgz", - "integrity": "sha512-/t1ebrbHkrLrDuNMdeAcsvynWgoH/i4o8EGGfX7dEYDoTXOYVAkEpFdtshlvabzc6JlJ8Kf9YdFEoz7JkzGN9Q==", - "dependencies": { - "stackframe": "^1.1.1" - } - }, - "node_modules/stackframe": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.2.0.tgz", - "integrity": "sha512-GrdeshiRmS1YLMYgzF16olf2jJ/IzxXY9lhKOskuVziubpTYcYqyOwYeJKzQkwy7uN0fYSsbsC4RQaXf9LCrYA==" - }, - "node_modules/stacktrace-gps": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/stacktrace-gps/-/stacktrace-gps-3.0.4.tgz", - "integrity": "sha512-qIr8x41yZVSldqdqe6jciXEaSCKw1U8XTXpjDuy0ki/apyTn/r3w9hDAAQOhZdxvsC93H+WwwEu5cq5VemzYeg==", - "dependencies": { - "source-map": "0.5.6", - "stackframe": "^1.1.1" - } - }, - "node_modules/stacktrace-gps/node_modules/source-map": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/stacktrace-js": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/stacktrace-js/-/stacktrace-js-2.0.2.tgz", - "integrity": "sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg==", - "dependencies": { - "error-stack-parser": "^2.0.6", - "stack-generator": "^2.0.5", - "stacktrace-gps": "^3.0.4" - } - }, "node_modules/statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -7527,14 +7477,12 @@ "@cspotcode/source-map-consumer": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.6.1.tgz", "integrity": "sha512-DX3Z+T5dt1ockmPdobJS/FAsQPW4V4SrWEhD2iYQT2Cb2tQsiMnYxrcUH9By/Z3B+v0S5LMBkQtV/XOBbpLEOg==", - "dev": true, "requires": { "@cspotcode/source-map-consumer": "0.8.0" } @@ -9104,14 +9052,6 @@ "is-arrayish": "^0.2.1" } }, - "error-stack-parser": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.0.6.tgz", - "integrity": "sha512-d51brTeqC+BHlwF0BhPtcYgF5nlzf9ZZ0ZIUQNZpc9ZB9qw5IJ2diTrBY9jlCJkTLITYPjmiX6OWCwH+fuyNgQ==", - "requires": { - "stackframe": "^1.1.1" - } - }, "es-abstract": { "version": "1.18.3", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.3.tgz", @@ -12029,45 +11969,6 @@ "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-2.0.0.tgz", "integrity": "sha512-GGrHXePi305aW7XQweYZZwiRwR7Js3MWoK/EHzzB9ROdc75nCnjSJVi21rdAGxFl+yCx2L2qdfl5y7NO4lTyqg==" }, - "stack-generator": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/stack-generator/-/stack-generator-2.0.5.tgz", - "integrity": "sha512-/t1ebrbHkrLrDuNMdeAcsvynWgoH/i4o8EGGfX7dEYDoTXOYVAkEpFdtshlvabzc6JlJ8Kf9YdFEoz7JkzGN9Q==", - "requires": { - "stackframe": "^1.1.1" - } - }, - "stackframe": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.2.0.tgz", - "integrity": "sha512-GrdeshiRmS1YLMYgzF16olf2jJ/IzxXY9lhKOskuVziubpTYcYqyOwYeJKzQkwy7uN0fYSsbsC4RQaXf9LCrYA==" - }, - "stacktrace-gps": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/stacktrace-gps/-/stacktrace-gps-3.0.4.tgz", - "integrity": "sha512-qIr8x41yZVSldqdqe6jciXEaSCKw1U8XTXpjDuy0ki/apyTn/r3w9hDAAQOhZdxvsC93H+WwwEu5cq5VemzYeg==", - "requires": { - "source-map": "0.5.6", - "stackframe": "^1.1.1" - }, - "dependencies": { - "source-map": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" - } - } - }, - "stacktrace-js": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/stacktrace-js/-/stacktrace-js-2.0.2.tgz", - "integrity": "sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg==", - "requires": { - "error-stack-parser": "^2.0.6", - "stack-generator": "^2.0.5", - "stacktrace-gps": "^3.0.4" - } - }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", diff --git a/package.json b/package.json index 5b636c091..85f4769b0 100644 --- a/package.json +++ b/package.json @@ -168,6 +168,7 @@ "node": ">=12" }, "dependencies": { + "@cspotcode/source-map-support": "^0.6.1", "@cucumber/create-meta": "6.0.1", "@cucumber/cucumber-expressions": "12.1.2", "@cucumber/gherkin": "20.0.1", diff --git a/src/support_code_library_builder/get_definition_line_and_uri.ts b/src/support_code_library_builder/get_definition_line_and_uri.ts index 2be97dddf..3489bdb6d 100644 --- a/src/support_code_library_builder/get_definition_line_and_uri.ts +++ b/src/support_code_library_builder/get_definition_line_and_uri.ts @@ -1,4 +1,5 @@ import path from 'path' +import { wrapCallSite } from '@cspotcode/source-map-support' import stackChain from 'stack-chain' import { isFileNameInCucumber } from '../stack_trace_filter' import { doesHaveValue, valueOrDefault } from '../value_checker' @@ -12,16 +13,7 @@ export function getDefinitionLineAndUri( let line: number let uri: string try { - console.log(new Error().stack.split("\n").slice(1).map( - (line: String) => line.match(/(\/.*):(\d+):\d+/).slice(1,3) - )) - const stackframes = stackChain.callSite() - /*console.log( - stackframes.map((frame: CallSite) => [ - frame.getLineNumber(), - frame.getFileName(), - ]) - )*/ + const stackframes: CallSite[] = stackChain.callSite().map(wrapCallSite) const stackframe = stackframes.find( (frame: CallSite) => frame.getFileName() !== __filename && !isExcluded(frame.getFileName()) From fec9841b92f903ad562a06274179d4a13a19e9df Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Mon, 1 Nov 2021 15:05:16 -0400 Subject: [PATCH 07/13] update cspotcode/source-map-support --- .DS_Store | Bin 6148 -> 8196 bytes package-lock.json | 18 ++++++++---------- package.json | 1 + 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.DS_Store b/.DS_Store index a18d1c150f0c66e8bee67caf92bbd3e7cd6f054c..dcb959aabbcbf3a7f2dda1aa32d151857c83a693 100644 GIT binary patch literal 8196 zcmeHM&ubGw82vUIV_F+pdMb*#cp^MLdAnns22~_KR`W*c=FAU-Tfw;4Lyn28QA%jdEd-?^JcQ!*%Fa6+4hS> zV?>n4CE~~tR6UBo#g!---Et1mL4T^x6=$kJqnXIG4b}ncfOWt+U>&dy{3{ONoh?c} z<-M;^TU!UL0|(Lp@qF-biCEIHqoRCtppr)b#4MU+!TpH1LG*Mi>DW;b2#TY+BC4*A zK4LhkJK8;+SJJVgqUuhLK72Tu+0iEyN3vslPo|SoQqk7d0qa200daQE(ixhg8ZGnl zduDiZmt&2fT&~oE3fl7Jqd(8DKYn}B#QnZ_b3XnykQtZ1(!(Jy%~P8yoSkU&K1T1# z;2PdNFMN2UG$gWOCFxmQ50U(2;Zg-IESNgz0(5AE^S?TE;?u8b=|P0Xyh+sLlk+c7 zl>%yj{5CCvS+Li|I?$@AVY~(neX_Z(ohL8$v@d;o#9H^)!_@x`g0OFV=&#a}p?2Wj z4#&8*XA>_&ZBgGw5G(108@z+lf;UfhXjXdGrWWo@es^lGR}Ra21Tz?lj@YFLD ztn4mAfkrs@m-n+*AFAhkgvK*Zq6XjQYYb{jiUY1{9}~Osa{BlGl-{=4I$$069~^M9 z<(cv%W}?s5i8+b0wukE$E>T2YM@88Ml}Hio@;Htd{lgIVp2kW#c2op{^4C8Euycr( PX5atz{V(_8L8|@$e>p5v delta 261 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjUE#6q~50C<+o_1dGKp_>u z7@VA+TL2PbD39z!$mHg`xFqG|Cjmt`DldKFU<*F%h%B3eCOi3pm=xoLjfq!S7PE73 r2r>iJ0)YTGkZ=Y0U}NHU=E?jrjvz0B{J;XDnIL`yi*1hQnZpbKe4IHe diff --git a/package-lock.json b/package-lock.json index b948be331..4c47d8f62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "8.0.0-rc.1", "license": "MIT", "dependencies": { + "@cspotcode/source-map-support": "^0.7.0", "@cucumber/create-meta": "6.0.2", "@cucumber/cucumber-expressions": "^14.0.0", "@cucumber/gherkin": "^22.0.0", @@ -514,16 +515,14 @@ "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true, "engines": { "node": ">= 12" } }, "node_modules/@cspotcode/source-map-support": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.6.1.tgz", - "integrity": "sha512-DX3Z+T5dt1ockmPdobJS/FAsQPW4V4SrWEhD2iYQT2Cb2tQsiMnYxrcUH9By/Z3B+v0S5LMBkQtV/XOBbpLEOg==", - "dev": true, + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", "dependencies": { "@cspotcode/source-map-consumer": "0.8.0" }, @@ -7330,13 +7329,12 @@ "@cspotcode/source-map-consumer": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" }, "@cspotcode/source-map-support": { - "version": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.6.1.tgz", - "integrity": "sha512-DX3Z+T5dt1ockmPdobJS/FAsQPW4V4SrWEhD2iYQT2Cb2tQsiMnYxrcUH9By/Z3B+v0S5LMBkQtV/XOBbpLEOg==", - "dev": true, + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", "requires": { "@cspotcode/source-map-consumer": "0.8.0" } diff --git a/package.json b/package.json index 9add18291..b95451af1 100644 --- a/package.json +++ b/package.json @@ -182,6 +182,7 @@ "node": ">=12" }, "dependencies": { + "@cspotcode/source-map-support": "^0.7.0", "@cucumber/create-meta": "6.0.2", "@cucumber/cucumber-expressions": "^14.0.0", "@cucumber/gherkin": "^22.0.0", From b11b98812de161bd3862318da18181fefdc31f99 Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Mon, 1 Nov 2021 15:34:24 -0400 Subject: [PATCH 08/13] remove .DS_Store --- .DS_Store | Bin 8196 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index dcb959aabbcbf3a7f2dda1aa32d151857c83a693..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM&ubGw82vUIV_F+pdMb*#cp^MLdAnns22~_KR`W*c=FAU-Tfw;4Lyn28QA%jdEd-?^JcQ!*%Fa6+4hS> zV?>n4CE~~tR6UBo#g!---Et1mL4T^x6=$kJqnXIG4b}ncfOWt+U>&dy{3{ONoh?c} z<-M;^TU!UL0|(Lp@qF-biCEIHqoRCtppr)b#4MU+!TpH1LG*Mi>DW;b2#TY+BC4*A zK4LhkJK8;+SJJVgqUuhLK72Tu+0iEyN3vslPo|SoQqk7d0qa200daQE(ixhg8ZGnl zduDiZmt&2fT&~oE3fl7Jqd(8DKYn}B#QnZ_b3XnykQtZ1(!(Jy%~P8yoSkU&K1T1# z;2PdNFMN2UG$gWOCFxmQ50U(2;Zg-IESNgz0(5AE^S?TE;?u8b=|P0Xyh+sLlk+c7 zl>%yj{5CCvS+Li|I?$@AVY~(neX_Z(ohL8$v@d;o#9H^)!_@x`g0OFV=&#a}p?2Wj z4#&8*XA>_&ZBgGw5G(108@z+lf;UfhXjXdGrWWo@es^lGR}Ra21Tz?lj@YFLD ztn4mAfkrs@m-n+*AFAhkgvK*Zq6XjQYYb{jiUY1{9}~Osa{BlGl-{=4I$$069~^M9 z<(cv%W}?s5i8+b0wukE$E>T2YM@88Ml}Hio@;Htd{lgIVp2kW#c2op{^4C8Euycr( PX5atz{V(_8L8|@$e>p5v From 1d7a089bbe9984b0ff39969fba32fdec754b53ab Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Fri, 12 Nov 2021 11:40:05 -0500 Subject: [PATCH 09/13] updates unit test to support paths on windows Co-authored-by: Matt Wynne Co-authored-by: Blaise Pabon Co-authored-by: Dane Parchment --- .../get_definition_line_and_uri_spec.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/support_code_library_builder/get_definition_line_and_uri_spec.ts b/src/support_code_library_builder/get_definition_line_and_uri_spec.ts index 28f9b6e67..81956f255 100644 --- a/src/support_code_library_builder/get_definition_line_and_uri_spec.ts +++ b/src/support_code_library_builder/get_definition_line_and_uri_spec.ts @@ -1,14 +1,17 @@ import assert from 'assert' import { getDefinitionLineAndUri } from './get_definition_line_and_uri' +import path from 'path' describe(getDefinitionLineAndUri.name, () => { it('correctly gets the filename of the caller', () => { const includeAnyFile = (): boolean => false const { uri, line } = getDefinitionLineAndUri('.', includeAnyFile) assert.strictEqual( - uri, - 'src/support_code_library_builder/get_definition_line_and_uri_spec.ts' + path.normalize(uri), + path.normalize( + 'src/support_code_library_builder/get_definition_line_and_uri_spec.ts' + ) ) - assert.strictEqual(line, 7) + assert.strictEqual(line, 8) }) }) From 68cab1e340fceefa52c0b1824785608e9afc7906 Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Fri, 12 Nov 2021 11:52:23 -0500 Subject: [PATCH 10/13] Removes assertion for a failing test that's no longer needed Co-authored-by: Matt Wynne Co-authored-by: Blaise Pabon Co-authored-by: Dane Parchment --- features/custom_stack_trace.feature | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/features/custom_stack_trace.feature b/features/custom_stack_trace.feature index d374f1694..317c92b84 100644 --- a/features/custom_stack_trace.feature +++ b/features/custom_stack_trace.feature @@ -20,8 +20,4 @@ Feature: Custom stack trace Error.prepareStackTrace = _prepareStackTrace """ When I run cucumber-js - Then it passes - And the error output contains the text: - """ - Warning: unable to get definition line and uri [Custom message] - """ + Then it passes \ No newline at end of file From 48a79298a1bf8b9c1e24d99707fa2b2bd6d40270 Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Fri, 12 Nov 2021 12:09:36 -0500 Subject: [PATCH 11/13] Removes exception for the custom stack trace feature Co-authored-by: Matt Wynne Co-authored-by: Blaise Pabon Co-authored-by: Dane Parchment --- features/custom_stack_trace.feature | 23 ---------------- .../get_definition_line_and_uri.ts | 26 +++++++++---------- 2 files changed, 12 insertions(+), 37 deletions(-) delete mode 100644 features/custom_stack_trace.feature diff --git a/features/custom_stack_trace.feature b/features/custom_stack_trace.feature deleted file mode 100644 index 317c92b84..000000000 --- a/features/custom_stack_trace.feature +++ /dev/null @@ -1,23 +0,0 @@ -Feature: Custom stack trace - - @spawn - Scenario: Error.prepareStackTrace override - Given a file named "features/a.feature" with: - """ - Feature: Some feature - Scenario: Some scenario - Given Error.prepareStackTrace has been overriden - """ - Given a file named "features/step_definitions/cucumber_steps.js" with: - """ - const {When} = require('@cucumber/cucumber') - - const _prepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = () => { return 'Custom message' } - - When(/^Error.prepareStackTrace has been overriden$/, function() {}) - - Error.prepareStackTrace = _prepareStackTrace - """ - When I run cucumber-js - Then it passes \ No newline at end of file diff --git a/src/support_code_library_builder/get_definition_line_and_uri.ts b/src/support_code_library_builder/get_definition_line_and_uri.ts index 3489bdb6d..fbd8e2fc1 100644 --- a/src/support_code_library_builder/get_definition_line_and_uri.ts +++ b/src/support_code_library_builder/get_definition_line_and_uri.ts @@ -12,22 +12,20 @@ export function getDefinitionLineAndUri( ): ILineAndUri { let line: number let uri: string - try { - const stackframes: CallSite[] = stackChain.callSite().map(wrapCallSite) - const stackframe = stackframes.find( - (frame: CallSite) => - frame.getFileName() !== __filename && !isExcluded(frame.getFileName()) - ) - if (stackframe != null) { - line = stackframe.getLineNumber() - uri = stackframe.getFileName() - if (doesHaveValue(uri)) { - uri = path.relative(cwd, uri) - } + + const stackframes: CallSite[] = stackChain.callSite().map(wrapCallSite) + const stackframe = stackframes.find( + (frame: CallSite) => + frame.getFileName() !== __filename && !isExcluded(frame.getFileName()) + ) + if (stackframe != null) { + line = stackframe.getLineNumber() + uri = stackframe.getFileName() + if (doesHaveValue(uri)) { + uri = path.relative(cwd, uri) } - } catch (e) { - console.warn('Warning: unable to get definition line and uri', e) } + return { line: valueOrDefault(line, 0), uri: valueOrDefault(uri, 'unknown'), From ea600883582c94ad6375402031bc5583d0d43e7d Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Fri, 12 Nov 2021 12:15:04 -0500 Subject: [PATCH 12/13] Updates changelog Co-authored-by: Matt Wynne Co-authored-by: Blaise Pabon Co-authored-by: Dane Parchment --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eae2a747c..24b8b14c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber. ## [Unreleased] +### Fixed +- Allows for parentheses in paths for developers working on cucumber's own code ([[#1735](https://github.com/cucumber/cucumber-js/issues/1735)]) ## [8.0.0-rc.1] - 2021-10-19 ### Added From 9f03c2fefd2a9f5a28ef43d2f1487f96fb5e94c7 Mon Sep 17 00:00:00 2001 From: Emmanuel Ola <54866720+eoola@users.noreply.github.com> Date: Fri, 12 Nov 2021 12:16:47 -0500 Subject: [PATCH 13/13] fixed linting for previous commit Co-authored-by: Matt Wynne Co-authored-by: Blaise Pabon Co-authored-by: Dane Parchment --- src/support_code_library_builder/get_definition_line_and_uri.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/support_code_library_builder/get_definition_line_and_uri.ts b/src/support_code_library_builder/get_definition_line_and_uri.ts index fbd8e2fc1..583319e6a 100644 --- a/src/support_code_library_builder/get_definition_line_and_uri.ts +++ b/src/support_code_library_builder/get_definition_line_and_uri.ts @@ -25,7 +25,7 @@ export function getDefinitionLineAndUri( uri = path.relative(cwd, uri) } } - + return { line: valueOrDefault(line, 0), uri: valueOrDefault(uri, 'unknown'),