Merge pull request #5648 from Tyriar/slow_tests_2
Speed up all remaining unit tests below threshold (40ms?)
This commit is contained in:
@@ -190,9 +190,7 @@ describe('Terminal', () => {
|
|||||||
});
|
});
|
||||||
it('should clear a buffer larger than rows', async () => {
|
it('should clear a buffer larger than rows', async () => {
|
||||||
// Fill the buffer with dummy rows
|
// Fill the buffer with dummy rows
|
||||||
for (let i = 0; i < term.rows * 2; i++) {
|
await term.writeP('test\n'.repeat(term.rows * 2));
|
||||||
await term.writeP('test\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
const promptLine = term.buffer.lines.get(term.buffer.ybase + term.buffer.y);
|
const promptLine = term.buffer.lines.get(term.buffer.ybase + term.buffer.y);
|
||||||
term.clear();
|
term.clear();
|
||||||
@@ -389,9 +387,7 @@ describe('Terminal', () => {
|
|||||||
|
|
||||||
it('should not scroll down, when a custom keydown handler prevents the event', async () => {
|
it('should not scroll down, when a custom keydown handler prevents the event', async () => {
|
||||||
// Add some output to the terminal
|
// Add some output to the terminal
|
||||||
for (let i = 0; i < term.rows * 3; i++) {
|
await term.writeP('test\r\n'.repeat(term.rows * 3));
|
||||||
await term.writeP('test\r\n');
|
|
||||||
}
|
|
||||||
const startYDisp = (term.rows * 2) + 1;
|
const startYDisp = (term.rows * 2) + 1;
|
||||||
term.attachCustomKeyEventHandler(() => {
|
term.attachCustomKeyEventHandler(() => {
|
||||||
return false;
|
return false;
|
||||||
@@ -731,70 +727,87 @@ describe('Terminal', () => {
|
|||||||
it(`${range}: 2 characters per cell`, async function (): Promise<void> {
|
it(`${range}: 2 characters per cell`, async function (): Promise<void> {
|
||||||
const high = String.fromCharCode(0xD800);
|
const high = String.fromCharCode(0xD800);
|
||||||
const cell = new CellData();
|
const cell = new CellData();
|
||||||
|
const values: string[] = [];
|
||||||
for (let j = i; j <= i + 0xF; j++) {
|
for (let j = i; j <= i + 0xF; j++) {
|
||||||
await term.writeP(high + String.fromCharCode(j));
|
values.push(high + String.fromCharCode(j));
|
||||||
const tchar = term.buffer.lines.get(0)!.loadCell(0, cell);
|
}
|
||||||
assert.equal(tchar.getChars(), high + String.fromCharCode(j));
|
await term.writeP(values.join('\r\n'));
|
||||||
|
for (let idx = 0; idx < values.length; idx++) {
|
||||||
|
const expected = values[idx];
|
||||||
|
const tchar = term.buffer.lines.get(idx)!.loadCell(0, cell);
|
||||||
|
assert.equal(tchar.getChars(), expected);
|
||||||
assert.equal(tchar.getChars().length, 2);
|
assert.equal(tchar.getChars().length, 2);
|
||||||
assert.equal(tchar.getWidth(), 1);
|
assert.equal(tchar.getWidth(), 1);
|
||||||
assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), '');
|
assert.equal(term.buffer.lines.get(idx)!.loadCell(1, cell).getChars(), '');
|
||||||
term.reset();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it(`${range}: 2 characters at last cell`, async () => {
|
it(`${range}: 2 characters at last cell`, async () => {
|
||||||
const high = String.fromCharCode(0xD800);
|
const high = String.fromCharCode(0xD800);
|
||||||
const cell = new CellData();
|
const cell = new CellData();
|
||||||
term.buffer.x = term.cols - 1;
|
const values: string[] = [];
|
||||||
for (let j = i; j <= i + 0xF; j++) {
|
for (let j = i; j <= i + 0xF; j++) {
|
||||||
await term.writeP(high + String.fromCharCode(j));
|
values.push(high + String.fromCharCode(j));
|
||||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars(), high + String.fromCharCode(j));
|
}
|
||||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.buffer.x - 1, cell).getChars().length, 2);
|
await term.writeP(values.map((value, idx) => `\x1b[${idx + 1};${term.cols}H${value}`).join(''));
|
||||||
assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), '');
|
for (let idx = 0; idx < values.length; idx++) {
|
||||||
term.reset();
|
const expected = values[idx];
|
||||||
|
assert.equal(term.buffer.lines.get(idx)!.loadCell(term.cols - 1, cell).getChars(), expected);
|
||||||
|
assert.equal(term.buffer.lines.get(idx)!.loadCell(term.cols - 1, cell).getChars().length, 2);
|
||||||
|
assert.equal(term.buffer.lines.get(idx + 1)!.loadCell(0, cell).getChars(), '');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it(`${range}: 2 characters per cell over line end with autowrap`, async function (): Promise<void> {
|
it(`${range}: 2 characters per cell over line end with autowrap`, async function (): Promise<void> {
|
||||||
const high = String.fromCharCode(0xD800);
|
const high = String.fromCharCode(0xD800);
|
||||||
const cell = new CellData();
|
const cell = new CellData();
|
||||||
|
term.resize(term.cols, 40);
|
||||||
|
const values: string[] = [];
|
||||||
for (let j = i; j <= i + 0xF; j++) {
|
for (let j = i; j <= i + 0xF; j++) {
|
||||||
term.buffer.x = term.cols - 1;
|
values.push(high + String.fromCharCode(j));
|
||||||
await term.writeP('a' + high + String.fromCharCode(j));
|
}
|
||||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), 'a');
|
await term.writeP(values.map((value, idx) => `\x1b[${idx * 2 + 1};${term.cols}H` + 'a' + value).join(''));
|
||||||
assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars(), high + String.fromCharCode(j));
|
for (let idx = 0; idx < values.length; idx++) {
|
||||||
assert.equal(term.buffer.lines.get(1)!.loadCell(0, cell).getChars().length, 2);
|
const expected = values[idx];
|
||||||
assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), '');
|
const row = idx * 2;
|
||||||
term.reset();
|
assert.equal(term.buffer.lines.get(row)!.loadCell(term.cols - 1, cell).getChars(), 'a');
|
||||||
|
assert.equal(term.buffer.lines.get(row + 1)!.loadCell(0, cell).getChars(), expected);
|
||||||
|
assert.equal(term.buffer.lines.get(row + 1)!.loadCell(0, cell).getChars().length, 2);
|
||||||
|
assert.equal(term.buffer.lines.get(row + 1)!.loadCell(1, cell).getChars(), '');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it(`${range}: 2 characters per cell over line end without autowrap`, async function (): Promise<void> {
|
it(`${range}: 2 characters per cell over line end without autowrap`, async function (): Promise<void> {
|
||||||
const high = String.fromCharCode(0xD800);
|
const high = String.fromCharCode(0xD800);
|
||||||
const cell = new CellData();
|
const cell = new CellData();
|
||||||
|
const values: string[] = [];
|
||||||
for (let j = i; j <= i + 0xF; j++) {
|
for (let j = i; j <= i + 0xF; j++) {
|
||||||
term.buffer.x = term.cols - 1;
|
|
||||||
await term.writeP('\x1b[?7l'); // Disable wraparound mode
|
|
||||||
const width = wcwidth((0xD800 - 0xD800) * 0x400 + j - 0xDC00 + 0x10000);
|
const width = wcwidth((0xD800 - 0xD800) * 0x400 + j - 0xDC00 + 0x10000);
|
||||||
if (width !== 1) {
|
if (width !== 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
await term.writeP('a' + high + String.fromCharCode(j));
|
values.push(high + String.fromCharCode(j));
|
||||||
// auto wraparound mode should cut off the rest of the line
|
}
|
||||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars(), high + String.fromCharCode(j));
|
await term.writeP('\x1b[?7l' + values.map((value, idx) => `\x1b[${idx + 1};${term.cols}H` + 'a' + value).join(''));
|
||||||
assert.equal(term.buffer.lines.get(0)!.loadCell(term.cols - 1, cell).getChars().length, 2);
|
for (let idx = 0; idx < values.length; idx++) {
|
||||||
assert.equal(term.buffer.lines.get(1)!.loadCell(1, cell).getChars(), '');
|
const expected = values[idx];
|
||||||
term.reset();
|
assert.equal(term.buffer.lines.get(idx)!.loadCell(term.cols - 1, cell).getChars(), expected);
|
||||||
|
assert.equal(term.buffer.lines.get(idx)!.loadCell(term.cols - 1, cell).getChars().length, 2);
|
||||||
|
assert.equal(term.buffer.lines.get(idx + 1)!.loadCell(1, cell).getChars(), '');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it(`${range}: splitted surrogates`, async function (): Promise<void> {
|
it(`${range}: splitted surrogates`, async function (): Promise<void> {
|
||||||
const high = String.fromCharCode(0xD800);
|
const high = String.fromCharCode(0xD800);
|
||||||
const cell = new CellData();
|
const cell = new CellData();
|
||||||
|
const values: string[] = [];
|
||||||
for (let j = i; j <= i + 0xF; j++) {
|
for (let j = i; j <= i + 0xF; j++) {
|
||||||
await term.writeP(high + String.fromCharCode(j));
|
values.push(high + String.fromCharCode(j));
|
||||||
const tchar = term.buffer.lines.get(0)!.loadCell(0, cell);
|
}
|
||||||
assert.equal(tchar.getChars(), high + String.fromCharCode(j));
|
await term.writeP(values.join('\r\n'));
|
||||||
|
for (let idx = 0; idx < values.length; idx++) {
|
||||||
|
const expected = values[idx];
|
||||||
|
const tchar = term.buffer.lines.get(idx)!.loadCell(0, cell);
|
||||||
|
assert.equal(tchar.getChars(), expected);
|
||||||
assert.equal(tchar.getChars().length, 2);
|
assert.equal(tchar.getChars().length, 2);
|
||||||
assert.equal(tchar.getWidth(), 1);
|
assert.equal(tchar.getWidth(), 1);
|
||||||
assert.equal(term.buffer.lines.get(0)!.loadCell(1, cell).getChars(), '');
|
assert.equal(term.buffer.lines.get(idx)!.loadCell(1, cell).getChars(), '');
|
||||||
term.reset();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2521,7 +2521,7 @@ describe('InputHandler', () => {
|
|||||||
const cpr: number[][] = [];
|
const cpr: number[][] = [];
|
||||||
inputHandler.registerCsiHandler({ final: 'H' }, async params => {
|
inputHandler.registerCsiHandler({ final: 'H' }, async params => {
|
||||||
cup.push(params.toArray() as number[]);
|
cup.push(params.toArray() as number[]);
|
||||||
await new Promise(res => setTimeout(res, 50));
|
await Promise.resolve();
|
||||||
// late call of real repositioning
|
// late call of real repositioning
|
||||||
return inputHandler.cursorPosition(params);
|
return inputHandler.cursorPosition(params);
|
||||||
});
|
});
|
||||||
@@ -2536,7 +2536,7 @@ describe('InputHandler', () => {
|
|||||||
});
|
});
|
||||||
it('async OSC between', async () => {
|
it('async OSC between', async () => {
|
||||||
inputHandler.registerOscHandler(1000, async data => {
|
inputHandler.registerOscHandler(1000, async data => {
|
||||||
await new Promise(res => setTimeout(res, 50));
|
await Promise.resolve();
|
||||||
assert.deepEqual(getLines(bufferService, 2), ['hello world!', '']);
|
assert.deepEqual(getLines(bufferService, 2), ['hello world!', '']);
|
||||||
assert.equal(data, 'some data');
|
assert.equal(data, 'some data');
|
||||||
return true;
|
return true;
|
||||||
@@ -2546,7 +2546,7 @@ describe('InputHandler', () => {
|
|||||||
});
|
});
|
||||||
it('async DCS between', async () => {
|
it('async DCS between', async () => {
|
||||||
inputHandler.registerDcsHandler({ final: 'a' }, async (data, params) => {
|
inputHandler.registerDcsHandler({ final: 'a' }, async (data, params) => {
|
||||||
await new Promise(res => setTimeout(res, 50));
|
await Promise.resolve();
|
||||||
assert.deepEqual(getLines(bufferService, 2), ['hello world!', '']);
|
assert.deepEqual(getLines(bufferService, 2), ['hello world!', '']);
|
||||||
assert.equal(data, 'some data');
|
assert.equal(data, 'some data');
|
||||||
assert.deepEqual(params.toArray(), [1, 2]);
|
assert.deepEqual(params.toArray(), [1, 2]);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ describe('WriteBuffer', () => {
|
|||||||
it('writeSync called from action does not overflow callstack - issue #3265', () => {
|
it('writeSync called from action does not overflow callstack - issue #3265', () => {
|
||||||
wb = new WriteBuffer(data => {
|
wb = new WriteBuffer(data => {
|
||||||
const num = parseInt(data as string);
|
const num = parseInt(data as string);
|
||||||
if (num < 1000000) {
|
if (num < 10000) {
|
||||||
wb.writeSync('' + (num + 1));
|
wb.writeSync('' + (num + 1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ class TestHandlerAsync implements IDcsHandler {
|
|||||||
}
|
}
|
||||||
public async unhook(success: boolean): Promise<boolean> {
|
public async unhook(success: boolean): Promise<boolean> {
|
||||||
// simple sleep to check in tests whether ordering gets messed up
|
// simple sleep to check in tests whether ordering gets messed up
|
||||||
await new Promise(res => setTimeout(res, 20));
|
await Promise.resolve();
|
||||||
this.output.push([this.msg, 'UNHOOK', success]);
|
this.output.push([this.msg, 'UNHOOK', success]);
|
||||||
if (this.returnFalse) {
|
if (this.returnFalse) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ class TestHandlerAsync implements IOscHandler {
|
|||||||
this.output.push([this.msg, this.id, 'PUT', utf32ToString(data, start, end)]);
|
this.output.push([this.msg, this.id, 'PUT', utf32ToString(data, start, end)]);
|
||||||
}
|
}
|
||||||
public async end(success: boolean): Promise<boolean> {
|
public async end(success: boolean): Promise<boolean> {
|
||||||
await new Promise(res => setTimeout(res, 20));
|
await Promise.resolve();
|
||||||
this.output.push([this.msg, this.id, 'END', success]);
|
this.output.push([this.msg, this.id, 'END', success]);
|
||||||
if (this.returnFalse) {
|
if (this.returnFalse) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user