mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Fixes #27604.
This commit is contained in:
parent
06d60228fd
commit
100f70c3fb
|
@ -23,17 +23,17 @@ export class IntegratedTerminal {
|
|||
return this.spectron.command('workbench.action.terminal.toggleTerminal');
|
||||
}
|
||||
|
||||
public async getCommandOutput(command: string): Promise<string> {
|
||||
public async commandOutputHas(result: string): Promise<boolean> {
|
||||
const selector = 'div[id="workbench.panel.terminal"] .xterm-rows';
|
||||
// Default Powershell terminal adds 3 header rows at the top, whereas bash does not.
|
||||
let readRow = process.platform === 'win32' ? 5 : 2;
|
||||
let output: string = await this.spectron.client.getText(`${selector}>:nth-child(${readRow})`);
|
||||
|
||||
// If ended up on the wrong line, it could be terminal's restored session (e.g. on OS X)
|
||||
if (output.trim().endsWith(command)) {
|
||||
output = await this.spectron.client.getText(`${selector}>:nth-child(${readRow+1})`); // try next line
|
||||
const rows = await this.spectron.client.elements(`${selector} div`);
|
||||
for (let i = 0; i < rows.value.length; i++) {
|
||||
const rowText = await this.spectron.client.getText(`${selector}>:nth-child(${i+1})`);
|
||||
if (rowText.trim() === result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return output.trim(); // remove many tags
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
var Mocha = require('mocha');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
var mocha = new Mocha({
|
||||
timeout: 360000,
|
||||
|
|
|
@ -34,8 +34,7 @@ export function testIntegratedTerminal() {
|
|||
await common.type(command);
|
||||
await common.enter();
|
||||
await app.wait();
|
||||
let output = await terminal.getCommandOutput(command);
|
||||
assert.equal(output, 'test');
|
||||
assert.ok(await terminal.commandOutputHas('test'));
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue