Skip to content

Commit

Permalink
Fix slashes in telemetry unit tests (microsoft#11572)
Browse files Browse the repository at this point in the history
* Fix slashes

* Don't use fix path, replace sep directly
  • Loading branch information
kimadeline committed May 5, 2020
1 parent 49434e2 commit 7431c9c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
57 changes: 29 additions & 28 deletions src/test/telemetry/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,23 @@ suite('Telemetry', () => {
test('Send Error Telemetry with stack trace', () => {
rewiremock.enable();
const error = new Error('Boo');
const root = EXTENSION_ROOT_DIR.replace(/\\/g, '/');
error.stack = [
'Error: Boo',
`at Context.test (${EXTENSION_ROOT_DIR}/src/test/telemetry/index.unit.test.ts:50:23)`,
`at callFn (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:372:21)`,
`at Test.Runnable.run (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:364:7)`,
`at Runner.runTest (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:455:10)`,
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:573:12`,
`at next (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:369:14)`,
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:379:7`,
`at next (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:303:14)`,
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:342:7`,
`at done (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:319:5)`,
`at callFn (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:395:7)`,
`at Hook.Runnable.run (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:364:7)`,
`at next (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:317:10)`,
`at Immediate.<anonymous> (${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:347:5)`,
`at Context.test (${root}/src/test/telemetry/index.unit.test.ts:50:23)`,
`at callFn (${root}/node_modules/mocha/lib/runnable.js:372:21)`,
`at Test.Runnable.run (${root}/node_modules/mocha/lib/runnable.js:364:7)`,
`at Runner.runTest (${root}/node_modules/mocha/lib/runner.js:455:10)`,
`at ${root}/node_modules/mocha/lib/runner.js:573:12`,
`at next (${root}/node_modules/mocha/lib/runner.js:369:14)`,
`at ${root}/node_modules/mocha/lib/runner.js:379:7`,
`at next (${root}/node_modules/mocha/lib/runner.js:303:14)`,
`at ${root}/node_modules/mocha/lib/runner.js:342:7`,
`at done (${root}/node_modules/mocha/lib/runnable.js:319:5)`,
`at callFn (${root}/node_modules/mocha/lib/runnable.js:395:7)`,
`at Hook.Runnable.run (${root}/node_modules/mocha/lib/runnable.js:364:7)`,
`at next (${root}/node_modules/mocha/lib/runner.js:317:10)`,
`at Immediate.<anonymous> (${root}/node_modules/mocha/lib/runner.js:347:5)`,
'at runCallback (timers.js:789:20)',
'at tryOnImmediate (timers.js:751:5)',
'at processImmediate [as _immediateCallback] (timers.js:722:5)'
Expand Down Expand Up @@ -181,20 +182,20 @@ suite('Telemetry', () => {
expect(Reporter.errorProps).to.deep.equal([]);

const expectedStack = [
`at Context.test ${EXTENSION_ROOT_DIR}/src/test/telemetry/index.unit.test.ts:50:23`,
`at callFn ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:372:21`,
`at Test.Runnable.run ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:364:7`,
`at Runner.runTest ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:455:10`,
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:573:12`,
`at next ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:369:14`,
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:379:7`,
`at next ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:303:14`,
`at ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:342:7`,
`at done ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:319:5`,
`at callFn ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:395:7`,
`at Hook.Runnable.run ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runnable.js:364:7`,
`at next ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:317:10`,
`at Immediate ${EXTENSION_ROOT_DIR}/node_modules/mocha/lib/runner.js:347:5`,
`at Context.test ${root}/src/test/telemetry/index.unit.test.ts:50:23`,
`at callFn ${root}/node_modules/mocha/lib/runnable.js:372:21`,
`at Test.Runnable.run ${root}/node_modules/mocha/lib/runnable.js:364:7`,
`at Runner.runTest ${root}/node_modules/mocha/lib/runner.js:455:10`,
`at ${root}/node_modules/mocha/lib/runner.js:573:12`,
`at next ${root}/node_modules/mocha/lib/runner.js:369:14`,
`at ${root}/node_modules/mocha/lib/runner.js:379:7`,
`at next ${root}/node_modules/mocha/lib/runner.js:303:14`,
`at ${root}/node_modules/mocha/lib/runner.js:342:7`,
`at done ${root}/node_modules/mocha/lib/runnable.js:319:5`,
`at callFn ${root}/node_modules/mocha/lib/runnable.js:395:7`,
`at Hook.Runnable.run ${root}/node_modules/mocha/lib/runnable.js:364:7`,
`at next ${root}/node_modules/mocha/lib/runner.js:317:10`,
`at Immediate ${root}/node_modules/mocha/lib/runner.js:347:5`,
'at runCallback timers.js:789:20',
'at tryOnImmediate timers.js:751:5',
'at processImmediate [as _immediateCallback] timers.js:722:5'
Expand Down
2 changes: 1 addition & 1 deletion src/test/testing/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function lookForTestFile(tests: Tests, testFile: string) {
// Only "/" (forward slash) in the given filename is affected.
//
// This helps with readability in test code. It allows us to use
// literals for filenames and dirnames instead of oath.join().
// literals for filenames and dirnames instead of path.join().
export function fixPath(filename: string): string {
return filename.replace(/\//, sep);
}
Expand Down

0 comments on commit 7431c9c

Please sign in to comment.