Path: blob/main/src/vs/workbench/contrib/debug/test/node/terminals.test.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';7import { prepareCommand } from '../../node/terminals.js';8910suite('Debug - prepareCommand', () => {11ensureNoDisposablesAreLeakedInTestSuite();1213test('bash', () => {14assert.strictEqual(15prepareCommand('bash', ['{$} ('], false).trim(),16'\\{\\$\\}\\ \\(');17assert.strictEqual(18prepareCommand('bash', ['hello', 'world', '--flag=true'], false).trim(),19'hello world --flag=true');20assert.strictEqual(21prepareCommand('bash', [' space arg '], false).trim(),22'\\ space\\ arg\\');2324assert.strictEqual(25prepareCommand('bash', ['{$} ('], true).trim(),26'{$} (');27assert.strictEqual(28prepareCommand('bash', ['hello', 'world', '--flag=true'], true).trim(),29'hello world --flag=true');30assert.strictEqual(31prepareCommand('bash', [' space arg '], true).trim(),32'space arg');33});3435test('bash - do not escape > and <', () => {36assert.strictEqual(37prepareCommand('bash', ['arg1', '>', '> hello.txt', '<', '<input.in'], false).trim(),38'arg1 > \\>\\ hello.txt < \\<input.in');39});4041test('cmd', () => {42assert.strictEqual(43prepareCommand('cmd.exe', ['^!< '], false).trim(),44'"^^^!^< "');45assert.strictEqual(46prepareCommand('cmd.exe', ['hello', 'world', '--flag=true'], false).trim(),47'hello world --flag=true');48assert.strictEqual(49prepareCommand('cmd.exe', [' space arg '], false).trim(),50'" space arg "');51assert.strictEqual(52prepareCommand('cmd.exe', ['"A>0"'], false).trim(),53'"""A^>0"""');54assert.strictEqual(55prepareCommand('cmd.exe', [''], false).trim(),56'""');5758assert.strictEqual(59prepareCommand('cmd.exe', ['^!< '], true).trim(),60'^!<');61assert.strictEqual(62prepareCommand('cmd.exe', ['hello', 'world', '--flag=true'], true).trim(),63'hello world --flag=true');64assert.strictEqual(65prepareCommand('cmd.exe', [' space arg '], true).trim(),66'space arg');67assert.strictEqual(68prepareCommand('cmd.exe', ['"A>0"'], true).trim(),69'"A>0"');70assert.strictEqual(71prepareCommand('cmd.exe', [''], true).trim(),72'');73});7475test('cmd - do not escape > and <', () => {76assert.strictEqual(77prepareCommand('cmd.exe', ['arg1', '>', '> hello.txt', '<', '<input.in'], false).trim(),78'arg1 > "^> hello.txt" < ^<input.in');79});8081test('powershell', () => {82assert.strictEqual(83prepareCommand('powershell', ['!< '], false).trim(),84`& '!< '`);85assert.strictEqual(86prepareCommand('powershell', ['hello', 'world', '--flag=true'], false).trim(),87`& 'hello' 'world' '--flag=true'`);88assert.strictEqual(89prepareCommand('powershell', [' space arg '], false).trim(),90`& ' space arg '`);91assert.strictEqual(92prepareCommand('powershell', ['"A>0"'], false).trim(),93`& '"A>0"'`);94assert.strictEqual(95prepareCommand('powershell', [''], false).trim(),96`& ''`);9798assert.strictEqual(99prepareCommand('powershell', ['!< '], true).trim(),100'!<');101assert.strictEqual(102prepareCommand('powershell', ['hello', 'world', '--flag=true'], true).trim(),103'hello world --flag=true');104assert.strictEqual(105prepareCommand('powershell', [' space arg '], true).trim(),106'space arg');107assert.strictEqual(108prepareCommand('powershell', ['"A>0"'], true).trim(),109'"A>0"');110assert.strictEqual(111prepareCommand('powershell', [''], true).trim(),112``);113});114115test('powershell - do not escape > and <', () => {116assert.strictEqual(117prepareCommand('powershell', ['arg1', '>', '> hello.txt', '<', '<input.in'], false).trim(),118`& 'arg1' > '> hello.txt' < '<input.in'`);119});120});121122123