[libc++] Allow specifying arbitrary custom executors with the new format
authorLouis Dionne <ldionne@apple.com>
Thu, 11 Jun 2020 19:41:38 +0000 (15:41 -0400)
committerLouis Dionne <ldionne@apple.com>
Thu, 11 Jun 2020 20:24:29 +0000 (16:24 -0400)
The integration between CMake and executor selection in the new format
wasn't very flexible -- only the default executor and SSH executors were
supported.

This patch makes it possible to specify arbitrary executors with the new
format. With the new testing format, a custom executor is just a script
that gets called with a command-line to execute, and some arguments like
--env, --codesign_identity and --execdir. As such, the default executor
is just run.py.

Remote execution with the SSH executor can be achived by specifying
LIBCXX_EXECUTOR="<path-to-ssh.py> --host <host>". Similarly, arbitrary
scripts can be provided.

libcxx/test/CMakeLists.txt
libcxx/utils/libcxx/test/config.py
libcxxabi/test/CMakeLists.txt
libunwind/test/CMakeLists.txt

index 5068cbd..b68f59f 100644 (file)
@@ -81,7 +81,7 @@ endif()
 
 set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
     "TargetInfo to use when setting up test environment.")
-set(LIBCXX_EXECUTOR "None" CACHE STRING
+set(LIBCXX_EXECUTOR "${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING
     "Executor to use when running tests.")
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
index 5eccc27..44cb959 100644 (file)
@@ -189,18 +189,22 @@ class Configuration(object):
             exec_env=self.exec_env)
 
     def configure_executor(self):
-        exec_str = self.get_lit_conf('executor', "None")
-        te = eval(exec_str)
-        if te:
-            self.lit_config.note("Using executor: %r" % exec_str)
-            if self.lit_config.useValgrind:
-                self.lit_config.fatal("The libc++ test suite can't run under Valgrind with a custom executor")
-        else:
-            te = LocalExecutor()
+        if self.get_lit_conf('use_old_format'):
+            exec_str = self.get_lit_conf('executor', "None")
+            te = eval(exec_str)
+            if te:
+                self.lit_config.note("Using executor: %r" % exec_str)
+                if self.lit_config.useValgrind:
+                    self.lit_config.fatal("The libc++ test suite can't run under Valgrind with a custom executor")
+            else:
+                te = LocalExecutor()
 
-        te.target_info = self.target_info
-        self.target_info.executor = te
-        self.executor = te
+            te.target_info = self.target_info
+            self.target_info.executor = te
+            self.executor = te
+        else:
+            self.executor = self.get_lit_conf('executor')
+            self.lit_config.note("Using executor: {}".format(self.executor))
 
     def configure_target_info(self):
         self.target_info = make_target_info(self)
@@ -751,14 +755,8 @@ class Configuration(object):
             '--codesign_identity "{}"'.format(codesign_ident),
             '--env {}'.format(env_vars)
         ]
-        if isinstance(self.executor, SSHExecutor):
-            exec_args.append('--host {}'.format(self.executor.user_prefix + self.executor.host))
-            executor = os.path.join(self.libcxx_src_root, 'utils', 'ssh.py')
-        else:
-            executor = os.path.join(self.libcxx_src_root, 'utils', 'run.py')
-        sub.append(('%{exec}', '{} {} {} -- '.format(pipes.quote(sys.executable),
-                                                     pipes.quote(executor),
-                                                     ' '.join(exec_args))))
+        if not self.get_lit_conf('use_old_format'):
+            sub.append(('%{exec}', '{} {} -- '.format(self.executor, ' '.join(exec_args))))
         if self.get_lit_conf('libcxx_gdb'):
             sub.append(('%{libcxx_gdb}', self.get_lit_conf('libcxx_gdb')))
 
index bedfce8..2160f52 100644 (file)
@@ -32,7 +32,7 @@ if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_SHARED)
 endif()
 
 if(DEFINED LIBCXX_ENABLE_STATIC
-   AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX 
+   AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
    AND NOT LIBCXX_ENABLE_STATIC)
   message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON")
 endif()
@@ -50,7 +50,7 @@ pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX)
 pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI)
 set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
     "TargetInfo to use when setting up test environment.")
-set(LIBCXXABI_EXECUTOR "None" CACHE STRING
+set(LIBCXXABI_EXECUTOR "${Python3_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/run.py" CACHE STRING
     "Executor to use when running tests.")
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")
index e608c17..26e7842 100644 (file)
@@ -20,7 +20,8 @@ pythonize_bool(LIBUNWIND_USE_COMPILER_RT)
 pythonize_bool(LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY)
 set(LIBUNWIND_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
     "TargetInfo to use when setting up test environment.")
-set(LIBUNWIND_EXECUTOR "None" CACHE STRING
+set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../../libcxx")
+set(LIBUNWIND_EXECUTOR "${Python3_EXECUTABLE} ${LIBUNWIND_LIBCXX_PATH}/utils/run.py" CACHE STRING
     "Executor to use when running tests.")
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libunwind configuration.\n# Do not edit!")