Skip to content

Commit

Permalink
better cleanup between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrichardson committed Jul 31, 2019
1 parent df6a17a commit 106ec9f
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 48 deletions.
4 changes: 3 additions & 1 deletion src/utilities/deployment/executeTerminalCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export async function executeTerminalCommand(
}

const terminal = await vscode.window.createTerminal(terminalOptions);
// terminal.show(true);
if (!terminalOptions.runInBackground) {
terminal.show(true);
}

terminal.sendText(command, true);

Expand Down
4 changes: 2 additions & 2 deletions test/deploymentE2E.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ suite("Deployment - E2E", function(): void {
});

suiteTeardown(async (): Promise<void> => {
await cleanup(testEnv.MicrosoftAppId, testEnv.ResourceGroupName);
await disposeAllTerminals();
await cleanup(testEnv.MicrosoftAppId, testEnv.ResourceGroupName);
});

setup(async (): Promise<void> => {
Expand All @@ -49,6 +48,7 @@ suite("Deployment - E2E", function(): void {
testNotify(`Saved terminal error to: ${ saveLocation }`);
} catch (err) { }
}
await disposeAllTerminals();
});

test("Should create a web app", async function(): Promise<void> {
Expand Down
14 changes: 7 additions & 7 deletions test/deploymentUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ suite("Deployment - Unit", function(): void {
await setVsCodeConfig(constants.vsCodeConfig.names.customTerminal, undefined);
});

suiteTeardown(async (): Promise<void> => {
await disposeAllTerminals();
});

setup(async (): Promise<void> => {
await setBotVariables(testEnv);
});

teardown(async (): Promise<void> => {
await disposeAllTerminals();
});

test("Should download both deployment templates if missing", async function(): Promise<void> {
this.timeout(10 * 1000);
Expand Down Expand Up @@ -267,7 +267,7 @@ suite("Deployment - Unit", function(): void {
terminal.sendText('test');
const result = (await handleTerminalData(terminal, {
commandFailedRegex: /(?<err>The term 'test' is not)/,
timeout: 5000,
timeout: 4500,
}) as RegExpMatchArray);
terminal.dispose();
assert.equal(result, false);
Expand All @@ -279,7 +279,7 @@ suite("Deployment - Unit", function(): void {
terminal.sendText('test');
const result = (await handleTerminalData(terminal, {
commandCompleteRegex: /(?<err>The term 'test' is not)/,
timeout: 5000,
timeout: 4500,
}) as RegExpMatchArray);
terminal.dispose();
assert.equal(result, true);
Expand All @@ -292,7 +292,7 @@ suite("Deployment - Unit", function(): void {
const result = (await handleTerminalData(terminal, {
commandCompleteRegex: /(?<err>The term 'test' is not)/,
commandFailedRegex: /(?<err>The term 'test' is not)/,
timeout: 5000,
timeout: 4500,
}) as RegExpMatchArray);
terminal.dispose();
assert.equal(result, false);
Expand Down
6 changes: 2 additions & 4 deletions test/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ const testEndpoints = {
};

suite('Emulator', function(): void {
suiteTeardown(async (): Promise<void> => {
await disposeAllTerminals();
});

teardown((): void => {
teardown(async (): Promise<void> => {
sinon.restore();
await disposeAllTerminals();
});

test('Should Create Proper Emulator Start Command', function(): void {
Expand Down
28 changes: 13 additions & 15 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as fs from 'fs';
const fsP = fs.promises;
import mocha = require('mocha');
import { getWorkspaceRoot, setBotVariables, promptForVariableIfNotExist, getEnvBotVariables, watchEnvFiles, getDeploymentTemplate, executeTerminalCommand, getLocalBotVariables, log, getToolsUpdateCommand, getCurrentAzCliVersion, getLatestAzCliVersion, deleteDirectory, createTempDir, getSparseCheckoutCommand, promptForSample, rootFolderIsEmpty, renameDirectory, getSample, createCodeZip, deleteCodeZip, setLocalBotVariables, syncLocalBotVariablesToEnv, getTerminalPath, joinTerminalCommands, handleTerminalData, regexToVariables, getCreateAppRegistrationCommand, normalizeEnvKeys, getEndpointKeyType, getEndpoints, getEndpointObject, promptForNewEndpoint, modifyEndpointNameIfNecessary, getSingleEndpoint, getEndpointFromQuickPick, writeEndpointToEnv, getEmulatorLaunchCommand, loadCommands, handleAzCliUpdate, getPrepareDeployCommand, openSample } from '../src/utilities';
import { testNotify, deleteDownloadTemplates, makeNestedTestDir, deleteCodeFiles, writeCodeFiles, deleteTerminalOutputFile, clearEnvVariables, deletePrepareDeployFiles } from './testUtilities';
import { testNotify, deleteDownloadTemplates, makeNestedTestDir, deleteCodeFiles, writeCodeFiles, deleteTerminalOutputFile, clearEnvVariables, deletePrepareDeployFiles, disposeAllTerminals } from './testUtilities';
import { setVsCodeConfig } from '../src/utilities/variables/setVsCodeConfig';
import { getVsCodeConfig } from '../src/utilities/variables/getVsCodeConfig';
import { CommandOptions } from '../src/interfaces/CommandOptions';
Expand All @@ -31,7 +31,7 @@ require('./variables');
require('./tools');
require('./samples');
require('./deploymentUnit');
require('./deploymentE2E');
// require('./deploymentE2E');

var testEnv: BotVariables = {
BotName: 'vmicricEXT',
Expand Down Expand Up @@ -90,22 +90,20 @@ var testEnv: BotVariables = {


// suite("Quick Test", function(): void {
// teardown((): void => {
// teardown(async (): Promise<void> => {
// sinon.restore();
// await disposeAllTerminals();
// });
// test("Should Get Endpoint Variables - Node", async function(): Promise<void> {
// test("Terminal should return true if it detects complete regex and no matches", async function(): Promise<void> {
// this.timeout(5 * 1000);
// await clearEnvVariables();
// await writeCodeFiles(constants.variables.sdkLanguages.Node);
// await setBotVariables(botVariables);

// const localVariables = await getLocalBotVariables();

// assert.equal(localVariables['Endpoint'], endpoint);
// assert.equal(localVariables['Endpoint_AppId'], appId);
// assert.equal(localVariables['Endpoint_AppPassword'], appPass);
// assert.equal(localVariables['Endpoint_Test'], endpoint);
// assert.equal(localVariables['Endpoint_Test_AppId'], appId);
// assert.equal(localVariables['Endpoint_Test_AppPassword'], appPass);
// const terminal = vscode.window.createTerminal();
// terminal.sendText('test');
// const result = (await handleTerminalData(terminal, {
// commandCompleteRegex: /(?<err>The term 'test' is not)/,
// timeout: 5000,
// }) as RegExpMatchArray);
// terminal.dispose();
// assert.equal(result, true);
// });
// });
6 changes: 2 additions & 4 deletions test/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import { disposeAllTerminals } from './testUtilities';
const fsP = fs.promises;

suite('Extension Loading Tests', function(): void {
suiteTeardown(async (): Promise<void> => {
await disposeAllTerminals();
});

teardown((): void => {
teardown(async (): Promise<void> => {
sinon.restore();
await disposeAllTerminals();
});

test("Should Properly Activate the Extension", async function(): Promise<void> {
Expand Down
7 changes: 2 additions & 5 deletions test/samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ import { getSampleUrl } from '../src/utilities/samples/getSampleUrl';
const fsP = fs.promises;

suite('Samples', function(): void {
suiteTeardown(async (): Promise<void> => {
await disposeAllTerminals();
});

teardown((): void => {
teardown(async (): Promise<void> => {
sinon.restore();
await disposeAllTerminals();
});

test("Should Create an Appropriate Temporary Directory", async function(): Promise<void> {
Expand Down
7 changes: 2 additions & 5 deletions test/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import sinon = require('sinon');
import { disposeAllTerminals } from './testUtilities';

suite('Tools', function(): void {
suiteTeardown(async (): Promise<void> => {
await disposeAllTerminals();
});

teardown((): void => {
teardown(async (): Promise<void> => {
sinon.restore();
await disposeAllTerminals();
});

test("All Website Constants Should Return 200 Status", async function(): Promise<void> {
Expand Down
7 changes: 2 additions & 5 deletions test/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import { getLocalBotVariables, getEnvBotVariables, setBotVariables, normalizeEnv
import sinon = require('sinon');

suite("Variables", function(): void {
suiteTeardown(async (): Promise<void> => {
await disposeAllTerminals();
});

teardown((): void => {
teardown(async (): Promise<void> => {
sinon.restore();
await disposeAllTerminals();
});

test("Should Get and Set VSCode Configs", async function(): Promise<void> {
Expand Down

0 comments on commit 106ec9f

Please sign in to comment.