diff --git a/libcxx/test/libcxx/selftest/dsl/dsl.sh.py b/libcxx/test/libcxx/selftest/dsl/dsl.sh.py index 5a8ae88e0531..b9437d6ca053 100644 --- a/libcxx/test/libcxx/selftest/dsl/dsl.sh.py +++ b/libcxx/test/libcxx/selftest/dsl/dsl.sh.py @@ -194,6 +194,16 @@ class TestFeature(SetupConfigs): feature.enableIn(self.config) self.assertIn('name', self.config.available_features) + def test_name_is_not_a_string_1(self): + feature = dsl.Feature(name=None) + assert feature.isSupported(self.config) + self.assertRaises(ValueError, lambda: feature.enableIn(self.config)) + + def test_name_is_not_a_string_2(self): + feature = dsl.Feature(name=lambda cfg: None) + assert feature.isSupported(self.config) + self.assertRaises(ValueError, lambda: feature.enableIn(self.config)) + def test_adding_compile_flag(self): feature = dsl.Feature(name='name', compileFlag='-foo') origLinkFlags = copy.deepcopy(self.getSubstitution('%{link_flags}')) diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py index bbed2bba76c4..3e2d0ed8ee33 100644 --- a/libcxx/utils/libcxx/test/dsl.py +++ b/libcxx/utils/libcxx/test/dsl.py @@ -220,6 +220,8 @@ class Feature(object): config.substitutions = addTo(config.substitutions, '%{link_flags}', linkFlag) name = self._name(config) if callable(self._name) else self._name + if not isinstance(name, str): + raise ValueError("Feature did not resolve to a name that's a string, got {}".format(name)) config.available_features.add(name)