-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes when there are spaces in test target name #47
Fixes when there are spaces in test target name #47
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I have one question, but otherwise this looks good to me
src/meson/runners.ts
Outdated
const title = name ? `Building target ${name}` : "Building project"; | ||
|
||
getOutputChannel().append(`\n${title}\n`); | ||
const stream = execStream(`meson compile ${name ?? ""}`, { cwd: buildDir }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be quoted too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd only done test targets as surely nobody puts spaces in binary names 😀
That said, the one you reference ends up spawning and not going via the shell:
Lines 34 to 42 in fbede29
export function execStream( | |
command: string | string[], | |
options: cp.SpawnOptions | |
) { | |
//FIXME: Force string array and fix callers | |
if (typeof command === "string") { | |
command = command.split(" "); | |
} | |
const spawned = cp.spawn(command[0], command.slice(1), options); |
So quoting breaks it there. The FIXME
would solve the problem I suppose, though I get the feeling from looking at the code some greater refactoring to tidy up the multiple routes things can take is the right solution...
I'll update the PR for one other compile command that is going via the shell for now.
9f5c418
to
067ac05
Compare
Actually scratch that. Thought I'd better check what Windows does (well, Powershell) and it is pretty horrible. That said, looks like |
* typescript 2.4.1 -> 4.4.4 * vscode 1.1.34 -> 1.1.37 * types/node 12.0.2 -> 16.11.7
067ac05
to
8828b01
Compare
OK here's a revised work in progress that works with powershell. Still draft as there's a few things I need to look at, but any feedback welcome in the meantime! The main fix was switching from #47 (comment) is also done now. TODO:
Cheers |
999b67e
to
b48d540
Compare
Meson requires the separator between path and target name to be '/'. ALso, since the full target name can now end up as "path\to/targetName", don't show path\to in the tree view (it's implicit from the nodes anyway).
Don't do that. Also removed unused exec() function.
…presumably) intended.
…ate command/args parameters. Will allow spaces in target names to work cross-platform (avoiding shell escaping issues). No uses require shell variable expansion, etc.
Should allow target names with spaces.
I.e. Meson -> Run Unit Tests -> all, or specific test name with spaces. Uses ProcessExecution rather than ShellExecution for ninja/meson invocation to avoid shell space escaping issues. No uses require variable expansion, etc.
Samurai now works, via NINJA=samu.
b48d540
to
84a3be0
Compare
OK here's a "final" version I'm happy with, with one caveat:
I did this in 84a3be0. But I could see an issue - if someone's used a shell variable in their configure options, then previously it would've been expanded but now won't be. Would be nice if there was an API to support vscode variable expansion and use that (e.g. microsoft/vscode#46471) but I guess not. So maybe this commit should be binned? There's no real downside (aside from being nice to consistently avoid the shell) unless someone has spaces in their build dir, AFAICT...
That was a pretty trivial fix. Meson seems to be happy as long as the separator between dir and target name is a forward slash. Hope it's useful. Makes the extension usable for me anyway! I've got a few more other fixes but unrelated, so might as well get this in first. |
Would that also prevent shell variables that meson interpreters internally stop working? I do rely on that (PKG_CONFIG_PATH, in particular) |
Which bit in particular do you mean? The avoiding of the shell when running meson commands in general or the specific case I mention in 84a3be0? For 84a3be0, what I'm saying is if you had say It's the only case in the extension I could see where there might be an issue. All the other uses are just For the first case - whatever environment VSCode has will be inherited by the meson it runs, it's just that there's no longer a shell process in the middle. So wherever meson is doing HTH! |
Yeah, that should be fine. I use nix, so having environment variables is pretty important for things to work, lol |
Hi
Great that this extension is now part of the meson project and will hopefully get some love.
Here are some patches to fix a few issues with spaces in test target names and to use
meson
rather thanninja
for all commands (I usesamurai
).I other less trivial ones but thought I'd see if these are of interest first.
Regards