Skip to content

Commit 7431c9c

Browse files
authored
Fix slashes in telemetry unit tests (#11572)
* Fix slashes * Don't use fix path, replace sep directly
1 parent 49434e2 commit 7431c9c

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

src/test/telemetry/index.unit.test.ts

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,23 @@ suite('Telemetry', () => {
138138
test('Send Error Telemetry with stack trace', () => {
139139
rewiremock.enable();
140140
const error = new Error('Boo');
141+
const root = EXTENSION_ROOT_DIR.replace(/\\/g, '/');
141142
error.stack = [
142143
'Error: Boo',
143-
`at Context.test (${EXTENSION_ROOT_DIR}/src/test/telemetry/index.unit.test.ts:50:23)`,
144-
`at callFn (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:372:21)`,
145-
`at Test.Runnable.run (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:364:7)`,
146-
`at Runner.runTest (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:455:10)`,
147-
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:573:12`,
148-
`at next (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:369:14)`,
149-
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:379:7`,
150-
`at next (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:303:14)`,
151-
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:342:7`,
152-
`at done (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:319:5)`,
153-
`at callFn (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:395:7)`,
154-
`at Hook.Runnable.run (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:364:7)`,
155-
`at next (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:317:10)`,
156-
`at Immediate.<anonymous> (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:347:5)`,
144+
`at Context.test (${root}/src/test/telemetry/index.unit.test.ts:50:23)`,
145+
`at callFn (${root}/node_modules/mocha/lib/runnable.js:372:21)`,
146+
`at Test.Runnable.run (${root}/node_modules/mocha/lib/runnable.js:364:7)`,
147+
`at Runner.runTest (${root}/node_modules/mocha/lib/runner.js:455:10)`,
148+
`at ${root}/node_modules/mocha/lib/runner.js:573:12`,
149+
`at next (${root}/node_modules/mocha/lib/runner.js:369:14)`,
150+
`at ${root}/node_modules/mocha/lib/runner.js:379:7`,
151+
`at next (${root}/node_modules/mocha/lib/runner.js:303:14)`,
152+
`at ${root}/node_modules/mocha/lib/runner.js:342:7`,
153+
`at done (${root}/node_modules/mocha/lib/runnable.js:319:5)`,
154+
`at callFn (${root}/node_modules/mocha/lib/runnable.js:395:7)`,
155+
`at Hook.Runnable.run (${root}/node_modules/mocha/lib/runnable.js:364:7)`,
156+
`at next (${root}/node_modules/mocha/lib/runner.js:317:10)`,
157+
`at Immediate.<anonymous> (${root}/node_modules/mocha/lib/runner.js:347:5)`,
157158
'at runCallback (timers.js:789:20)',
158159
'at tryOnImmediate (timers.js:751:5)',
159160
'at processImmediate [as _immediateCallback] (timers.js:722:5)'
@@ -181,20 +182,20 @@ suite('Telemetry', () => {
181182
expect(Reporter.errorProps).to.deep.equal([]);
182183

183184
const expectedStack = [
184-
`at Context.test ${EXTENSION_ROOT_DIR}/src/test/telemetry/index.unit.test.ts:50:23`,
185-
`at callFn ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:372:21`,
186-
`at Test.Runnable.run ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:364:7`,
187-
`at Runner.runTest ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:455:10`,
188-
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:573:12`,
189-
`at next ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:369:14`,
190-
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:379:7`,
191-
`at next ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:303:14`,
192-
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:342:7`,
193-
`at done ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:319:5`,
194-
`at callFn ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:395:7`,
195-
`at Hook.Runnable.run ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:364:7`,
196-
`at next ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:317:10`,
197-
`at Immediate ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:347:5`,
185+
`at Context.test ${root}/src/test/telemetry/index.unit.test.ts:50:23`,
186+
`at callFn ${root}/node_modules/mocha/lib/runnable.js:372:21`,
187+
`at Test.Runnable.run ${root}/node_modules/mocha/lib/runnable.js:364:7`,
188+
`at Runner.runTest ${root}/node_modules/mocha/lib/runner.js:455:10`,
189+
`at ${root}/node_modules/mocha/lib/runner.js:573:12`,
190+
`at next ${root}/node_modules/mocha/lib/runner.js:369:14`,
191+
`at ${root}/node_modules/mocha/lib/runner.js:379:7`,
192+
`at next ${root}/node_modules/mocha/lib/runner.js:303:14`,
193+
`at ${root}/node_modules/mocha/lib/runner.js:342:7`,
194+
`at done ${root}/node_modules/mocha/lib/runnable.js:319:5`,
195+
`at callFn ${root}/node_modules/mocha/lib/runnable.js:395:7`,
196+
`at Hook.Runnable.run ${root}/node_modules/mocha/lib/runnable.js:364:7`,
197+
`at next ${root}/node_modules/mocha/lib/runner.js:317:10`,
198+
`at Immediate ${root}/node_modules/mocha/lib/runner.js:347:5`,
198199
'at runCallback timers.js:789:20',
199200
'at tryOnImmediate timers.js:751:5',
200201
'at processImmediate [as _immediateCallback] timers.js:722:5'

src/test/testing/helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function lookForTestFile(tests: Tests, testFile: string) {
3232
// Only "/" (forward slash) in the given filename is affected.
3333
//
3434
// This helps with readability in test code. It allows us to use
35-
// literals for filenames and dirnames instead of oath.join().
35+
// literals for filenames and dirnames instead of path.join().
3636
export function fixPath(filename: string): string {
3737
return filename.replace(/\//, sep);
3838
}

0 commit comments

Comments
 (0)