[llvm] [lldb] fix tests with spaces in command path (PR #138714)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 6 09:10:06 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-testing-tools
Author: Charles Zablit (charles-zablit)
<details>
<summary>Changes</summary>
# Summary
LLDB tests will fail with the "command not found" error if there are spaces in the command path.
This PR fixes the issue by quoting the command.
# Description
The path of a command that was substituted in a test file (for instance `lld-link`) may contain spaces. On windows, it will start will `C:\Program Files\...`. This will cause the command to be parsed as `['C:\Program', 'Files\...', ...`.
This causes the tests to fail.
# Fix
During the parsing stage of the test file, we use `shlex.quote` to shell escape the command path. The command is test parsed correctly by `ShUtil.ShParser.parse` and the rest of the flow is executed as expected.
---
Full diff: https://github.com/llvm/llvm-project/pull/138714.diff
1 Files Affected:
- (modified) llvm/utils/lit/lit/llvm/subst.py (+3)
``````````diff
diff --git a/llvm/utils/lit/lit/llvm/subst.py b/llvm/utils/lit/lit/llvm/subst.py
index 09ab3555a6b44..9d74db89bd6b4 100644
--- a/llvm/utils/lit/lit/llvm/subst.py
+++ b/llvm/utils/lit/lit/llvm/subst.py
@@ -1,5 +1,6 @@
import os
import re
+import shlex
import lit.util
@@ -118,6 +119,8 @@ def resolve(self, config, search_dirs):
command_str = str(self.command)
if command_str:
+ # A command path with spaces will fail to be parsed by ShParser if they are not quoted.
+ command_str = shlex.quote(command_str)
if self.extra_args:
command_str = " ".join([command_str] + self.extra_args)
else:
``````````
</details>
https://github.com/llvm/llvm-project/pull/138714
More information about the llvm-commits
mailing list