Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Add auto test debug mode for launch.json (#1780) #1832

Merged
merged 2 commits into from
Aug 10, 2018

Conversation

prism4time
Copy link
Contributor

use regex to check if the current file is for test

let debugMode;
let testFileRegExp = RegExp('.*_test\.go$', 'g');
const currentFileName = vscode.window.activeTextEditor.document.fileName;
if (testFileRegExp.test(currentFileName)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isnt it simpler with if (activeEditor.document.fileName.endsWith('_test.go')) ?
I have a tendency to avoid regex when possible.

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still using regex ...

@prism4time prism4time force-pushed the auto-test-debug-mode branch from 8cea511 to 39b3d17 Compare August 10, 2018 00:40
@@ -54,6 +54,12 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
debugConfiguration['dlvLoadConfig'] = dlvConfig['dlvLoadConfig'];
}

if (activeEditor.document.fileName.endsWith('_test.go')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The activeEditor can be null

if (activeEditor.document.fileName.endsWith('_test.go')) {
debugConfiguration['mode'] = 'test';
} else {
debugConfiguration['mode'] = 'debug';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need the else here?

@prism4time prism4time force-pushed the auto-test-debug-mode branch from 5395b14 to 21d2e08 Compare August 10, 2018 03:28
Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, Thanks!

@ramya-rao-a ramya-rao-a merged commit 9cc625e into microsoft:master Aug 10, 2018
@ramya-rao-a
Copy link
Contributor

Fixes #1780

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants