Skip to content

Commit

Permalink
Merge branch 'golang:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
day-dreams committed Jul 26, 2021
2 parents 3cd9332 + 15aaa8c commit 3c9d035
Show file tree
Hide file tree
Showing 37 changed files with 1,412 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-long-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
version: ['stable', 'insiders']
go: ['1.15', '1.16']
go: ['1.15', '1.16', '1.17.0-rc1']

steps:
- name: Clone repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-long.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest] # TODO: reenable macos-latest
version: ['stable']
go: ['1.15', '1.16']
go: ['1.15', '1.16', '1.17.0-rc1']

steps:
- name: Clone repository
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Please note that extra configuration is required to build and run the [Debug Ada

### Setup

1) Install [node](https://nodejs.org/en/).
1) Install [node](https://nodejs.org/en/). Note: make sure that you are using `npm v7` or higher. The file format for `package-lock.json` (changed significantly)[https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json#file-format] in `npm v7`.
2) Clone the repository, run `npm install`, and open VS Code:

```bash
Expand Down
416 changes: 353 additions & 63 deletions docs/dlv-dap.md

Large diffs are not rendered by default.

Binary file added docs/images/attach-terminate.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/attach.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/callstack-section-annotated.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/conditional-breakpoint.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/create-launch-json.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/debug-console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/debug-output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/debug-toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/dlv-load-config-warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/dlvdap-install.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/function-breakpoint.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/invalid-breakpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/panicinfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/remote-debugging.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/shadowed-variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/variable-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/vscode-go-debug-arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ Default:
"tags" : "",
}
```
### `go.terminal.activateEnvironment`

Apply the Go & PATH environment variables used by the extension to all integrated terminals.

Default: `true`
### `go.testEnvFile`

Absolute path to a file containing environment variables definitions. File contents should be of the form key=value.
Expand Down
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ We can't diagnose a problem from just a description. When filing an issue, pleas

1. Your Go version: `go version`
1. Your `gopls` version: `gopls -v version`
1. Your vscode version: `code -v`
1. Your vscode version: `code -v` (The minimum required VS Code version is in the ["engines"](https://github.com/golang/vscode-go/blob/master/package.json#L89) attribute in the package.json file.)
1. Your Go extension version: `Extensions: Show Installed Extensions`
1. Your Go environment: `go env` in the workspace folder
1. Relevant VS Code settings: run `Preferences: Open Settings (JSON)` and include anything in a `[go]` block, and anything that starts with `go.` or `gopls.`
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/golang/vscode-go

go 1.16

require golang.org/x/build v0.0.0-20210617174213-df58bbac082b
632 changes: 632 additions & 0 deletions go.sum

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,12 @@
},
"additionalProperties": true
},
"go.terminal.activateEnvironment": {
"default": true,
"description": "Apply the Go & PATH environment variables used by the extension to all integrated terminals.",
"scope": "resource",
"type": "boolean"
},
"gopls": {
"type": "object",
"markdownDescription": "Configure the default Go language server ('gopls'). In most cases, configuring this section is unnecessary. See [the documentation](https://github.com/golang/tools/blob/master/gopls/doc/settings.md) for all available settings.",
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@ function getConfig(section: string, uri?: vscode.Uri) {
}

// True if the extension is running in known cloud-based IDEs.
export const IsInCloudIDE = process.env.CLOUD_SHELL === 'true' || process.env.CODESPACES === 'true';
export const IsInCloudIDE =
process.env.CLOUD_SHELL === 'true' || process.env.CODESPACES === 'true' || !!process.env.GITPOD_WORKSPACE_ID;
8 changes: 5 additions & 3 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,11 @@ export class Delve {

if (launchArgs.showLog) {
dlvArgs.push('--log=' + launchArgs.showLog.toString());
}
if (launchArgs.logOutput) {
dlvArgs.push('--log-output=' + launchArgs.logOutput);
// Only add the log output flag if we have already added the log flag.
// Otherwise, delve complains.
if (launchArgs.logOutput) {
dlvArgs.push('--log-output=' + launchArgs.logOutput);
}
}
if (launchArgs.cwd) {
dlvArgs.push('--wd=' + launchArgs.cwd);
Expand Down
7 changes: 1 addition & 6 deletions src/goDebugConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,7 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
if (!debugConfiguration.hasOwnProperty('substitutePath') && dlvConfig.hasOwnProperty('substitutePath')) {
debugConfiguration['substitutePath'] = dlvConfig['substitutePath'];
}
if (
debugAdapter !== 'dlv-dap' &&
debugConfiguration.request === 'attach' &&
debugConfiguration.mode === 'remote' &&
!debugConfiguration['cwd']
) {
if (debugAdapter !== 'dlv-dap' && debugConfiguration.request === 'attach' && !debugConfiguration['cwd']) {
debugConfiguration['cwd'] = '${workspaceFolder}';
if (vscode.workspace.workspaceFolders?.length > 1) {
debugConfiguration['cwd'] = '${fileWorkspaceFolder}';
Expand Down
8 changes: 5 additions & 3 deletions src/goDebugFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,11 @@ function spawnDlvDapServerProcess(
dlvArgs.push(`--listen=${host}:${port}`);
if (launchAttachArgs.showLog) {
dlvArgs.push('--log=' + launchAttachArgs.showLog.toString());
}
if (launchAttachArgs.logOutput) {
dlvArgs.push('--log-output=' + launchAttachArgs.logOutput);
// Only add the log output flag if we have already added the log flag.
// Otherwise, delve complains.
if (launchAttachArgs.logOutput) {
dlvArgs.push('--log-output=' + launchAttachArgs.logOutput);
}
}

const onWindows = process.platform === 'win32';
Expand Down
4 changes: 4 additions & 0 deletions src/goEnvironmentStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ export function addGoRuntimeBaseToPATH(newGoRuntimeBase: string) {
if (!newGoRuntimeBase) {
return;
}
const goCfg = getGoConfig();
if (!goCfg.get('terminal.activateEnvironment')) {
return;
}
const pathEnvVar = pathEnvVarName();
if (!pathEnvVar) {
logVerbose("couldn't find PATH property in process.env");
Expand Down
16 changes: 13 additions & 3 deletions src/goTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,22 @@ export async function subTestAtCursor(goConfig: vscode.WorkspaceConfiguration, a
}
}

let subtest: string;
if (!simpleMatch) {
vscode.window.showInformationMessage('No subtest function with a simple subtest name found at cursor.');
return;
const input = await vscode.window.showInputBox({
prompt: 'Enter sub test name'
});
if (input) {
subtest = input;
} else {
vscode.window.showInformationMessage('No subtest function with a simple subtest name found at cursor.');
return;
}
} else {
subtest = simpleMatch[1];
}

const subTestName = testFunctionName + '/' + simpleMatch[1];
const subTestName = testFunctionName + '/' + subtest;

return await runTestAtCursor(editor, subTestName, testFunctions, goConfig, 'test', args);
} catch (err) {
Expand Down
9 changes: 9 additions & 0 deletions test/integration/codelens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,19 @@ suite('Code lenses for testing and benchmarking', function () {
test('Subtests - does nothing for a dynamically defined subtest', async () => {
const editor = await vscode.window.showTextDocument(document);
editor.selection = new vscode.Selection(17, 4, 17, 4);
sinon.stub(vscode.window, 'showInputBox').onFirstCall().resolves(undefined);
const result = await subTestAtCursor(goConfig, []);
assert.equal(result, undefined);
});

test('Subtests - runs a test with curson on t.Run line and dynamic test name is passed in input box', async () => {
const editor = await vscode.window.showTextDocument(document);
editor.selection = new vscode.Selection(17, 4, 17, 4);
sinon.stub(vscode.window, 'showInputBox').onFirstCall().resolves('dynamic test name');
const result = await subTestAtCursor(goConfig, []);
assert.equal(result, false);
});

test('Subtests - does nothing when cursor outside of a test function', async () => {
const editor = await vscode.window.showTextDocument(document);
editor.selection = new vscode.Selection(5, 0, 5, 0);
Expand Down
Loading

0 comments on commit 3c9d035

Please sign in to comment.