Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/debug/test/node/terminals.test.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
8
import { prepareCommand } from '../../node/terminals.js';
9
10
11
suite('Debug - prepareCommand', () => {
12
ensureNoDisposablesAreLeakedInTestSuite();
13
14
test('bash', () => {
15
assert.strictEqual(
16
prepareCommand('bash', ['{$} ('], false).trim(),
17
'\\{\\$\\}\\ \\(');
18
assert.strictEqual(
19
prepareCommand('bash', ['hello', 'world', '--flag=true'], false).trim(),
20
'hello world --flag=true');
21
assert.strictEqual(
22
prepareCommand('bash', [' space arg '], false).trim(),
23
'\\ space\\ arg\\');
24
25
assert.strictEqual(
26
prepareCommand('bash', ['{$} ('], true).trim(),
27
'{$} (');
28
assert.strictEqual(
29
prepareCommand('bash', ['hello', 'world', '--flag=true'], true).trim(),
30
'hello world --flag=true');
31
assert.strictEqual(
32
prepareCommand('bash', [' space arg '], true).trim(),
33
'space arg');
34
});
35
36
test('bash - do not escape > and <', () => {
37
assert.strictEqual(
38
prepareCommand('bash', ['arg1', '>', '> hello.txt', '<', '<input.in'], false).trim(),
39
'arg1 > \\>\\ hello.txt < \\<input.in');
40
});
41
42
test('cmd', () => {
43
assert.strictEqual(
44
prepareCommand('cmd.exe', ['^!< '], false).trim(),
45
'"^^^!^< "');
46
assert.strictEqual(
47
prepareCommand('cmd.exe', ['hello', 'world', '--flag=true'], false).trim(),
48
'hello world --flag=true');
49
assert.strictEqual(
50
prepareCommand('cmd.exe', [' space arg '], false).trim(),
51
'" space arg "');
52
assert.strictEqual(
53
prepareCommand('cmd.exe', ['"A>0"'], false).trim(),
54
'"""A^>0"""');
55
assert.strictEqual(
56
prepareCommand('cmd.exe', [''], false).trim(),
57
'""');
58
59
assert.strictEqual(
60
prepareCommand('cmd.exe', ['^!< '], true).trim(),
61
'^!<');
62
assert.strictEqual(
63
prepareCommand('cmd.exe', ['hello', 'world', '--flag=true'], true).trim(),
64
'hello world --flag=true');
65
assert.strictEqual(
66
prepareCommand('cmd.exe', [' space arg '], true).trim(),
67
'space arg');
68
assert.strictEqual(
69
prepareCommand('cmd.exe', ['"A>0"'], true).trim(),
70
'"A>0"');
71
assert.strictEqual(
72
prepareCommand('cmd.exe', [''], true).trim(),
73
'');
74
});
75
76
test('cmd - do not escape > and <', () => {
77
assert.strictEqual(
78
prepareCommand('cmd.exe', ['arg1', '>', '> hello.txt', '<', '<input.in'], false).trim(),
79
'arg1 > "^> hello.txt" < ^<input.in');
80
});
81
82
test('powershell', () => {
83
assert.strictEqual(
84
prepareCommand('powershell', ['!< '], false).trim(),
85
`& '!< '`);
86
assert.strictEqual(
87
prepareCommand('powershell', ['hello', 'world', '--flag=true'], false).trim(),
88
`& 'hello' 'world' '--flag=true'`);
89
assert.strictEqual(
90
prepareCommand('powershell', [' space arg '], false).trim(),
91
`& ' space arg '`);
92
assert.strictEqual(
93
prepareCommand('powershell', ['"A>0"'], false).trim(),
94
`& '"A>0"'`);
95
assert.strictEqual(
96
prepareCommand('powershell', [''], false).trim(),
97
`& ''`);
98
99
assert.strictEqual(
100
prepareCommand('powershell', ['!< '], true).trim(),
101
'!<');
102
assert.strictEqual(
103
prepareCommand('powershell', ['hello', 'world', '--flag=true'], true).trim(),
104
'hello world --flag=true');
105
assert.strictEqual(
106
prepareCommand('powershell', [' space arg '], true).trim(),
107
'space arg');
108
assert.strictEqual(
109
prepareCommand('powershell', ['"A>0"'], true).trim(),
110
'"A>0"');
111
assert.strictEqual(
112
prepareCommand('powershell', [''], true).trim(),
113
``);
114
});
115
116
test('powershell - do not escape > and <', () => {
117
assert.strictEqual(
118
prepareCommand('powershell', ['arg1', '>', '> hello.txt', '<', '<input.in'], false).trim(),
119
`& 'arg1' > '> hello.txt' < '<input.in'`);
120
});
121
});
122
123