-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for debuggable web tests (#10326)
- Loading branch information
1 parent
0e90086
commit 0700879
Showing
10 changed files
with
165 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
|
||
try { | ||
const file = path.join(__dirname, '..', 'temp', 'jupyter.pid'); | ||
if (fs.existsSync(file)) { | ||
const pid = parseInt(fs.readFileSync(file).toString().trim()); | ||
fs.unlinkSync(file); | ||
if (pid > 0) { | ||
process.kill(pid); | ||
} | ||
} | ||
} catch (ex) { | ||
console.warn(`Failed to kill Jupyter Server`, ex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
const { startJupyter } = require('./preLaunchWebTest'); | ||
const jsonc = require('jsonc-parser'); | ||
|
||
const settingsFile = path.join(__dirname, '..', 'src', 'test', 'datascience', '.vscode', 'settings.json'); | ||
async function go() { | ||
const { server, url } = await startJupyter(true); | ||
fs.writeFileSync(path.join(__dirname, '..', 'temp', 'jupyter.pid'), server.pid.toString()); | ||
const settingsJson = fs.readFileSync(settingsFile).toString(); | ||
const edits = jsonc.modify(settingsJson, ['jupyter.DEBUG_JUPYTER_SERVER_URI'], url, {}); | ||
const updatedSettingsJson = jsonc.applyEdits(settingsJson, edits); | ||
fs.writeFileSync(settingsFile, updatedSettingsJson); | ||
process.exit(0); | ||
} | ||
void go(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
const path = require('path'); | ||
const jupyterServer = require('../out/test/datascience/jupyterServer.node'); | ||
const fs = require('fs-extra'); | ||
|
||
exports.startJupyter = async function startJupyter(detached) { | ||
const server = jupyterServer.JupyterServer.instance; | ||
// Need to start jupyter here before starting the test as it requires node to start it. | ||
const uri = await server.startJupyterWithToken({ detached }); | ||
|
||
// Use this token to write to the bundle so we can transfer this into the test. | ||
const extensionDevelopmentPath = path.resolve(__dirname, '../'); | ||
const bundlePath = path.join(extensionDevelopmentPath, 'out', 'extension.web.bundle'); | ||
const bundleFile = `${bundlePath}.js`; | ||
if (await fs.pathExists(bundleFile)) { | ||
const bundleContents = await fs.readFile(bundleFile, { encoding: 'utf-8' }); | ||
const newContents = bundleContents.replace( | ||
/^exports\.JUPYTER_SERVER_URI = '(.*)';$/gm, | ||
`exports.JUPYTER_SERVER_URI = '${uri.toString()}';` | ||
); | ||
if (newContents === bundleContents) { | ||
throw new Error('JUPYTER_SERVER_URI in bundle not updated'); | ||
} | ||
await fs.writeFile(bundleFile, newContents); | ||
} | ||
return { server, url: uri.toString() }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters