Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix-1735 Parentheses in developers' paths break cucumber's own tests #1824

Merged
merged 20 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
103 changes: 2 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -206,7 +207,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",
"util-arity": "^1.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import path from 'path'
import StackTrace from 'stacktrace-js'
import { wrapCallSite } from '@cspotcode/source-map-support'
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,
Expand All @@ -11,9 +13,9 @@ export function getDefinitionLineAndUri(
let line: number
let uri: string
try {
const stackframes = StackTrace.getSync()
const stackframes: CallSite[] = stackChain.callSite().map(wrapCallSite)
const stackframe = stackframes.find(
(frame) =>
(frame: CallSite) =>
frame.getFileName() !== __filename && !isExcluded(frame.getFileName())
)
if (stackframe != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
eoola marked this conversation as resolved.
Show resolved Hide resolved
uri,
'src/support_code_library_builder/get_definition_line_and_uri_spec.ts'
)
assert.strictEqual(line, 7)
})
})