[libcxx-commits] [libcxx] 14f07bc - [libc++] Avoid using distutils.util in the DSL
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 28 10:33:31 PDT 2020
Author: Louis Dionne
Date: 2020-04-28T13:33:04-04:00
New Revision: 14f07bcab0d60669777fd70d9183c1dc803f12f5
URL: https://github.com/llvm/llvm-project/commit/14f07bcab0d60669777fd70d9183c1dc803f12f5
DIFF: https://github.com/llvm/llvm-project/commit/14f07bcab0d60669777fd70d9183c1dc803f12f5.diff
LOG: [libc++] Avoid using distutils.util in the DSL
Some bots apparently don't have that package.
Added:
Modified:
libcxx/utils/libcxx/test/dsl.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py
index ed1722574e44..9c0d68e71f14 100644
--- a/libcxx/utils/libcxx/test/dsl.py
+++ b/libcxx/utils/libcxx/test/dsl.py
@@ -6,7 +6,6 @@
#
#===----------------------------------------------------------------------===##
-import distutils.util
import libcxx.test.newformat
import lit
import lit.util
@@ -195,6 +194,24 @@ def enableIn(self, config):
config.available_features.add(name)
+def _str_to_bool(s):
+ """
+ Convert a string value to a boolean.
+
+ True values are "y", "yes", "t", "true", "on" and "1", regardless of capitalization.
+ False values are "n", "no", "f", "false", "off" and "0", regardless of capitalization.
+ """
+ trueVals = ["y", "yes", "t", "true", "on", "1"]
+ falseVals = ["n", "no", "f", "false", "off", "0"]
+ lower = s.lower()
+ if lower in trueVals:
+ return True
+ elif lower in falseVals:
+ return False
+ else:
+ raise ValueError("Got string '{}', which isn't a valid boolean".format(s))
+
+
class Parameter(object):
"""
Represents a parameter of a Lit test suite.
@@ -265,8 +282,8 @@ def __init__(self, name, choices, type, help, feature, default=None):
if len(self._choices) == 0:
raise ValueError("Parameter '{}' must be given at least one possible value".format(self._name))
- self._parse = lambda x: (distutils.util.strtobool(x) if type is bool and isinstance(x, str)
- else type(x))
+ self._parse = lambda x: (_str_to_bool(x) if type is bool and isinstance(x, str)
+ else type(x))
self._help = help
self._feature = feature
self._default = default
More information about the libcxx-commits
mailing list