X-Git-Url: https://git.josue.xyz/?p=VSoRC%2F.git;a=blobdiff_plain;f=node_modules%2Fnode-pty%2Fsrc%2FwindowsPtyAgent.test.ts;fp=node_modules%2Fnode-pty%2Fsrc%2FwindowsPtyAgent.test.ts;h=0000000000000000000000000000000000000000;hp=dc2104b34fd396722a9e30821ff0b7dea18b4295;hb=5e96dd57ddd883604e87f62bdddcb111c63a6e1a;hpb=acb5f682a2b75b972710cabd81658f63071324b0 diff --git a/node_modules/node-pty/src/windowsPtyAgent.test.ts b/node_modules/node-pty/src/windowsPtyAgent.test.ts deleted file mode 100644 index dc2104b..0000000 --- a/node_modules/node-pty/src/windowsPtyAgent.test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2017, Daniel Imms (MIT License). - * Copyright (c) 2018, Microsoft Corporation (MIT License). - */ - -import * as assert from 'assert'; -import { argsToCommandLine } from './windowsPtyAgent'; - -function check(file: string, args: string | string[], expected: string): void { - assert.equal(argsToCommandLine(file, args), expected); -} - -if (process.platform === 'win32') { - describe('argsToCommandLine', () => { - describe('Plain strings', () => { - it('doesn\'t quote plain string', () => { - check('asdf', [], 'asdf'); - }); - it('doesn\'t escape backslashes', () => { - check('\\asdf\\qwer\\', [], '\\asdf\\qwer\\'); - }); - it('doesn\'t escape multiple backslashes', () => { - check('asdf\\\\qwer', [], 'asdf\\\\qwer'); - }); - it('adds backslashes before quotes', () => { - check('"asdf"qwer"', [], '\\"asdf\\"qwer\\"'); - }); - it('escapes backslashes before quotes', () => { - check('asdf\\"qwer', [], 'asdf\\\\\\"qwer'); - }); - }); - - describe('Quoted strings', () => { - it('quotes string with spaces', () => { - check('asdf qwer', [], '"asdf qwer"'); - }); - it('quotes empty string', () => { - check('', [], '""'); - }); - it('quotes string with tabs', () => { - check('asdf\tqwer', [], '"asdf\tqwer"'); - }); - it('escapes only the last backslash', () => { - check('\\asdf \\qwer\\', [], '"\\asdf \\qwer\\\\"'); - }); - it('doesn\'t escape multiple backslashes', () => { - check('asdf \\\\qwer', [], '"asdf \\\\qwer"'); - }); - it('escapes backslashes before quotes', () => { - check('asdf \\"qwer', [], '"asdf \\\\\\"qwer"'); - }); - it('escapes multiple backslashes at the end', () => { - check('asdf qwer\\\\', [], '"asdf qwer\\\\\\\\"'); - }); - }); - - describe('Multiple arguments', () => { - it('joins arguments with spaces', () => { - check('asdf', ['qwer zxcv', '', '"'], 'asdf "qwer zxcv" "" \\"'); - }); - it('array argument all in quotes', () => { - check('asdf', ['"surounded by quotes"'], 'asdf \\"surounded by quotes\\"'); - }); - it('array argument quotes in the middle', () => { - check('asdf', ['quotes "in the" middle'], 'asdf "quotes \\"in the\\" middle"'); - }); - it('array argument quotes near start', () => { - check('asdf', ['"quotes" near start'], 'asdf "\\"quotes\\" near start"'); - }); - it('array argument quotes near end', () => { - check('asdf', ['quotes "near end"'], 'asdf "quotes \\"near end\\""'); - }); - }); - - describe('Args as CommandLine', () => { - it('should handle empty string', () => { - check('file', '', 'file'); - }); - it('should not change args', () => { - check('file', 'foo bar baz', 'file foo bar baz'); - check('file', 'foo \\ba"r \baz', 'file foo \\ba"r \baz'); - }); - }); - - describe('Real-world cases', () => { - it('quotes within quotes', () => { - check('cmd.exe', ['/c', 'powershell -noexit -command \'Set-location \"C:\\user\"\''], 'cmd.exe /c "powershell -noexit -command \'Set-location \\\"C:\\user\\"\'"'); - }); - it('space within quotes', () => { - check('cmd.exe', ['/k', '"C:\\Users\\alros\\Desktop\\test script.bat"'], 'cmd.exe /k \\"C:\\Users\\alros\\Desktop\\test script.bat\\"'); - }); - }); - }); -}