mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
@@ -676,12 +676,14 @@ import { assertNoRpc } from '../utils';
|
||||
'b1~b2~',
|
||||
'~c2~c1'
|
||||
];
|
||||
let data = '';
|
||||
disposables.push(window.onDidWriteTerminalData(e => {
|
||||
if (terminal !== e.terminal) {
|
||||
return;
|
||||
}
|
||||
data += sanitizeData(e.data);
|
||||
// Multiple expected could show up in the same data event
|
||||
while (expectedText.length > 0 && e.data.indexOf(expectedText[0]) >= 0) {
|
||||
while (expectedText.length > 0 && data.indexOf(expectedText[0]) >= 0) {
|
||||
expectedText.shift();
|
||||
// Check if all string are found, if so finish the test
|
||||
if (expectedText.length === 0) {
|
||||
@@ -719,12 +721,14 @@ import { assertNoRpc } from '../utils';
|
||||
'~b2~',
|
||||
'~c2~'
|
||||
];
|
||||
let data = '';
|
||||
disposables.push(window.onDidWriteTerminalData(e => {
|
||||
if (terminal !== e.terminal) {
|
||||
return;
|
||||
}
|
||||
data += sanitizeData(e.data);
|
||||
// Multiple expected could show up in the same data event
|
||||
while (expectedText.length > 0 && e.data.indexOf(expectedText[0]) >= 0) {
|
||||
while (expectedText.length > 0 && data.indexOf(expectedText[0]) >= 0) {
|
||||
expectedText.shift();
|
||||
// Check if all string are found, if so finish the test
|
||||
if (expectedText.length === 0) {
|
||||
@@ -761,12 +765,14 @@ import { assertNoRpc } from '../utils';
|
||||
'~a1~',
|
||||
'~b1~'
|
||||
];
|
||||
let data = '';
|
||||
disposables.push(window.onDidWriteTerminalData(e => {
|
||||
if (terminal !== e.terminal) {
|
||||
return;
|
||||
}
|
||||
data += sanitizeData(e.data);
|
||||
// Multiple expected could show up in the same data event
|
||||
while (expectedText.length > 0 && e.data.indexOf(expectedText[0]) >= 0) {
|
||||
while (expectedText.length > 0 && data.indexOf(expectedText[0]) >= 0) {
|
||||
expectedText.shift();
|
||||
// Check if all string are found, if so finish the test
|
||||
if (expectedText.length === 0) {
|
||||
@@ -800,12 +806,14 @@ import { assertNoRpc } from '../utils';
|
||||
'~a1~',
|
||||
'~b2~'
|
||||
];
|
||||
let data = '';
|
||||
disposables.push(window.onDidWriteTerminalData(e => {
|
||||
if (terminal !== e.terminal) {
|
||||
return;
|
||||
}
|
||||
data += sanitizeData(e.data);
|
||||
// Multiple expected could show up in the same data event
|
||||
while (expectedText.length > 0 && e.data.indexOf(expectedText[0]) >= 0) {
|
||||
while (expectedText.length > 0 && data.indexOf(expectedText[0]) >= 0) {
|
||||
expectedText.shift();
|
||||
// Check if all string are found, if so finish the test
|
||||
if (expectedText.length === 0) {
|
||||
@@ -857,3 +865,15 @@ import { assertNoRpc } from '../utils';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function sanitizeData(data: string): string {
|
||||
// Strip NL/CR so terminal dimensions don't impact tests
|
||||
data = data.replaceAll(/[\r\n]/g, '');
|
||||
|
||||
// Strip escape sequences so winpty/conpty doesn't cause flakiness, do for all platforms for
|
||||
// consistency
|
||||
const terminalCodesRegex = /(?:\u001B|\u009B)[\[\]()#;?]*(?:(?:(?:[a-zA-Z0-9]*(?:;[a-zA-Z0-9]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-PR-TZcf-ntqry=><~]))/g;
|
||||
data = data.replaceAll(terminalCodesRegex, '');
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user