import os
import platform
import sys
+import subprocess
import lit.formats
from lit.llvm import llvm_config
config.environment['COVERAGE_PROCESS_START'] = os.path.join(
os.path.dirname(__file__), ".coveragerc")
-# Add a feature to detect if psutil is available
-supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
-if supported:
+# Add a feature to detect if test cancellation is available. Check the ability
+# to do cancellation in the same environment as where RUN commands are run.
+# The reason is that on most systems cancellation depends on psutil being
+# available and RUN commands are run with a cleared PYTHONPATH and user site
+# packages disabled.
+testing_script_path = "/".join((os.path.dirname(__file__),
+ "check-tested-lit-timeout-ability"))
+proc = subprocess.run([sys.executable, testing_script_path],
+ stderr=subprocess.PIPE, env=config.environment,
+ universal_newlines=True)
+if proc.returncode == 0:
config.available_features.add("lit-max-individual-test-time")
else:
+ errormsg = proc.stderr
lit_config.warning('Setting a timeout per test not supported. ' + errormsg
+ ' Some tests will be skipped and the --timeout'
' command line argument will not work.')