Skip to content

Commit 955499e

Browse files
committed
test/integration: fix more tests in windows
Linting test - use 'timeout' instead of 'sleep' in Windows Test diffUtils.getEditsFromUnifiedDiffStr - the test calls 'diff' that is not available in Windows. Skip it. Installation tests - use the correct binary name when checking whether installation has succeeded. Windows binaries use '.exe'. - correct the file proxy url. - file paths in zip should always use /. path.join cleans up to use the platform specific separators. Updates #239 Change-Id: Idcb2f29145e425d70ddd04970fa8c0b1fe2c82b0 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/244768 Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
1 parent ac492ad commit 955499e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

test/integration/extension.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ It returns the number of bytes written and any write error encountered.
374374
buildOnSave: { value: 'package' },
375375
lintOnSave: { value: 'package' },
376376
// simulate a long running lint process by sleeping for a couple seconds
377-
lintTool: { value: 'sleep' },
378-
lintFlags: { value: ['2'] }
377+
lintTool: { value: process.platform !== 'win32' ? 'sleep' : 'timeout' },
378+
lintFlags: { value: process.platform !== 'win32' ? ['2'] : ['/t', 2] }
379379
});
380380

381381
const results = await Promise.all([
@@ -473,7 +473,12 @@ It returns the number of bytes written and any write error encountered.
473473
assert.equal(testFileGenerated, true, 'Test file not generated.');
474474
});
475475

476-
test('Test diffUtils.getEditsFromUnifiedDiffStr', async () => {
476+
test('Test diffUtils.getEditsFromUnifiedDiffStr', async function () {
477+
if (process.platform === 'win32') {
478+
// This test requires diff tool that's not available on windows
479+
this.skip();
480+
}
481+
477482
const file1path = path.join(fixturePath, 'diffTest1Data', 'file1.go');
478483
const file2path = path.join(fixturePath, 'diffTest1Data', 'file2.go');
479484
const file1uri = vscode.Uri.file(file1path);

test/integration/install.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import fs = require('fs');
1010
import os = require('os');
1111
import path = require('path');
1212
import sinon = require('sinon');
13+
import url = require('url');
1314
import util = require('util');
1415
import vscode = require('vscode');
1516
import { toolInstallationEnvironment } from '../../src/goEnv';
1617
import { installTools } from '../../src/goInstallTools';
1718
import { allToolsInformation, getTool, getToolAtVersion } from '../../src/goTools';
1819
import { getBinPath, getGoVersion, rmdirRecursive } from '../../src/util';
20+
import { correctBinname } from '../../src/utils/goPath';
1921

2022
suite('Installation Tests', function () {
2123
// Disable timeout when we are running slow tests.
@@ -71,7 +73,7 @@ suite('Installation Tests', function () {
7173
const goConfig = Object.create(vscode.workspace.getConfiguration('go'), {
7274
toolsEnvVars: {
7375
value: {
74-
GOPROXY: `file://${proxyDir}`,
76+
GOPROXY: url.pathToFileURL(proxyDir),
7577
GOSUMDB: 'off',
7678
}
7779
},
@@ -93,7 +95,7 @@ suite('Installation Tests', function () {
9395
for (const tool of testCases) {
9496
checks.push(new Promise<void>(async (resolve) => {
9597
// Check that the expect tool has been installed to $GOPATH/bin.
96-
const ok = await exists(path.join(tmpToolsGopath, 'bin', tool));
98+
const ok = await exists(path.join(tmpToolsGopath, 'bin', correctBinname(tool)));
9799
if (!ok) {
98100
assert.fail(`expected ${tmpToolsGopath}/bin/${tool}, not found`);
99101
}
@@ -152,7 +154,7 @@ function buildFakeProxy(tools: string[]) {
152154
// Write the zip file.
153155
const zip = new AdmZip();
154156
const content = `package main; func main() {};`;
155-
zip.addFile(path.join(`${module}@${version}`, 'main.go'), Buffer.alloc(content.length, content));
157+
zip.addFile(`${module}@${version}/main.go`, Buffer.alloc(content.length, content));
156158
zip.writeZip(path.join(dir, `${version}.zip`));
157159
}
158160
return proxyDir;

0 commit comments

Comments
 (0)