Skip to content

respect existing serverReadyAction in launch config #646

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion src/extension/debugger/configuration/resolvers/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
}
const isFastAPI = LaunchConfigurationResolver.isDebuggingFastAPI(debugConfiguration);
const isFlask = LaunchConfigurationResolver.isDebuggingFlask(debugConfiguration);
if (debugConfiguration.autoStartBrowser && (debugConfiguration.django || isFlask)) {
if (
debugConfiguration.autoStartBrowser &&
(debugConfiguration.django || isFlask) &&
!debugConfiguration.serverReadyAction
) {
debugConfiguration.serverReadyAction = {
pattern: '.*(https?:\\/\\/\\S+:[0-9]+\\/?).*',
uriFormat: '%s',
Expand Down
33 changes: 33 additions & 0 deletions src/test/unittest/configuration/resolvers/launch.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,39 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
});
});

test('Preserve serverReadyAction when already defined in configuration', async () => {
const pythonPath = `PythonPath_${new Date().toString()}`;
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
const pythonFile = 'xyz.py';
setupIoc(pythonPath);
setupActiveEditor(pythonFile, PYTHON_LANGUAGE);

const customServerReadyAction = {
pattern: '.*Running on (http://\\S+:[0-9]+).*',
uriFormat: '%s/custom',
action: 'debugWithChrome',
};

testsForautoStartBrowser.forEach(async (testParams) => {
const debugConfig = await resolveDebugConfiguration(workspaceFolder, {
...launch,
...testParams,
serverReadyAction: customServerReadyAction,
});

expect(debugConfig).to.have.property('serverReadyAction', customServerReadyAction);
if (!debugConfig) {
throw new Error('Debug config is undefined');
}
expect(debugConfig.serverReadyAction).to.deep.equal(customServerReadyAction);
expect(debugConfig.serverReadyAction).to.not.deep.equal({
pattern: '.*(https?:\\/\\/\\S+:[0-9]+\\/?).*',
uriFormat: '%s',
action: 'openExternally',
});
});
});

test('Send consoleName value to debugpy as consoleTitle', async () => {
const consoleName = 'My Console Name';
const pythonPath = `PythonPath_${new Date().toString()}`;
Expand Down