ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / workbench / contrib / terminal / test / common / terminalEnvironment.test.ts 388 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
import { deepStrictEqual, strictEqual } from 'assert' ;
import { IStringDictionary } from '../../../../../base/common/collections.js' ;
import { isWindows, OperatingSystem } from '../../../../../base/common/platform.js' ;
import { URI as Uri } from '../../../../../base/common/uri.js' ;
import { addTerminalEnvironmentKeys, createTerminalEnvironment, getUriLabelForShell, getCwd, getLangEnvVariable, getWorkspaceForTerminal, mergeEnvironments, preparePathForShell, shouldSetLangEnvVariable } from '../../common/terminalEnvironment.js' ;
import { GeneralShellType PosixShellType WindowsShellType
ensureNoDisposablesAreLeakedInTestSuite
TestContextService TestHistoryService
testWorkspace
wslPathBackend
getWslPath original direction
direction
match original
groups match groups
groups
original
match original
groups match groups
groups
original
env key
env
env
env
env
env
env key
env
env
env2 key
env2
env2
env3
env3
env3
env4
env4
env4
parent
a
other
c
parent other
parent
a
c
isWindows test skip test
parent
a
other
parent other
parent
a
parent
a
c
other IStringDictionary
a
parent other
parent
c
isWindows test skip test
parent
a
c
other IStringDictionary
parent other
parent
c
a b
Uri a fsPath Uri b fsPath
executable args
executable args Uri
executable args
executable args Uri
executable args Uri
executable args Uri
executable args
executable args
executable args
executable args ignoreConfigurationCwd Uri
WindowsShellType CommandPrompt wslPathBackend OperatingSystem Windows
WindowsShellType CommandPrompt wslPathBackend OperatingSystem Windows
WindowsShellType CommandPrompt wslPathBackend OperatingSystem Windows
GeneralShellType PowerShell wslPathBackend OperatingSystem Windows
GeneralShellType PowerShell wslPathBackend OperatingSystem Windows
GeneralShellType PowerShell wslPathBackend OperatingSystem Windows
WindowsShellType GitBash wslPathBackend OperatingSystem Windows
WindowsShellType GitBash wslPathBackend OperatingSystem Windows
WindowsShellType GitBash wslPathBackend OperatingSystem Windows
WindowsShellType Wsl wslPathBackend OperatingSystem Windows
PosixShellType Bash wslPathBackend OperatingSystem Linux
PosixShellType Bash wslPathBackend OperatingSystem Linux
PosixShellType Bash wslPathBackend OperatingSystem Linux
PosixShellType Zsh wslPathBackend OperatingSystem Linux
PosixShellType Zsh wslPathBackend OperatingSystem Linux
PosixShellType Zsh wslPathBackend OperatingSystem Linux
PosixShellType Fish wslPathBackend OperatingSystem Linux
PosixShellType Fish wslPathBackend OperatingSystem Linux
PosixShellType Fish wslPathBackend OperatingSystem Linux
WindowsShellType CommandPrompt wslPathBackend OperatingSystem Windows
WindowsShellType CommandPrompt wslPathBackend OperatingSystem Windows
WindowsShellType CommandPrompt wslPathBackend OperatingSystem Windows
GeneralShellType PowerShell wslPathBackend OperatingSystem Windows
GeneralShellType PowerShell wslPathBackend OperatingSystem Windows
GeneralShellType PowerShell wslPathBackend OperatingSystem Windows
WindowsShellType GitBash wslPathBackend OperatingSystem Windows
WindowsShellType GitBash wslPathBackend OperatingSystem Windows
WindowsShellType GitBash wslPathBackend OperatingSystem Windows
WindowsShellType Wsl wslPathBackend OperatingSystem Windows
PosixShellType Bash wslPathBackend OperatingSystem Linux
PosixShellType Bash wslPathBackend OperatingSystem Linux
PosixShellType Bash wslPathBackend OperatingSystem Linux
PosixShellType Zsh wslPathBackend OperatingSystem Linux
PosixShellType Zsh wslPathBackend OperatingSystem Linux
PosixShellType Zsh wslPathBackend OperatingSystem Linux
PosixShellType Fish wslPathBackend OperatingSystem Linux
PosixShellType Fish wslPathBackend OperatingSystem Linux
PosixShellType Fish wslPathBackend OperatingSystem Linux
commonVariables
foo empty
foo empty commonVariables
folderA Uri
folderB Uri
contextService folderA folderB
historyService folderA
result folderB contextService historyService
result uri fsPath folderB fsPath
folderA Uri
contextService folderA
historyService folderA
result Uri contextService historyService
result uri fsPath folderA fsPath
folderA Uri
contextService folderA
historyService folderA
contextService historyService uri fsPath folderA fsPath
contextService Uri
historyService
contextService historyService
wslPathBackend WindowsShellType Wsl OperatingSystem Windows
wslPathBackend WindowsShellType Wsl OperatingSystem Windows
wslPathBackend WindowsShellType GitBash OperatingSystem Windows
wslPathBackend WindowsShellType GitBash OperatingSystem Windows
wslPathBackend GeneralShellType PowerShell OperatingSystem Windows
wslPathBackend GeneralShellType PowerShell OperatingSystem Windows
wslPathBackend GeneralShellType PowerShell OperatingSystem Windows
wslPathBackend GeneralShellType PowerShell OperatingSystem Windows
wslPathBackend PosixShellType Bash OperatingSystem Linux
wslPathBackend PosixShellType Bash OperatingSystem Linux
wslPathBackend PosixShellType Bash OperatingSystem Linux
wslPathBackend PosixShellType Bash OperatingSystem Linux
,
,
}
from
'../../../../../platform/terminal/common/terminal.js'
;
import
{
}
from
'../../../../../base/test/common/utils.js'
;
import
{
,
}
from
'../../../../test/common/workbenchTestServices.js'
;
import
{
}
from
'../../../../../platform/workspace/test/common/testWorkspace.js'
;
const
=
{
:
async
(
:
string
,
:
'unix-to-win'
|
'win-to-unix'
)
=>
{
if
(
===
'unix-to-win'
)
{
const
=
.
match
(
/ ^ \/ mnt\/ (?<drive > [ a- z A- Z ] ) \/ (?<path > . + ) $ /
)
;
const
=
?.
;
if
(
!
)
{
return
;
}
return
` ${ groups. drive} :\\ ${ groups. path. replace ( / \/ / g , '\\' ) } `
;
}
const
=
.
match
(
/ (?<drive > [ a- z A- Z ] ) :\\ (?<path > . + ) /
)
;
const
=
?.
;
if
(
!
)
{
return
;
}
return
` /mnt/ ${ groups. drive. toLowerCase ( ) } / ${ groups. path. replace ( / \\ / g , '/' ) } `
;
}
}
;
suite
(
'Workbench - TerminalEnvironment'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
suite
(
'addTerminalEnvironmentKeys'
,
(
)
=>
{
test
(
'should set expected variables'
,
(
)
=>
{
const
:
{
[
:
string
]
:
any
}
=
{
}
;
addTerminalEnvironmentKeys
(
,
'1.2.3'
,
'en'
,
'on'
)
;
strictEqual
(
[
'TERM_PROGRAM'
]
,
'vscode'
)
;
strictEqual
(
[
'TERM_PROGRAM_VERSION'
]
,
'1.2.3'
)
;
strictEqual
(
[
'COLORTERM'
]
,
'truecolor'
)
;
strictEqual
(
[
'LANG'
]
,
'en_US.UTF-8'
)
;
}
)
;
test
(
'should use language variant for LANG that is provided in locale'
,
(
)
=>
{
const
:
{
[
:
string
]
:
any
}
=
{
}
;
addTerminalEnvironmentKeys
(
,
'1.2.3'
,
'en-au'
,
'on'
)
;
strictEqual
(
[
'LANG'
]
,
'en_AU.UTF-8'
,
'LANG is equal to the requested locale with UTF-8'
)
;
}
)
;
test
(
'should fallback to en_US when no locale is provided'
,
(
)
=>
{
const
:
{
[
:
string
]
:
any
}
=
{
FOO
:
'bar'
}
;
addTerminalEnvironmentKeys
(
,
'1.2.3'
,
undefined
,
'on'
)
;
strictEqual
(
[
'LANG'
]
,
'en_US.UTF-8'
,
'LANG is equal to en_US.UTF-8 as fallback.'
)
;
}
)
;
test
(
'should fallback to en_US when an invalid locale is provided'
,
(
)
=>
{
const
=
{
LANG
:
'replace'
}
;
addTerminalEnvironmentKeys
(
,
'1.2.3'
,
undefined
,
'on'
)
;
strictEqual
(
[
'LANG'
]
,
'en_US.UTF-8'
,
'LANG is set to the fallback LANG'
)
;
}
)
;
test
(
'should override existing LANG'
,
(
)
=>
{
const
=
{
LANG
:
'en_AU.UTF-8'
}
;
addTerminalEnvironmentKeys
(
,
'1.2.3'
,
undefined
,
'on'
)
;
strictEqual
(
[
'LANG'
]
,
'en_US.UTF-8'
,
'LANG is equal to the parent environment\'s LANG'
)
;
}
)
;
}
)
;
suite
(
'shouldSetLangEnvVariable'
,
(
)
=>
{
test
(
'auto'
,
(
)
=>
{
strictEqual
(
shouldSetLangEnvVariable
(
{
}
,
'auto'
)
,
true
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US'
}
,
'auto'
)
,
true
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.utf'
}
,
'auto'
)
,
true
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.utf8'
}
,
'auto'
)
,
false
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.UTF-8'
}
,
'auto'
)
,
false
)
;
}
)
;
test
(
'off'
,
(
)
=>
{
strictEqual
(
shouldSetLangEnvVariable
(
{
}
,
'off'
)
,
false
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US'
}
,
'off'
)
,
false
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.utf'
}
,
'off'
)
,
false
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.utf8'
}
,
'off'
)
,
false
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.UTF-8'
}
,
'off'
)
,
false
)
;
}
)
;
test
(
'on'
,
(
)
=>
{
strictEqual
(
shouldSetLangEnvVariable
(
{
}
,
'on'
)
,
true
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US'
}
,
'on'
)
,
true
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.utf'
}
,
'on'
)
,
true
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.utf8'
}
,
'on'
)
,
true
)
;
strictEqual
(
shouldSetLangEnvVariable
(
{
LANG
:
'en-US.UTF-8'
}
,
'on'
)
,
true
)
;
}
)
;
}
)
;
suite
(
'getLangEnvVariable'
,
(
)
=>
{
test
(
'should fallback to en_US when no locale is provided'
,
(
)
=>
{
strictEqual
(
getLangEnvVariable
(
undefined
)
,
'en_US.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
''
)
,
'en_US.UTF-8'
)
;
}
)
;
test
(
'should fallback to default language variants when variant isn\'t provided'
,
(
)
=>
{
strictEqual
(
getLangEnvVariable
(
'af'
)
,
'af_ZA.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'am'
)
,
'am_ET.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'be'
)
,
'be_BY.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'bg'
)
,
'bg_BG.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'ca'
)
,
'ca_ES.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'cs'
)
,
'cs_CZ.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'da'
)
,
'da_DK.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'de'
)
,
'de_DE.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'el'
)
,
'el_GR.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'en'
)
,
'en_US.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'es'
)
,
'es_ES.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'et'
)
,
'et_EE.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'eu'
)
,
'eu_ES.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'fi'
)
,
'fi_FI.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'fr'
)
,
'fr_FR.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'he'
)
,
'he_IL.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'hr'
)
,
'hr_HR.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'hu'
)
,
'hu_HU.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'hy'
)
,
'hy_AM.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'is'
)
,
'is_IS.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'it'
)
,
'it_IT.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'ja'
)
,
'ja_JP.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'kk'
)
,
'kk_KZ.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'ko'
)
,
'ko_KR.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'lt'
)
,
'lt_LT.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'nl'
)
,
'nl_NL.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'no'
)
,
'no_NO.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'pl'
)
,
'pl_PL.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'pt'
)
,
'pt_BR.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'ro'
)
,
'ro_RO.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'ru'
)
,
'ru_RU.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'sk'
)
,
'sk_SK.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'sl'
)
,
'sl_SI.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'sr'
)
,
'sr_YU.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'sv'
)
,
'sv_SE.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'tr'
)
,
'tr_TR.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'uk'
)
,
'uk_UA.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'zh'
)
,
'zh_CN.UTF-8'
)
;
}
)
;
test
(
'should set language variant based on full locale'
,
(
)
=>
{
strictEqual
(
getLangEnvVariable
(
'en-AU'
)
,
'en_AU.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'en-au'
)
,
'en_AU.UTF-8'
)
;
strictEqual
(
getLangEnvVariable
(
'fa-ke'
)
,
'fa_KE.UTF-8'
)
;
}
)
;
}
)
;
suite
(
'mergeEnvironments'
,
(
)
=>
{
test
(
'should add keys'
,
(
)
=>
{
const
=
{
:
'b'
}
;
const
=
{
:
'd'
}
;
mergeEnvironments
(
,
)
;
deepStrictEqual
(
,
{
:
'b'
,
:
'd'
}
)
;
}
)
;
(
!
?
.
:
)
(
'should add keys ignoring case on Windows'
,
(
)
=>
{
const
=
{
:
'b'
}
;
const
=
{
A
:
'c'
}
;
mergeEnvironments
(
,
)
;
deepStrictEqual
(
,
{
:
'c'
}
)
;
}
)
;
test
(
'null values should delete keys from the parent env'
,
(
)
=>
{
const
=
{
:
'b'
,
:
'd'
}
;
const
:
<
string
|
null
>
=
{
:
null
}
;
mergeEnvironments
(
,
)
;
deepStrictEqual
(
,
{
:
'd'
}
)
;
}
)
;
(
!
?
.
:
)
(
'null values should delete keys from the parent env ignoring case on Windows'
,
(
)
=>
{
const
=
{
:
'b'
,
:
'd'
}
;
const
:
<
string
|
null
>
=
{
A
:
null
}
;
mergeEnvironments
(
,
)
;
deepStrictEqual
(
,
{
:
'd'
}
)
;
}
)
;
}
)
;
suite
(
'getCwd'
,
(
)
=>
{
function
assertPathsMatch
(
:
string
,
:
string
)
:
void
{
strictEqual
(
.
file
(
)
.
,
.
file
(
)
.
)
;
}
test
(
'should default to userHome for an empty workspace'
,
async
(
)
=>
{
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
undefined
,
undefined
)
,
'/userHome/'
)
;
}
)
;
test
(
'should use to the workspace if it exists'
,
async
(
)
=>
{
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
.
file
(
'/foo'
)
,
undefined
)
,
'/foo'
)
;
}
)
;
test
(
'should use an absolute custom cwd as is'
,
async
(
)
=>
{
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
undefined
,
'/foo'
)
,
'/foo'
)
;
}
)
;
test
(
'should normalize a relative custom cwd against the workspace path'
,
async
(
)
=>
{
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
.
file
(
'/bar'
)
,
'foo'
)
,
'/bar/foo'
)
;
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
.
file
(
'/bar'
)
,
'./foo'
)
,
'/bar/foo'
)
;
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
.
file
(
'/bar'
)
,
'../foo'
)
,
'/foo'
)
;
}
)
;
test
(
'should fall back for relative a custom cwd that doesn\'t have a workspace'
,
async
(
)
=>
{
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
undefined
,
'foo'
)
,
'/userHome/'
)
;
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
undefined
,
'./foo'
)
,
'/userHome/'
)
;
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
}
,
'/userHome/'
,
undefined
,
undefined
,
'../foo'
)
,
'/userHome/'
)
;
}
)
;
test
(
'should ignore custom cwd when told to ignore'
,
async
(
)
=>
{
assertPathsMatch
(
await
getCwd
(
{
:
undefined
,
:
[
]
,
:
true
}
,
'/userHome/'
,
undefined
,
.
file
(
'/bar'
)
,
'/foo'
)
,
'/bar'
)
;
}
)
;
}
)
;
suite
(
'preparePathForShell'
,
(
)
=>
{
suite
(
'Windows frontend, Windows backend'
,
(
)
=>
{
test
(
'Command Prompt'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar'
,
'cmd'
,
'cmd'
,
.
,
,
.
,
true
)
,
` c:\\foo\\bar `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar\'baz'
,
'cmd'
,
'cmd'
,
.
,
,
.
,
true
)
,
` c:\\foo\\bar'baz `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar$(echo evil)baz'
,
'cmd'
,
'cmd'
,
.
,
,
.
,
true
)
,
` "c:\\foo\\bar$(echo evil)baz" `
)
;
}
)
;
test
(
'PowerShell'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar'
,
'pwsh'
,
'pwsh'
,
.
,
,
.
,
true
)
,
` c:\\foo\\bar `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar\'baz'
,
'pwsh'
,
'pwsh'
,
.
,
,
.
,
true
)
,
` & 'c:\\foo\\bar''baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar$(echo evil)baz'
,
'pwsh'
,
'pwsh'
,
.
,
,
.
,
true
)
,
` & 'c:\\foo\\bar$(echo evil)baz' `
)
;
}
)
;
test
(
'Git Bash'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar'
,
'bash'
,
'bash'
,
.
,
,
.
,
true
)
,
` 'c:/foo/bar' `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar\'baz'
,
'bash'
,
'bash'
,
.
,
,
.
,
true
)
,
` 'c:/foo/bar\\'baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar$(echo evil)baz'
,
'bash'
,
'bash'
,
.
,
,
.
,
true
)
,
` 'c:/foo/bar(echo evil)baz' `
)
;
}
)
;
test
(
'WSL'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar'
,
'bash'
,
'bash'
,
.
,
,
.
,
true
)
,
'/mnt/c/foo/bar'
)
;
}
)
;
}
)
;
suite
(
'Windows frontend, Linux backend'
,
(
)
=>
{
test
(
'Bash'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'/foo/bar'
,
'bash'
,
'bash'
,
.
,
,
.
,
true
)
,
` '/foo/bar' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar\'baz'
,
'bash'
,
'bash'
,
.
,
,
.
,
true
)
,
` '/foo/bar\\'baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar$(echo evil)baz'
,
'bash'
,
'bash'
,
.
,
,
.
,
true
)
,
` '/foo/bar(echo evil)baz' `
)
;
}
)
;
test
(
'Zsh'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'/foo/bar'
,
'zsh'
,
'zsh'
,
.
,
,
.
,
true
)
,
` '/foo/bar' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar\'baz'
,
'zsh'
,
'zsh'
,
.
,
,
.
,
true
)
,
` '/foo/bar\\'baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar$(echo evil)baz'
,
'zsh'
,
'zsh'
,
.
,
,
.
,
true
)
,
` '/foo/bar(echo evil)baz' `
)
;
}
)
;
test
(
'Fish'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'/foo/bar'
,
'fish'
,
'fish'
,
.
,
,
.
,
true
)
,
` '/foo/bar' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar\'baz'
,
'fish'
,
'fish'
,
.
,
,
.
,
true
)
,
` '/foo/bar\\'baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar$(echo evil)baz'
,
'fish'
,
'fish'
,
.
,
,
.
,
true
)
,
` '/foo/bar(echo evil)baz' `
)
;
}
)
;
}
)
;
suite
(
'Linux frontend, Windows backend'
,
(
)
=>
{
test
(
'Command Prompt'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar'
,
'cmd'
,
'cmd'
,
.
,
,
.
,
false
)
,
` c:\\foo\\bar `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar\'baz'
,
'cmd'
,
'cmd'
,
.
,
,
.
,
false
)
,
` c:\\foo\\bar'baz `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar$(echo evil)baz'
,
'cmd'
,
'cmd'
,
.
,
,
.
,
false
)
,
` "c:\\foo\\bar$(echo evil)baz" `
)
;
}
)
;
test
(
'PowerShell'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar'
,
'pwsh'
,
'pwsh'
,
.
,
,
.
,
false
)
,
` c:\\foo\\bar `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar\'baz'
,
'pwsh'
,
'pwsh'
,
.
,
,
.
,
false
)
,
` & 'c:\\foo\\bar''baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar$(echo evil)baz'
,
'pwsh'
,
'pwsh'
,
.
,
,
.
,
false
)
,
` & 'c:\\foo\\bar$(echo evil)baz' `
)
;
}
)
;
test
(
'Git Bash'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar'
,
'bash'
,
'bash'
,
.
,
,
.
,
false
)
,
` 'c:/foo/bar' `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar\'baz'
,
'bash'
,
'bash'
,
.
,
,
.
,
false
)
,
` 'c:/foo/bar\\'baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar$(echo evil)baz'
,
'bash'
,
'bash'
,
.
,
,
.
,
false
)
,
` 'c:/foo/bar(echo evil)baz' `
)
;
}
)
;
test
(
'WSL'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'c:\\foo\\bar'
,
'bash'
,
'bash'
,
.
,
,
.
,
false
)
,
'/mnt/c/foo/bar'
)
;
}
)
;
}
)
;
suite
(
'Linux frontend, Linux backend'
,
(
)
=>
{
test
(
'Bash'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'/foo/bar'
,
'bash'
,
'bash'
,
.
,
,
.
,
false
)
,
` '/foo/bar' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar\'baz'
,
'bash'
,
'bash'
,
.
,
,
.
,
false
)
,
` '/foo/bar\\'baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar$(echo evil)baz'
,
'bash'
,
'bash'
,
.
,
,
.
,
false
)
,
` '/foo/bar(echo evil)baz' `
)
;
}
)
;
test
(
'Zsh'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'/foo/bar'
,
'zsh'
,
'zsh'
,
.
,
,
.
,
false
)
,
` '/foo/bar' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar\'baz'
,
'zsh'
,
'zsh'
,
.
,
,
.
,
false
)
,
` '/foo/bar\\'baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar$(echo evil)baz'
,
'zsh'
,
'zsh'
,
.
,
,
.
,
false
)
,
` '/foo/bar(echo evil)baz' `
)
;
}
)
;
test
(
'Fish'
,
async
(
)
=>
{
strictEqual
(
await
preparePathForShell
(
'/foo/bar'
,
'fish'
,
'fish'
,
.
,
,
.
,
false
)
,
` '/foo/bar' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar\'baz'
,
'fish'
,
'fish'
,
.
,
,
.
,
false
)
,
` '/foo/bar\\'baz' `
)
;
strictEqual
(
await
preparePathForShell
(
'/foo/bar$(echo evil)baz'
,
'fish'
,
'fish'
,
.
,
,
.
,
false
)
,
` '/foo/bar(echo evil)baz' `
)
;
}
)
;
}
)
;
}
)
;
suite
(
'createTerminalEnvironment'
,
(
)
=>
{
const
=
{
COLORTERM
:
'truecolor'
,
TERM_PROGRAM
:
'vscode'
}
;
test
(
'should retain variables equal to the empty string'
,
async
(
)
=>
{
deepStrictEqual
(
await
createTerminalEnvironment
(
{
}
,
undefined
,
undefined
,
undefined
,
'off'
,
{
:
'bar'
,
:
''
}
)
,
{
:
'bar'
,
:
''
,
...
}
)
;
}
)
;
}
)
;
suite
(
'getWorkspaceForTerminal'
,
(
)
=>
{
test
(
'should resolve workspace folder from cwd, not last active workspace'
,
(
)
=>
{
const
=
.
file
(
'/workspace/proj1'
)
;
const
=
.
file
(
'/workspace/proj2'
)
;
const
=
new
TestContextService
(
testWorkspace
(
,
)
)
;
const
=
new
TestHistoryService
(
)
;
const
=
getWorkspaceForTerminal
(
,
,
)
;
strictEqual
(
?.
.
,
.
)
;
}
)
;
test
(
'should fall back to last active workspace when cwd is not in any workspace folder'
,
(
)
=>
{
const
=
.
file
(
'/workspace/proj1'
)
;
const
=
new
TestContextService
(
testWorkspace
(
)
)
;
const
=
new
TestHistoryService
(
)
;
const
=
getWorkspaceForTerminal
(
.
file
(
'/other/path'
)
,
,
)
;
strictEqual
(
?.
.
,
.
)
;
}
)
;
test
(
'should fall back to last active workspace when cwd is undefined'
,
(
)
=>
{
const
=
.
file
(
'/workspace/proj1'
)
;
const
=
new
TestContextService
(
testWorkspace
(
)
)
;
const
=
new
TestHistoryService
(
)
;
strictEqual
(
getWorkspaceForTerminal
(
undefined
,
,
)
?.
.
,
.
)
;
}
)
;
test
(
'should return undefined when cwd and history are both unavailable'
,
(
)
=>
{
const
=
new
TestContextService
(
testWorkspace
(
.
file
(
'/workspace/proj1'
)
)
)
;
const
=
new
TestHistoryService
(
undefined
)
;
strictEqual
(
getWorkspaceForTerminal
(
undefined
,
,
)
,
undefined
)
;
}
)
;
}
)
;
suite
(
'formatUriForShellDisplay'
,
(
)
=>
{
test
(
'Wsl'
,
async
(
)
=>
{
strictEqual
(
await
getUriLabelForShell
(
'c:\\foo\\bar'
,
,
.
,
.
,
true
)
,
'/mnt/c/foo/bar'
)
;
strictEqual
(
await
getUriLabelForShell
(
'c:/foo/bar'
,
,
.
,
.
,
false
)
,
'/mnt/c/foo/bar'
)
;
}
)
;
test
(
'GitBash'
,
async
(
)
=>
{
strictEqual
(
await
getUriLabelForShell
(
'c:\\foo\\bar'
,
,
.
,
.
,
true
)
,
'/c/foo/bar'
)
;
strictEqual
(
await
getUriLabelForShell
(
'c:/foo/bar'
,
,
.
,
.
,
false
)
,
'/c/foo/bar'
)
;
}
)
;
suite
(
'PowerShell'
,
(
)
=>
{
test
(
'Windows frontend'
,
async
(
)
=>
{
strictEqual
(
await
getUriLabelForShell
(
'c:\\foo\\bar'
,
,
.
,
.
,
true
)
,
'c:\\foo\\bar'
)
;
strictEqual
(
await
getUriLabelForShell
(
'C:\\Foo\\Bar'
,
,
.
,
.
,
true
)
,
'C:\\Foo\\Bar'
)
;
}
)
;
test
(
'Non-Windows frontend'
,
async
(
)
=>
{
strictEqual
(
await
getUriLabelForShell
(
'c:/foo/bar'
,
,
.
,
.
,
false
)
,
'c:\\foo\\bar'
)
;
strictEqual
(
await
getUriLabelForShell
(
'C:/Foo/Bar'
,
,
.
,
.
,
false
)
,
'C:\\Foo\\Bar'
)
;
}
)
;
}
)
;
suite
(
'Bash'
,
(
)
=>
{
test
(
'Windows frontend'
,
async
(
)
=>
{
strictEqual
(
await
getUriLabelForShell
(
'\\foo\\bar'
,
,
.
,
.
,
true
)
,
'/foo/bar'
)
;
strictEqual
(
await
getUriLabelForShell
(
'/foo/bar'
,
,
.
,
.
,
true
)
,
'/foo/bar'
)
;
}
)
;
test
(
'Non-Windows frontend'
,
async
(
)
=>
{
strictEqual
(
await
getUriLabelForShell
(
'\\foo\\bar'
,
,
.
,
.
,
false
)
,
'\\foo\\bar'
)
;
strictEqual
(
await
getUriLabelForShell
(
'/foo/bar'
,
,
.
,
.
,
false
)
,
'/foo/bar'
)
;
}
)
;
}
)
;
}
)
;
}
)
;