|
7 | 7 | import assert from 'assert'; |
8 | 8 | import * as path from 'path'; |
9 | 9 | import * as vscode from 'vscode'; |
10 | | -import { getGoConfig } from '../../src/config'; |
11 | 10 | import sinon = require('sinon'); |
12 | 11 | import { getGoVersion, GoVersion } from '../../src/util'; |
13 | 12 | import { GOPLS_MAYBE_PROMPT_FOR_TELEMETRY, recordTelemetryStartTime, TelemetryService } from '../../src/goTelemetry'; |
@@ -159,48 +158,6 @@ suite('Go Extension Tests With Gopls', function () { |
159 | 158 | } |
160 | 159 | }); |
161 | 160 |
|
162 | | - async function testCustomFormatter(goConfig: vscode.WorkspaceConfiguration, customFormatter: string) { |
163 | | - const config = require('../../src/config'); |
164 | | - sandbox.stub(config, 'getGoConfig').returns(goConfig); |
165 | | - const workspaceDir = path.resolve(testdataDir, 'gogetdocTestData'); |
166 | | - await env.startGopls(path.join(workspaceDir, 'test.go'), goConfig, workspaceDir); |
167 | | - const { doc } = await env.openDoc(testdataDir, 'gogetdocTestData', 'format.go'); |
168 | | - await vscode.window.showTextDocument(doc); |
169 | | - |
170 | | - const formatFeature = env.languageClient?.getFeature('textDocument/formatting'); |
171 | | - const formatter = formatFeature?.getProvider(doc); |
172 | | - const tokensrc = new vscode.CancellationTokenSource(); |
173 | | - try { |
174 | | - const result = await formatter?.provideDocumentFormattingEdits( |
175 | | - doc, |
176 | | - {} as vscode.FormattingOptions, |
177 | | - tokensrc.token |
178 | | - ); |
179 | | - assert.fail(`formatter unexpectedly succeeded and returned a result: ${JSON.stringify(result)}`); |
180 | | - } catch (e) { |
181 | | - assert(`${e}`.includes(`errors when formatting with ${customFormatter}`), `${e}`); |
182 | | - } |
183 | | - } |
184 | | - |
185 | | - test('Nonexistent formatter', async () => { |
186 | | - const customFormatter = 'nonexistent'; |
187 | | - const goConfig = Object.create(getGoConfig(), { |
188 | | - formatTool: { value: customFormatter } // this should make the formatter fail. |
189 | | - }) as vscode.WorkspaceConfiguration; |
190 | | - |
191 | | - await testCustomFormatter(goConfig, customFormatter); |
192 | | - }); |
193 | | - |
194 | | - test('Custom formatter', async () => { |
195 | | - const customFormatter = 'coolCustomFormatter'; |
196 | | - const goConfig = Object.create(getGoConfig(), { |
197 | | - formatTool: { value: 'custom' }, // this should make the formatter fail. |
198 | | - alternateTools: { value: { customFormatter: customFormatter } } // this should make the formatter fail. |
199 | | - }) as vscode.WorkspaceConfiguration; |
200 | | - |
201 | | - await testCustomFormatter(goConfig, customFormatter); |
202 | | - }); |
203 | | - |
204 | 161 | test('Prompt For telemetry', async () => { |
205 | 162 | const workspaceDir = path.resolve(testdataDir, 'gogetdocTestData'); |
206 | 163 | await env.startGopls(path.join(workspaceDir, 'test.go'), undefined, workspaceDir); |
|
0 commit comments