diff --git a/src/utilities/deployment/executeTerminalCommand.ts b/src/utilities/deployment/executeTerminalCommand.ts index c87bd6c..9b539a8 100644 --- a/src/utilities/deployment/executeTerminalCommand.ts +++ b/src/utilities/deployment/executeTerminalCommand.ts @@ -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); diff --git a/test/deploymentE2E.ts b/test/deploymentE2E.ts index cfa6d86..7c8296f 100644 --- a/test/deploymentE2E.ts +++ b/test/deploymentE2E.ts @@ -30,8 +30,7 @@ suite("Deployment - E2E", function(): void { }); suiteTeardown(async (): Promise => { - await cleanup(testEnv.MicrosoftAppId, testEnv.ResourceGroupName); - await disposeAllTerminals(); + await cleanup(testEnv.MicrosoftAppId, testEnv.ResourceGroupName); }); setup(async (): Promise => { @@ -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 { diff --git a/test/deploymentUnit.ts b/test/deploymentUnit.ts index de44517..98407af 100644 --- a/test/deploymentUnit.ts +++ b/test/deploymentUnit.ts @@ -26,13 +26,13 @@ suite("Deployment - Unit", function(): void { await setVsCodeConfig(constants.vsCodeConfig.names.customTerminal, undefined); }); - suiteTeardown(async (): Promise => { - await disposeAllTerminals(); - }); - setup(async (): Promise => { await setBotVariables(testEnv); }); + + teardown(async (): Promise => { + await disposeAllTerminals(); + }); test("Should download both deployment templates if missing", async function(): Promise { this.timeout(10 * 1000); @@ -267,7 +267,7 @@ suite("Deployment - Unit", function(): void { terminal.sendText('test'); const result = (await handleTerminalData(terminal, { commandFailedRegex: /(?The term 'test' is not)/, - timeout: 5000, + timeout: 4500, }) as RegExpMatchArray); terminal.dispose(); assert.equal(result, false); @@ -279,7 +279,7 @@ suite("Deployment - Unit", function(): void { terminal.sendText('test'); const result = (await handleTerminalData(terminal, { commandCompleteRegex: /(?The term 'test' is not)/, - timeout: 5000, + timeout: 4500, }) as RegExpMatchArray); terminal.dispose(); assert.equal(result, true); @@ -292,7 +292,7 @@ suite("Deployment - Unit", function(): void { const result = (await handleTerminalData(terminal, { commandCompleteRegex: /(?The term 'test' is not)/, commandFailedRegex: /(?The term 'test' is not)/, - timeout: 5000, + timeout: 4500, }) as RegExpMatchArray); terminal.dispose(); assert.equal(result, false); diff --git a/test/emulator.ts b/test/emulator.ts index ca157ae..0a24ecd 100644 --- a/test/emulator.ts +++ b/test/emulator.ts @@ -44,12 +44,10 @@ const testEndpoints = { }; suite('Emulator', function(): void { - suiteTeardown(async (): Promise => { - await disposeAllTerminals(); - }); - teardown((): void => { + teardown(async (): Promise => { sinon.restore(); + await disposeAllTerminals(); }); test('Should Create Proper Emulator Start Command', function(): void { diff --git a/test/index.test.ts b/test/index.test.ts index aad4420..c989406 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -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'; @@ -31,7 +31,7 @@ require('./variables'); require('./tools'); require('./samples'); require('./deploymentUnit'); -require('./deploymentE2E'); +// require('./deploymentE2E'); var testEnv: BotVariables = { BotName: 'vmicricEXT', @@ -90,22 +90,20 @@ var testEnv: BotVariables = { // suite("Quick Test", function(): void { -// teardown((): void => { +// teardown(async (): Promise => { // sinon.restore(); +// await disposeAllTerminals(); // }); -// test("Should Get Endpoint Variables - Node", async function(): Promise { +// test("Terminal should return true if it detects complete regex and no matches", async function(): Promise { // 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: /(?The term 'test' is not)/, +// timeout: 5000, +// }) as RegExpMatchArray); +// terminal.dispose(); +// assert.equal(result, true); // }); // }); diff --git a/test/loading.ts b/test/loading.ts index 46aeafa..d5af1a7 100644 --- a/test/loading.ts +++ b/test/loading.ts @@ -10,12 +10,10 @@ import { disposeAllTerminals } from './testUtilities'; const fsP = fs.promises; suite('Extension Loading Tests', function(): void { - suiteTeardown(async (): Promise => { - await disposeAllTerminals(); - }); - teardown((): void => { + teardown(async (): Promise => { sinon.restore(); + await disposeAllTerminals(); }); test("Should Properly Activate the Extension", async function(): Promise { diff --git a/test/samples.ts b/test/samples.ts index 93b0f67..8a889a2 100644 --- a/test/samples.ts +++ b/test/samples.ts @@ -12,12 +12,9 @@ import { getSampleUrl } from '../src/utilities/samples/getSampleUrl'; const fsP = fs.promises; suite('Samples', function(): void { - suiteTeardown(async (): Promise => { - await disposeAllTerminals(); - }); - - teardown((): void => { + teardown(async (): Promise => { sinon.restore(); + await disposeAllTerminals(); }); test("Should Create an Appropriate Temporary Directory", async function(): Promise { diff --git a/test/tools.ts b/test/tools.ts index 12d6b0c..d5eb68d 100644 --- a/test/tools.ts +++ b/test/tools.ts @@ -10,12 +10,9 @@ import sinon = require('sinon'); import { disposeAllTerminals } from './testUtilities'; suite('Tools', function(): void { - suiteTeardown(async (): Promise => { - await disposeAllTerminals(); - }); - - teardown((): void => { + teardown(async (): Promise => { sinon.restore(); + await disposeAllTerminals(); }); test("All Website Constants Should Return 200 Status", async function(): Promise { diff --git a/test/variables.ts b/test/variables.ts index 639033e..44d8447 100644 --- a/test/variables.ts +++ b/test/variables.ts @@ -7,12 +7,9 @@ import { getLocalBotVariables, getEnvBotVariables, setBotVariables, normalizeEnv import sinon = require('sinon'); suite("Variables", function(): void { - suiteTeardown(async (): Promise => { - await disposeAllTerminals(); - }); - - teardown((): void => { + teardown(async (): Promise => { sinon.restore(); + await disposeAllTerminals(); }); test("Should Get and Set VSCode Configs", async function(): Promise {