1616 */
1717
1818import { expect } from 'chai' ;
19- import { window , commands , env , Uri , Terminal , Disposable } from 'vscode' ;
19+ import { window , commands , env , Uri , Terminal } from 'vscode' ;
2020import { START_DIDACT_COMMAND , sendTerminalText , gatherAllCommandsLinks , getContext } from '../../extensionFunctions' ;
2121import { didactManager } from '../../didactManager' ;
2222import { DidactUri } from '../../didactUri' ;
@@ -33,29 +33,11 @@ const TERMINAL_WAIT_RETRY = 2000;
3333
3434suite ( 'stub out a tutorial' , ( ) => {
3535
36- let disposables : Disposable [ ] = [ ] ;
37-
38- teardown ( ( ) => {
39- disposables . forEach ( d => d . dispose ( ) ) ;
40- disposables . length = 0 ;
41- } ) ;
42-
4336 test ( 'that we can send an echo command to the terminal and get the response' , async ( ) => {
4437 const name = 'echoTerminal' ;
4538 const text = `echo \"Hello World ${ name } \"` ;
4639 const result = `Hello World echoTerminal` ;
47- const winResult = [
48- `Hello` ,
49- `World` ,
50- `echoTerminal`
51- ] ;
52- await validateTerminalResponseWin ( name , text , result ) ;
53-
54- // if (process.platform === 'win32') {
55- // await validateTerminalResponseWin(name, text, winResult);
56- // } else {
57- // await validateTerminalResponse(name, text, result);
58- // }
40+ await validateTerminalResponse ( name , text , result ) ;
5941 } ) ;
6042
6143 test ( 'that we can get a response from each command in the demo tutorial' , async ( ) => {
@@ -115,53 +97,6 @@ suite('stub out a tutorial', () => {
11597 }
11698 }
11799
118- async function validateTerminalResponseWin ( terminalName : string , terminalText : string , terminalResponse : string ) {
119- let terminalData :string [ ] = [ ] ;
120- console . log ( `validateTerminalResponse terminal ${ terminalName } executing text ${ terminalText } ` ) ;
121- const term = window . createTerminal ( terminalName ) ;
122- expect ( term ) . to . not . be . null ;
123- if ( term ) {
124- console . log ( `-current terminal = ${ term ?. name } ` ) ;
125- await sendTerminalText ( terminalName , terminalText ) ;
126- await waitUntil ( async ( ) => {
127- await focusOnNamedTerminal ( terminalName ) ;
128- return terminalName === window . activeTerminal ?. name ;
129- } , 1000 ) ;
130- try {
131- const predicate = async ( ) => {
132- const result : string = await getActiveTerminalOutput ( ) ;
133- await commands . executeCommand ( 'workbench.action.terminal.clear' ) ;
134- if ( result . trim ( ) . length > 0 ) terminalData . push ( result . trim ( ) ) ;
135- return true ;
136- } ;
137- var numberOfTimes = 5 ;
138- const delay = 1000 ;
139- for ( let i = 0 ; i < numberOfTimes ; i ++ ) {
140- await predicate ( ) ;
141- await new Promise ( ( res ) => { setTimeout ( res , delay ) ; } ) ;
142- }
143- console . log ( `-terminal output = ${ terminalData } ` ) ;
144-
145- const foundIt = searchStringInArray ( terminalResponse , terminalData ) ;
146- if ( foundIt > - 1 ) {
147- return ;
148- } else {
149- fail ( `Searching for ${ terminalResponse } but not found in current content of active terminal ${ window . activeTerminal ?. name } : ${ terminalData } ` ) ;
150- } ;
151- } catch ( error ) {
152- fail ( error ) ;
153- }
154- findAndDisposeTerminal ( terminalName ) ;
155- }
156- }
157-
158- function searchStringInArray ( strToFind : string , strArray : string [ ] ) : number {
159- for ( var j = 0 ; j < strArray . length ; j ++ ) {
160- if ( strArray [ j ] . match ( strToFind ) ) return j ;
161- }
162- return - 1 ;
163- }
164-
165100 async function getActiveTerminalOutput ( ) : Promise < string > {
166101 const term = window . activeTerminal ;
167102 console . log ( `-current terminal = ${ term ?. name } ` ) ;
0 commit comments