romanresh / vscode-testcafe

This extension allows you to run TestCafe tests directly from VS Code
https://marketplace.visualstudio.com/items?itemName=romanresh.testcafe-test-runner
MIT License
47 stars 15 forks source link

Quoted arguments in testcafeTestRunner.customArguments are broken #40

Closed wwarby closed 3 years ago

wwarby commented 4 years ago

The following configuration used to work last time I ran my project (a few months ago) but no longer does:

"testcafeTestRunner.customArguments": "--ts-config-path ./.e2e/specs/tsconfig.json --env=local --selector-timeout 10000 --debug-on-fail --speed 1 --app \"serve ./.e2e -l 4789\""

The problem is that the quoted argument parameters to "--app" are not preserved as a quoted string, but rather the quotes themselves become escaped in the output:

env 'NODE_OPTIONS=--require "c:/Program Files/Microsoft VS Code/resources/ap
p/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" ' 'VSCODE_INSPECTOR_O
PTIONS={"inspectorIpc":"\\\\.\\pipe\\node-cdp.26200-7.sock","deferredMode":fals
e,"waitForDebugger":"","execPath":"C:\\Program Files\\nodejs\\node.exe","onlyEn
trypoint":false,"fileCallback":"C:\\Users\\wwarby\\AppData\\Local\\Temp\\node-d
ebug-callback-ebe6fa2be1fbbaea"}' "C:\\Program Files\\nodejs\\node.exe" --no-de
precation .\\node_modules\\testcafe\\lib\\cli\\index.js chrome c:\\GIT\\machine
\\ingress-scripts\\Impressions\\e2e\\specs\\latency-profiling-payload.spec.ts -
-ts-config-path ./.e2e/specs/tsconfig.json --env=local --selector-timeout 10000
 --debug-on-fail --speed 1 --app \"serve ./.e2e -l 4789\" --test "Latency profi
ling payload contains expected data"

As far as I can see the problem is at line 315 in /src/extension.ts where you are splitting on the space character without accounting for the fact that the arguments might contain quoted strings, so the quote itself gets treated as an argument.

My app can't work without that --app argument so this has completely broken the extension for me.

wwarby commented 3 years ago

Is this likely to be fixed any time soon? It's causing me a real headache. I'd be happy to take a stab at fixing it myself if that would help...

wwarby commented 3 years ago

I've patched my local copy of this extension now and added a pull request containing the fix

romanresh commented 3 years ago

Thanks, for your PR! I'll review the changes a bit later today. Sorry for a long answer, I threw myself into my work for a while :)

romanresh commented 3 years ago

published