Fix flakiness in test and re-enable

Fixes #128710
This commit is contained in:
Daniel Imms
2021-07-15 06:32:25 -07:00
parent 5236497ede
commit 3cd98a5056
3 changed files with 32 additions and 10 deletions

View File

@@ -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;
}