From 11fe587543ec09bbb3b8c8f428968902bfdfa29b Mon Sep 17 00:00:00 2001 From: Brian Fitzpatrick Date: Fri, 11 Jun 2021 11:16:09 -0600 Subject: [PATCH 1/2] FUSETOOLS2-1152 fixing test Signed-off-by: Brian Fitzpatrick --- src/test/suite/stubDemoTutorial.test.ts | 69 ++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/test/suite/stubDemoTutorial.test.ts b/src/test/suite/stubDemoTutorial.test.ts index bc9c676a..6b08531d 100644 --- a/src/test/suite/stubDemoTutorial.test.ts +++ b/src/test/suite/stubDemoTutorial.test.ts @@ -16,7 +16,7 @@ */ import { expect } from 'chai'; -import { window, commands, env, Uri, Terminal } from 'vscode'; +import { window, commands, env, Uri, Terminal, Disposable } from 'vscode'; import { START_DIDACT_COMMAND, sendTerminalText, gatherAllCommandsLinks, getContext } from '../../extensionFunctions'; import { didactManager } from '../../didactManager'; import { DidactUri } from '../../didactUri'; @@ -33,11 +33,29 @@ const TERMINAL_WAIT_RETRY = 2000; suite('stub out a tutorial', () => { + let disposables: Disposable[] = []; + + teardown(() => { + disposables.forEach(d => d.dispose()); + disposables.length = 0; + }); + test('that we can send an echo command to the terminal and get the response', async () => { const name = 'echoTerminal'; const text = `echo \"Hello World ${name}\"`; const result = `Hello World echoTerminal`; - await validateTerminalResponse(name, text, result); + const winResult = [ + `Hello`, + `World`, + `echoTerminal` + ]; + await validateTerminalResponseWin(name, text, result); + + // if (process.platform === 'win32') { + // await validateTerminalResponseWin(name, text, winResult); + // } else { + // await validateTerminalResponse(name, text, result); + // } }); test('that we can get a response from each command in the demo tutorial', async () => { @@ -97,6 +115,53 @@ suite('stub out a tutorial', () => { } } + async function validateTerminalResponseWin(terminalName : string, terminalText : string, terminalResponse : string) { + let terminalData:string[] = []; + console.log(`validateTerminalResponse terminal ${terminalName} executing text ${terminalText}`); + const term = window.createTerminal(terminalName); + expect(term).to.not.be.null; + if (term) { + console.log(`-current terminal = ${term?.name}`); + await sendTerminalText(terminalName, terminalText); + await waitUntil(async () => { + await focusOnNamedTerminal(terminalName); + return terminalName === window.activeTerminal?.name; + }, 1000); + try { + const predicate = async () => { + const result: string = await getActiveTerminalOutput(); + await commands.executeCommand('workbench.action.terminal.clear'); + if (result.trim().length > 0) terminalData.push(result.trim()); + return true; + }; + var numberOfTimes = 5; + const delay = 1000; + for (let i = 0; i < numberOfTimes; i++) { + await predicate(); + await new Promise((res) => { setTimeout(res, delay); }); + } + console.log(`-terminal output = ${terminalData}`); + + const foundIt = searchStringInArray(terminalResponse, terminalData); + if (foundIt > -1) { + return; + } else { + fail(`Searching for ${terminalResponse} but not found in current content of active terminal ${window.activeTerminal?.name} : ${terminalData}`); + }; + } catch (error){ + fail(error); + } + findAndDisposeTerminal(terminalName); + } + } + + function searchStringInArray (strToFind : string, strArray : string[]) : number { + for (var j=0; j { const term = window.activeTerminal; console.log(`-current terminal = ${term?.name}`); From 70c4fab3d78d8ed133b9a622ee309c30bf6df91a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Jul 2021 20:20:14 +0000 Subject: [PATCH 2/2] Bump vscode-test from 1.5.2 to 1.6.1 Bumps [vscode-test](https://github.com/Microsoft/vscode-test) from 1.5.2 to 1.6.1. - [Release notes](https://github.com/Microsoft/vscode-test/releases) - [Changelog](https://github.com/microsoft/vscode-test/blob/main/CHANGELOG.md) - [Commits](https://github.com/Microsoft/vscode-test/compare/v1.5.2...v1.6.1) --- updated-dependencies: - dependency-name: vscode-test dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 28749bcd..6441983a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3419,9 +3419,9 @@ "dev": true }, "vscode-test": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-1.5.2.tgz", - "integrity": "sha512-x9PVfKxF6EInH9iSFGQi0V8H5zIW1fC7RAer6yNQR6sy3WyOwlWkuT3I+wf75xW/cO53hxMi1aj/EvqQfDFOAg==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-1.6.1.tgz", + "integrity": "sha512-086q88T2ca1k95mUzffvbzb7esqQNvJgiwY4h29ukPhFo8u+vXOOmelUoU5EQUHs3Of8+JuQ3oGdbVCqaxuTXA==", "dev": true, "requires": { "http-proxy-agent": "^4.0.1", diff --git a/package.json b/package.json index f93c9eec..7146576f 100644 --- a/package.json +++ b/package.json @@ -298,7 +298,7 @@ "mocha-jenkins-reporter": "^0.4.4", "sinon": "11.1.1", "typescript": "^4.3.5", - "vscode-test": "^1.5.2", + "vscode-test": "^1.6.1", "y18n": ">=4.0.1" }, "dependencies": {