connorshea / vscode-ruby-test-adapter

A Ruby test adapter extension for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=connorshea.vscode-ruby-test-adapter
MIT License
83 stars 50 forks source link

Running a single test / single test file fails if the test file’s path contains spaces #41

Closed noniq closed 4 years ago

noniq commented 4 years ago

Your environment

Expected behavior

Running a single test / single test file works.

Actual behavior

Running a single test / single test file fails if the test file’s path contains spaces.

Cause

When constructing the command for running a single test, the test file’s path is not escaped, see https://github.com/connorshea/vscode-ruby-test-adapter/blob/fba16b983f2c61bdedef123cef33cd4624403d03/src/rspecTests.ts#L95

A quick workaround is to add quotes around ${testLocation} like this:

 let testCommand = `${this.getTestCommand()} --require ${this.getCustomFormatterLocation()} --format CustomFormatter "${testLocation}"`;

The proper fix would be to use shell escaping for all the arguments (including the test comannd and the formatter location).

Running a single test file suffers from the same issue, see https://github.com/connorshea/vscode-ruby-test-adapter/blob/fba16b983f2c61bdedef123cef33cd4624403d03/src/rspecTests.ts#L120