Use more portable paths in the test explorer #2194
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #1808 (comment)
With the R extension's log level set to "debug", you can get this info about the error:
I was able to reproduce the problem in a windows VM and this fixes it for me.
Relevant context:
Prior to this PR, the test-running command looked something like this:
Note the paths in the snippet of R code and, specifically, the different path separators. The problem was the Windows-style path where the backslashes aren't escaped, i.e. doubled. In the error above, you can tell that the
load_all()
command actually succeeds, so it's the path intest_active_file()
that is the problem. The solution is to use POSIX-style path separation. Here's how the test-running command looks with this PR:This treatment was already in place for the path to the embedded test reporter package and now it's clear why.
positron/extensions/positron-r/src/testing/runner-testthat.ts
Lines 17 to 19 in 9362409
This approach is consistent with the advice given in the R for Windows FAQ:
FWIW
child_process.spawn(..., { shell: true })
is launching acmd.exe
shell on Windows, but this turns out to be neither here nor there in terms of this problem.