Пример #1
0
 def test_trivial(self):
     feature = dsl.Feature(name='name')
     origSubstitutions = copy.deepcopy(self.config.substitutions)
     self.assertTrue(feature.isSupported(self.config))
     feature.enableIn(self.config)
     self.assertEqual(origSubstitutions, self.config.substitutions)
     self.assertIn('name', self.config.available_features)
Пример #2
0
 def test_link_flag_can_be_a_callable(self):
     feature = dsl.Feature(name='name',
                           linkFlag=lambda cfg:
                           (self.assertIs(self.config, cfg), '-foo')[1])
     assert feature.isSupported(self.config)
     feature.enableIn(self.config)
     self.assertIn('-foo', self.getSubstitution('%{link_flags}'))
Пример #3
0
 def test_value_provided_in_config_and_default_value(self):
     """The value provided in the config should override the default value"""
     self.config.std ='c++11'
     param = dsl.Parameter(name='std', choices=['c++03', 'c++11'], type=str, default='c++03', help='',
                           feature=lambda std: dsl.Feature(name=std))
     param.getFeature(self.config, self.litConfig.params).enableIn(self.config)
     self.assertIn('c++11', self.config.available_features)
     self.assertNotIn('c++03', self.config.available_features)
Пример #4
0
 def test_actions_can_be_a_callable(self):
     feature = dsl.Feature(name='name',
                           actions=lambda cfg:
                           (self.assertIs(self.config, cfg),
                            [dsl.AddCompileFlag('-std=c++03')])[1])
     for a in feature.getActions(self.config):
         a.applyTo(self.config)
     self.assertIn('-std=c++03', self.getSubstitution('%{compile_flags}'))
Пример #5
0
 def test_adding_action(self):
     feature = dsl.Feature(name='name', actions=[dsl.AddCompileFlag('-std=c++03')])
     origLinkFlags = copy.deepcopy(self.getSubstitution('%{link_flags}'))
     for a in feature.getActions(self.config):
         a.applyTo(self.config)
     self.assertIn('name', self.config.available_features)
     self.assertIn('-std=c++03', self.getSubstitution('%{compile_flags}'))
     self.assertEqual(origLinkFlags, self.getSubstitution('%{link_flags}'))
Пример #6
0
 def test_adding_compile_flag(self):
     feature = dsl.Feature(name='name', compileFlag='-foo')
     origLinkFlags = copy.deepcopy(self.getSubstitution('%{link_flags}'))
     assert feature.isSupported(self.config)
     feature.enableIn(self.config)
     self.assertIn('name', self.config.available_features)
     self.assertIn('-foo', self.getSubstitution('%{compile_flags}'))
     self.assertEqual(origLinkFlags, self.getSubstitution('%{link_flags}'))
Пример #7
0
 def test_trivial(self):
     feature = dsl.Feature(name='name')
     origSubstitutions = copy.deepcopy(self.config.substitutions)
     actions = feature.getActions(self.config)
     self.assertTrue(len(actions) == 1)
     for a in actions:
         a.applyTo(self.config)
     self.assertEqual(origSubstitutions, self.config.substitutions)
     self.assertIn('name', self.config.available_features)
Пример #8
0
 def test_value_provided_in_config_and_on_command_line(self):
     """The value on the command line should override the one in the config"""
     self.config.std = 'c++11'
     self.litConfig.params['std'] = 'c++03'
     param = dsl.Parameter(name='std', choices=['c++03', 'c++11'], type=str, help='',
                           feature=lambda std: dsl.Feature(name=std))
     param.getFeature(self.config, self.litConfig.params).enableIn(self.config)
     self.assertIn('c++03', self.config.available_features)
     self.assertNotIn('c++11', self.config.available_features)
Пример #9
0
 def test_value_provided_on_command_line_and_no_default_value(self):
     self.litConfig.params['std'] = 'c++03'
     param = dsl.Parameter(name='std',
                           choices=['c++03'],
                           type=str,
                           help='',
                           feature=lambda std: dsl.Feature(name=std))
     param.getFeature(self.config,
                      self.litConfig.params).enableIn(self.config)
     self.assertIn('c++03', self.config.available_features)
Пример #10
0
    def test_adding_both_flags(self):
        feature = dsl.Feature(name='name', compileFlag='-hello', linkFlag='-world')
        assert feature.isSupported(self.config)
        feature.enableIn(self.config)
        self.assertIn('name', self.config.available_features)

        self.assertIn('-hello', self.getSubstitution('%{compile_flags}'))
        self.assertNotIn('-world', self.getSubstitution('%{compile_flags}'))

        self.assertIn('-world', self.getSubstitution('%{link_flags}'))
        self.assertNotIn('-hello', self.getSubstitution('%{link_flags}'))
Пример #11
0
 def test_boolean_value_from_false_boolean_parameter(self):
     self.litConfig.params['enable_exceptions'] = False
     param = dsl.Parameter(
         name='enable_exceptions',
         choices=[True, False],
         type=bool,
         help='',
         feature=lambda exceptions: None
         if exceptions else dsl.Feature(name="-fno-exceptions"))
     param.getFeature(self.config,
                      self.litConfig.params).enableIn(self.config)
     self.assertIn('-fno-exceptions', self.config.available_features)
Пример #12
0
 def test_name_is_not_a_string_2(self):
     feature = dsl.Feature(name=lambda cfg: None)
     self.assertRaises(ValueError, lambda: feature.getActions(self.config))
     self.assertRaises(ValueError, lambda: feature.pretty(self.config))
Пример #13
0
 def test_name_can_be_a_callable(self):
     feature = dsl.Feature(name=lambda cfg: 'name')
     for a in feature.getActions(self.config):
         a.applyTo(self.config)
     self.assertIn('name', self.config.available_features)
Пример #14
0
 def test_is_supported_gets_passed_the_config(self):
     feature = dsl.Feature(name='name',
                           when=lambda cfg:
                           (self.assertIs(self.config, cfg), True)[1])
     self.assertTrue(feature.isSupported(self.config))
Пример #15
0
 def test_unsupported_feature(self):
     feature = dsl.Feature(name='name', when=lambda _: False)
     self.assertFalse(feature.isSupported(self.config))
     # Also make sure we assert if we ever try to add it to a config
     self.assertRaises(AssertionError,
                       lambda: feature.enableIn(self.config))
Пример #16
0
 def test_getName_when_unsupported(self):
     feature = dsl.Feature(name='name', when=lambda _: False)
     assert not feature.isSupported(self.config)
     self.assertRaises(AssertionError, lambda: feature.getName(self.config))
Пример #17
0
 def test_unsupported_feature(self):
     feature = dsl.Feature(name='name', when=lambda _: False)
     self.assertEqual(feature.getActions(self.config), [])
Пример #18
0
 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))
Пример #19
0
 def test_name_can_be_a_callable(self):
     feature = dsl.Feature(
         name=lambda cfg: (self.assertIs(self.config, cfg), 'name')[1])
     assert feature.isSupported(self.config)
     feature.enableIn(self.config)
     self.assertIn('name', self.config.available_features)
Пример #20
0
 def test_is_supported_gets_passed_the_config(self):
     feature = dsl.Feature(name='name',
                           when=lambda cfg:
                           (self.assertIs(self.config, cfg), True)[1])
     self.assertEqual(len(feature.getActions(self.config)), 1)
Пример #21
0
 def test_name_can_be_a_callable(self):
     feature = dsl.Feature(name=lambda cfg: 'name')
     assert feature.isSupported(self.config)
     self.assertEqual('name', feature.getName(self.config))
     feature.enableIn(self.config)
     self.assertIn('name', self.config.available_features)