[libcxx-commits] [libcxx] [libc++][lit] Allow overriding the executor for tests (PR #66545)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 15 13:29:41 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
<details>
<summary>Changes</summary>
This is useful when trying to run multiple tests with different arguments to the executor script. This is needed in my case since I do not know the correct ssh connection arguments when building libc++. The testing script I have spawns multiple QEMU instances that listen on a given port on localhost and runs lit with the `--num-shards/--run-shard` argument. In order to connect each shard to the right QEMU instances I need to customize the arguments passed to ssh.py (`--extra-ssh-args` and `--extra-scp-args`) but can't do this at configure time since the target port is only known when running the tests but not when calling CMake. This change allows me to pass `-Dexecutor=ssh.py <args>` to lit once I know the right hostname/port for running the tests.
---
Full diff: https://github.com/llvm/llvm-project/pull/66545.diff
2 Files Affected:
- (modified) libcxx/utils/libcxx/test/dsl.py (+23)
- (modified) libcxx/utils/libcxx/test/params.py (+9)
``````````diff
diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py
index 847cebf5962f6aa..778c15bf881175c 100644
--- a/libcxx/utils/libcxx/test/dsl.py
+++ b/libcxx/utils/libcxx/test/dsl.py
@@ -581,6 +581,29 @@ def pretty(self, config, litParams):
return "add substitution {} = {}".format(self._key, self._getSub(config))
+class OverrideSubstitution(AddSubstitution):
+ """
+ This action replaces the given substitution in the Lit configuration.
+
+ The substitution can be a string or a callable, in which case it is called
+ with the configuration to produce the actual substitution (as a string).
+ """
+
+ def applyTo(self, config):
+ key = self._key
+ sub = self._getSub(config)
+ for i, val in enumerate(config.substitutions):
+ if val[0] == key:
+ config.substitutions[i] = (key, sub)
+ return
+ raise ValueError(
+ "Expected substitution {} to already be defined".format(key)
+ )
+
+ def pretty(self, config, litParams):
+ return "replace substitution {} = {}".format(self._key, self._getSub(config))
+
+
class Feature(object):
"""
Represents a Lit available feature that is enabled whenever it is supported.
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index e05c6689964c734..dfe6fc7d11e804d 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -330,5 +330,14 @@ def getModuleFlag(cfg, enable_modules):
AddCompileFlag("-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES"),
],
),
+ Parameter(
+ name="executor",
+ type=str,
+ default="",
+ help="Custom executor to use instead of the configured default.",
+ actions=lambda executor: [] if not executor else [
+ OverrideSubstitution("%{executor}", executor)
+ ],
+ )
]
# fmt: on
``````````
</details>
https://github.com/llvm/llvm-project/pull/66545
More information about the libcxx-commits
mailing list