Skip to content

Commit 83d4955

Browse files
committed
shellIntegrationAddon: add tests for current broken deserializeMessage implementation
The test suite includes several skipped test cases for bugs which are fixed in subsequent commits.
1 parent 859f16a commit 83d4955

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

src/vs/workbench/contrib/terminal/test/browser/xterm/shellIntegrationAddon.test.ts

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Terminal } from 'xterm';
77
import { strictEqual, deepStrictEqual, deepEqual } from 'assert';
88
import { timeout } from 'vs/base/common/async';
99
import * as sinon from 'sinon';
10-
import { parseKeyValueAssignment, parseMarkSequence, ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon';
10+
import { parseKeyValueAssignment, parseMarkSequence, deserializeMessage, ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon';
1111
import { ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
1212
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
1313
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
@@ -257,6 +257,59 @@ suite('ShellIntegrationAddon', () => {
257257
});
258258
});
259259

260+
suite('deserializeMessage', () => {
261+
// A single literal backslash, in order to avoid confusion about whether we are escaping test data or testing escapes.
262+
const Backslash = '\\' as const;
263+
const Newline = '\n' as const;
264+
const Semicolon = ';' as const;
265+
266+
type TestCase = [title: string, input: string, expected: string];
267+
const cases: TestCase[] = [
268+
['empty', '', ''],
269+
['basic', 'value', 'value'],
270+
['space', 'some thing', 'some thing'],
271+
['escaped backslash', `${Backslash}${Backslash}`, Backslash],
272+
['non-initial escaped backslash', `foo${Backslash}${Backslash}`, `foo${Backslash}`],
273+
['two escaped backslashes', `${Backslash}${Backslash}${Backslash}${Backslash}`, `${Backslash}${Backslash}`],
274+
['escaped backslash amidst text', `Hello${Backslash}${Backslash}there`, `Hello${Backslash}there`],
275+
['backslash escaped literally and as hex', `${Backslash}${Backslash} is same as ${Backslash}x5c`, `${Backslash} is same as ${Backslash}`],
276+
['escaped semicolon', `${Backslash}x3b`, Semicolon],
277+
['non-initial escaped semicolon', `foo${Backslash}x3b`, `foo${Semicolon}`],
278+
['escaped semicolon (upper hex)', `${Backslash}x3B`, Semicolon],
279+
['escaped backslash followed by literal "x3b" is not a semicolon', `${Backslash}${Backslash}x3b`, `${Backslash}x3b`],
280+
['non-initial escaped backslash followed by literal "x3b" is not a semicolon', `foo${Backslash}${Backslash}x3b`, `foo${Backslash}x3b`],
281+
['escaped backslash followed by escaped semicolon', `${Backslash}${Backslash}${Backslash}x3b`, `${Backslash}${Semicolon}`],
282+
['escaped semicolon amidst text', `some${Backslash}x3bthing`, `some${Semicolon}thing`],
283+
['escaped newline', `${Backslash}x0a`, Newline],
284+
['non-initial escaped newline', `foo${Backslash}x0a`, `foo${Newline}`],
285+
['escaped newline (upper hex)', `${Backslash}x0A`, Newline],
286+
['escaped backslash followed by literal "x0a" is not a newline', `${Backslash}${Backslash}x0a`, `${Backslash}x0a`],
287+
['non-initial escaped backslash followed by literal "x0a" is not a newline', `foo${Backslash}${Backslash}x0a`, `foo${Backslash}x0a`],
288+
];
289+
290+
const BROKEN: readonly string[] = [
291+
'escaped semicolon',
292+
'escaped semicolon (upper hex)',
293+
// only "passing" due to interaction between two separate bugs:
294+
// 'escaped backslash followed by literal "x3b" is not a semicolon',
295+
'non-initial escaped backslash followed by literal "x3b" is not a semicolon',
296+
'escaped newline',
297+
'escaped newline (upper hex)',
298+
// only "passing" due to interaction between two separate bugs:
299+
// 'escaped backslash followed by literal "x0a" is not a newline',
300+
'non-initial escaped backslash followed by literal "x0a" is not a newline',
301+
];
302+
303+
cases.forEach(([title, input, expected]) => {
304+
const fn = () => strictEqual(deserializeMessage(input), expected);
305+
if (BROKEN.includes(title)) {
306+
test.skip(title, fn);
307+
} else {
308+
test(title, fn);
309+
}
310+
});
311+
});
312+
260313
test('parseKeyValueAssignment', () => {
261314
type TestCase = [title: string, input: string, expected: [key: string, value: string | undefined]];
262315
const cases: TestCase[] = [

0 commit comments

Comments
 (0)