* Runs a script in a separate workspace (i.e. a different 'remoteRoot') * from the original file, by copying the containing folder of the file * into a temporary directory.
(
filename: string,
options: Partial<INodeLaunchConfiguration> = {},
)
| 479 | * into a temporary directory. |
| 480 | */ |
| 481 | async runScriptAsRemote( |
| 482 | filename: string, |
| 483 | options: Partial<INodeLaunchConfiguration> = {}, |
| 484 | ): Promise<NodeTestHandle> { |
| 485 | await this.initialize; |
| 486 | |
| 487 | filename = path.isAbsolute(filename) ? filename : path.join(testFixturesDir, filename); |
| 488 | let tmpPath = path.join(tmpdir(), 'js-debug-test'); |
| 489 | if (process.platform === 'darwin' && tmpPath.startsWith('/var/folders')) { |
| 490 | // on OSX, tmpdir is 'virtually' inside /private. os.tmpdir() omits the |
| 491 | // private prefix, but Chrome sees it, so make sure it matches here. |
| 492 | tmpPath = `/private/${tmpPath}`; |
| 493 | } |
| 494 | after(() => del(`${forceForwardSlashes(tmpPath)}/**`, { force: true })); |
| 495 | |
| 496 | await new Promise((resolve, reject) => |
| 497 | gulp |
| 498 | .src('**/*.*', { cwd: path.dirname(filename) }) |
| 499 | .pipe(gulp.dest(tmpPath)) |
| 500 | .on('end', resolve) |
| 501 | .on('error', reject), |
| 502 | ); |
| 503 | |
| 504 | this._root.dap.launch({ |
| 505 | ...nodeLaunchConfigDefaults, |
| 506 | cwd: path.dirname(testFixturesDir), |
| 507 | program: path.join(tmpPath, path.basename(filename)), |
| 508 | localRoot: path.dirname(filename), |
| 509 | remoteRoot: tmpPath, |
| 510 | trace: { logFile: getLogFileForTest(this._testTitlePath) }, |
| 511 | outFiles: [], |
| 512 | resolveSourceMapLocations: ['**', '!**/node_modules/**'], |
| 513 | env: { |
| 514 | NODE_PATH: [ |
| 515 | process.env.NODE_PATH, |
| 516 | path.resolve(path.dirname(filename), 'node_modules'), |
| 517 | path.resolve(workspaceFolder, 'node_modules'), |
| 518 | ] |
| 519 | .filter(Boolean) |
| 520 | .join(process.platform === 'win32' ? ';' : ':'), |
| 521 | }, |
| 522 | __workspaceFolder: this._workspaceRoot, |
| 523 | ...options, |
| 524 | } as INodeLaunchConfiguration); |
| 525 | |
| 526 | const result = await new Promise(f => (this._launchCallback = f)); |
| 527 | return result as NodeTestHandle; |
| 528 | } |
| 529 | |
| 530 | async attachNode( |
| 531 | processId: number, |
no test coverage detected