Skip to content

Commit

Permalink
test: rename testfixtures and fixtures to testdata
Browse files Browse the repository at this point in the history
Currently, the fixtures are showing errors if gopls is enabled, which
clutters the problems view. The go command ignores directories named
testdata, so rename the test directories to "testdata".

Change-Id: I4218fc044e60ab022abae88e75b9f51d3cdc031d
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/264324
Run-TryBot: Rebecca Stambler <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
Trust: Hyang-Ah Hana Kim <[email protected]>
Trust: Rebecca Stambler <[email protected]>
  • Loading branch information
stamblerre committed Oct 23, 2020
1 parent 186ffe2 commit 46f249d
Show file tree
Hide file tree
Showing 65 changed files with 61 additions and 56 deletions.
6 changes: 3 additions & 3 deletions test/gopls/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Env {
// https://github.com/microsoft/vscode/blob/890f62dfd9f3e70198931f788c5c332b3e8b7ad7/src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.ts#L281
//
// So, when we start the gopls tests, we start the test extension host with a
// dummy workspace, ${projectDir}/test/gopls/testfixtures/src/workspace
// dummy workspace, ${projectDir}/test/gopls/testdata/src/workspace
// (see test/runTest.ts and launch.json).
// Then copy necessary files to the workspace using Env.reset() from the
// fixturesRoot directory.
Expand All @@ -59,8 +59,8 @@ class Env {
if (!projectDir) {
assert.fail('project directory cannot be determined');
}
this.workspaceDir = path.resolve(projectDir, 'test/gopls/testfixtures/src/workspace');
this.fixturesRoot = path.resolve(projectDir, 'test/fixtures');
this.workspaceDir = path.resolve(projectDir, 'test/gopls/testdata/src/workspace');
this.fixturesRoot = path.resolve(projectDir, 'test/testdata');
this.extension = vscode.extensions.getExtension(extensionId);
this.fakeOutputChannel = new FakeOutputChannel();

Expand Down
2 changes: 1 addition & 1 deletion test/integration/codelens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ suite('Code lenses for testing and benchmarking', function () {
// Set up the test fixtures.
repoPath = path.join(gopath, 'src', 'test');
fixturePath = path.join(repoPath, 'testfixture');
fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'fixtures', 'codelens');
fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'testdata', 'codelens');

fs.removeSync(repoPath);
fs.copySync(fixtureSourcePath, fixturePath, {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ suite('Coverage for tests', function () {
await updateGoVarsFromConfig();

// Set up the test fixtures.
fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'fixtures', 'coverage');
fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'testdata', 'coverage');
coverFilePath = path.join(fixtureSourcePath, 'cover.out');
return;
});
Expand Down
5 changes: 2 additions & 3 deletions test/integration/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ suite('Go Extension Tests', function () {

repoPath = path.join(gopath, 'src', 'test');
fixturePath = path.join(repoPath, 'testfixture');
fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'fixtures');
fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'testdata');
generateTestsSourcePath = path.join(repoPath, 'generatetests');
generateFunctionTestSourcePath = path.join(repoPath, 'generatefunctiontest');
generatePackageTestSourcePath = path.join(repoPath, 'generatePackagetest');
Expand Down Expand Up @@ -1245,8 +1245,7 @@ encountered.
assert.equal(
expected.length,
labels.length,
`expected number of completions: ${expected.length} Actual: ${labels.length} at position(${
position.line + 1
`expected number of completions: ${expected.length} Actual: ${labels.length} at position(${position.line + 1
},${position.character + 1}) ${labels}`
);
expected.forEach((entry, index) => {
Expand Down
46 changes: 23 additions & 23 deletions test/integration/goDebug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import * as fs from 'fs';
import * as path from 'path';
import { stringify } from 'querystring';
import * as sinon from 'sinon';
import {DebugClient} from 'vscode-debugadapter-testsupport';
import {DebugProtocol} from 'vscode-debugprotocol';
import { DebugClient } from 'vscode-debugadapter-testsupport';
import { DebugProtocol } from 'vscode-debugprotocol';
import {
Delve,
escapeGoModPath,
Expand Down Expand Up @@ -281,11 +281,11 @@ suite('Go Debug Adapter', function () {
const DEBUG_ADAPTER = path.join('.', 'out', 'src', 'debugAdapter', 'goDebug.js');

const PROJECT_ROOT = path.normalize(path.join(__dirname, '..', '..', '..'));
const DATA_ROOT = path.join(PROJECT_ROOT, 'test', 'fixtures');
const DATA_ROOT = path.join(PROJECT_ROOT, 'test', 'testdata');

let dc: DebugClient;

setup( () => {
setup(() => {
dc = new DebugClient('node', path.join(PROJECT_ROOT, DEBUG_ADAPTER), 'go');

// Launching delve may take longer than the default timeout of 5000.
Expand All @@ -295,7 +295,7 @@ suite('Go Debug Adapter', function () {
return dc.start();
});

teardown( () => dc.stop() );
teardown(() => dc.stop());

/**
* Helper function to assert that a variable has a particular value.
Expand All @@ -311,9 +311,9 @@ suite('Go Debug Adapter', function () {
async function assertVariableValue(name: string, val: string): Promise<void> {
const threadsResponse = await dc.threadsRequest();
assert(threadsResponse.success);
const stackTraceResponse = await dc.stackTraceRequest({threadId: threadsResponse.body.threads[0].id});
const stackTraceResponse = await dc.stackTraceRequest({ threadId: threadsResponse.body.threads[0].id });
assert(stackTraceResponse.success);
const scopesResponse = await dc.scopesRequest({frameId: stackTraceResponse.body.stackFrames[0].id});
const scopesResponse = await dc.scopesRequest({ frameId: stackTraceResponse.body.stackFrames[0].id });
assert(scopesResponse.success);
const variablesResponse = await dc.variablesRequest({
variablesReference: scopesResponse.body.scopes[0].variablesReference
Expand Down Expand Up @@ -476,8 +476,8 @@ suite('Go Debug Adapter', function () {
// The file paths returned from delve use '/' not the native path
// separator, so we can replace any instances of '\' with '/', which
// allows the hitBreakpoint check to match.
const getBreakpointLocation = (FILE: string, LINE: number) => {
return {path: FILE.replace(/\\/g, '/'), line: LINE };
const getBreakpointLocation = (FILE: string, LINE: number) => {
return { path: FILE.replace(/\\/g, '/'), line: LINE };
};

suite('setBreakpoints', () => {
Expand All @@ -498,7 +498,7 @@ suite('Go Debug Adapter', function () {
};
const debugConfig = debugConfigProvider.resolveDebugConfiguration(undefined, config);

return dc.hitBreakpoint(debugConfig, getBreakpointLocation(FILE, BREAKPOINT_LINE) );
return dc.hitBreakpoint(debugConfig, getBreakpointLocation(FILE, BREAKPOINT_LINE));
});

test('should stop on a breakpoint in test file', () => {
Expand All @@ -517,7 +517,7 @@ suite('Go Debug Adapter', function () {
};
const debugConfig = debugConfigProvider.resolveDebugConfiguration(undefined, config);

return dc.hitBreakpoint(debugConfig, getBreakpointLocation(FILE, BREAKPOINT_LINE) );
return dc.hitBreakpoint(debugConfig, getBreakpointLocation(FILE, BREAKPOINT_LINE));
});

});
Expand All @@ -542,8 +542,8 @@ suite('Go Debug Adapter', function () {

dc.waitForEvent('initialized').then(() => {
return dc.setBreakpointsRequest({
lines: [ location.line ],
breakpoints: [ { line: location.line, condition: 'i == 2' } ],
lines: [location.line],
breakpoints: [{ line: location.line, condition: 'i == 2' }],
source: { path: location.path }
});
}).then(() => {
Expand Down Expand Up @@ -582,12 +582,12 @@ suite('Go Debug Adapter', function () {
).then(() =>
// Add a condition to the breakpoint, and make sure it runs until 'i == 2'.
dc.setBreakpointsRequest({
lines: [ location.line ],
breakpoints: [ { line: location.line, condition: 'i == 2' } ],
lines: [location.line],
breakpoints: [{ line: location.line, condition: 'i == 2' }],
source: { path: location.path }
}).then(() =>
Promise.all([
dc.continueRequest({threadId: 1}),
dc.continueRequest({ threadId: 1 }),
dc.assertStoppedLocation('breakpoint', location)
]).then(() =>
// The program is stopped at the breakpoint, check to make sure 'i == 2'.
Expand Down Expand Up @@ -616,8 +616,8 @@ suite('Go Debug Adapter', function () {

dc.waitForEvent('initialized').then(() => {
return dc.setBreakpointsRequest({
lines: [ location.line ],
breakpoints: [ { line: location.line, condition: 'i == 2' } ],
lines: [location.line],
breakpoints: [{ line: location.line, condition: 'i == 2' }],
source: { path: location.path }
});
}).then(() => {
Expand All @@ -634,12 +634,12 @@ suite('Go Debug Adapter', function () {
).then(() =>
// Remove the breakpoint condition, and make sure the program runs until 'i == 3'.
dc.setBreakpointsRequest({
lines: [ location.line ],
breakpoints: [ { line: location.line } ],
lines: [location.line],
breakpoints: [{ line: location.line }],
source: { path: location.path }
}).then(() =>
Promise.all([
dc.continueRequest({threadId: 1}),
dc.continueRequest({ threadId: 1 }),
dc.assertStoppedLocation('breakpoint', location)
]).then(() =>
// The program is stopped at the breakpoint, check to make sure 'i == 3'.
Expand Down Expand Up @@ -669,15 +669,15 @@ suite('Go Debug Adapter', function () {

dc.waitForEvent('initialized').then(() => {
return dc.setExceptionBreakpointsRequest({
filters: [ 'all' ]
filters: ['all']
});
}).then(() => {
return dc.configurationDoneRequest();
}),

dc.launch(debugConfig),

dc.assertStoppedLocation('panic', {} )
dc.assertStoppedLocation('panic', {})
]);
});
});
Expand Down
38 changes: 22 additions & 16 deletions test/integration/goDebugConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ suite('Debug Environment Variable Merge Test', () => {
await updateGoVarsFromConfig();

// Set up the test fixtures.
const fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'fixtures');
const fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'testdata');
const filePath = path.join(fixtureSourcePath, 'baseTest', 'test.go');
await vscode.workspace.openTextDocument(vscode.Uri.file(filePath));
});
Expand All @@ -41,11 +41,11 @@ suite('Debug Environment Variable Merge Test', () => {

interface Input {
env?: { [key: string]: any };
envFile?: string|string[];
toolsEnv?: { [key: string]: any};
envFile?: string | string[];
toolsEnv?: { [key: string]: any };
}

function runTest(input: Input, expected: { [key: string]: any}) {
function runTest(input: Input, expected: { [key: string]: any }) {
sandbox.stub(goEnv, 'toolExecutionEnvironment').returns(input.toolsEnv || {});
const config = debugConfigProvider.resolveDebugConfigurationWithSubstitutedVariables(undefined, {
type: 'go',
Expand All @@ -66,36 +66,40 @@ suite('Debug Environment Variable Merge Test', () => {
test('toolsEnvVars is propagated', () => {
const toolsEnv = {
GOPATH: '/gopath',
GOOS: 'valueFromToolsEnv'};
GOOS: 'valueFromToolsEnv'
};

runTest({toolsEnv}, {
runTest({ toolsEnv }, {
GOPATH: '/gopath',
GOOS: 'valueFromToolsEnv'});
GOOS: 'valueFromToolsEnv'
});
});

test('preserves settings from launchArgs.env', () => {
const env = {GOPATH: 'valueFromEnv', GOOS: 'valueFromEnv2'};
runTest({env}, {
const env = { GOPATH: 'valueFromEnv', GOOS: 'valueFromEnv2' };
runTest({ env }, {
GOPATH: 'valueFromEnv',
GOOS: 'valueFromEnv2'});
GOOS: 'valueFromEnv2'
});
});

test('preserves settings from launchArgs.envFile', () => {
const envFile = path.join(tmpDir, 'env');
fs.writeFileSync(envFile, 'GOPATH=valueFromEnvFile');
runTest({envFile}, {GOPATH: 'valueFromEnvFile'});
runTest({ envFile }, { GOPATH: 'valueFromEnvFile' });
});

test('launchArgs.env overwrites launchArgs.envFile', () => {
const env = {SOMEVAR1: 'valueFromEnv'};
const env = { SOMEVAR1: 'valueFromEnv' };
const envFile = path.join(tmpDir, 'env');
fs.writeFileSync(envFile, [
'SOMEVAR1=valueFromEnvFile1',
'SOMEVAR2=valueFromEnvFile2'].join('\n'));

runTest({ env, envFile }, {
SOMEVAR1: 'valueFromEnv',
SOMEVAR2: 'valueFromEnvFile2'});
SOMEVAR2: 'valueFromEnvFile2'
});
});

test('launchArgs.env overwrites toolsEnvVar', () => {
Expand All @@ -105,11 +109,12 @@ suite('Debug Environment Variable Merge Test', () => {
SOMEVAR2: 'valueFromToolsEnvVar2'
};

const env = {SOMEVAR1: 'valueFromEnv'};
const env = { SOMEVAR1: 'valueFromEnv' };
runTest({ env, toolsEnv }, {
GOPATH: '/gopath',
SOMEVAR1: 'valueFromEnv',
SOMEVAR2: 'valueFromToolsEnvVar2'});
SOMEVAR2: 'valueFromToolsEnvVar2'
});
});

test('launchArgs.envFile overwrites toolsEnvVar', () => {
Expand All @@ -125,6 +130,7 @@ suite('Debug Environment Variable Merge Test', () => {
runTest({ toolsEnv, envFile }, {
GOPATH: '/gopath',
SOMEVAR1: 'valueFromToolsEnvVar1',
SOMEVAR2: 'valueFromEnvFile2'});
SOMEVAR2: 'valueFromEnvFile2'
});
});
});
2 changes: 1 addition & 1 deletion test/integration/statusbar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('#updateGoVarsFromConfig()', async function () {
// build a fake go binary and place it in tmpRootBin.
fs.mkdirSync(tmpRootBin);

const fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'fixtures', 'testhelpers');
const fixtureSourcePath = path.join(__dirname, '..', '..', '..', 'test', 'testdata', 'testhelpers');
const execFile = util.promisify(cp.execFile);
const goRuntimePath = ourutil.getBinPath('go');
const { stderr } = await execFile(
Expand Down
8 changes: 4 additions & 4 deletions test/integration/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { rmdirRecursive } from '../../src/util';
suite('Test Go Test', function () {
this.timeout(10000);

const sourcePath = path.join(__dirname, '..', '..', '..', 'test', 'fixtures', 'goTestTest');
const sourcePath = path.join(__dirname, '..', '..', '..', 'test', 'testdata', 'goTestTest');

let tmpGopath: string;
let repoPath: string;
Expand Down Expand Up @@ -50,7 +50,7 @@ suite('Test Go Test', function () {
}

async function runTest(
input: { isMod: boolean, includeSubDirectories: boolean, testFlags?: string[], applyCodeCoverage?: boolean},
input: { isMod: boolean, includeSubDirectories: boolean, testFlags?: string[], applyCodeCoverage?: boolean },
wantFiles: string[]) {

fs.copySync(sourcePath, repoPath, { recursive: true });
Expand Down Expand Up @@ -114,8 +114,8 @@ suite('Test Go Test', function () {
{ isMod: true, includeSubDirectories: true, testFlags: ['-v'] },
[path.join(repoPath, 'a_test.go'), path.join(repoPath, 'b', 'b_test.go')]);
await runTest(
{ isMod: true, includeSubDirectories: true, testFlags: ['-race'], applyCodeCoverage: true },
[path.join(repoPath, 'a_test.go'), path.join(repoPath, 'b', 'b_test.go')]);
{ isMod: true, includeSubDirectories: true, testFlags: ['-race'], applyCodeCoverage: true },
[path.join(repoPath, 'a_test.go'), path.join(repoPath, 'b', 'b_test.go')]);
await runTest(
{ isMod: true, includeSubDirectories: false, testFlags: ['-v'] },
[path.join(repoPath, 'a_test.go')]);
Expand Down
8 changes: 4 additions & 4 deletions test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as path from 'path';
import { runTests } from 'vscode-test';

async function main() {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');

let failed = false;
Expand All @@ -30,9 +30,9 @@ async function main() {
// dynamically adding folders.
// tslint:disable-next-line:max-line-length
// https://github.com/microsoft/vscode/blob/890f62dfd9f3e70198931f788c5c332b3e8b7ad7/src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.ts#L281
// So, we start the test extension host with a dummy workspace (test/gopls/testfixtures/src/workspace)
// So, we start the test extension host with a dummy workspace (test/gopls/testdata/src/workspace)
// and copy necessary files to the workspace.
const ws = path.resolve(extensionDevelopmentPath, 'test/gopls/testfixtures/src/workspace');
const ws = path.resolve(extensionDevelopmentPath, 'test/gopls/testdata/src/workspace');

await runTests({
extensionDevelopmentPath,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 46f249d

Please sign in to comment.