Beispiel #1
0
 def test_rules(self):
   def rules():
     return [example_rule, RootRule(RootType)]
   with self.create_register(rules=rules) as backend_package:
     load_backend(self.build_configuration, backend_package)
     self.assertEqual(self.build_configuration.rules(),
                      [example_rule, RootRule(RootType)])
    def test_target_types(self):
        def target_types():
            return [DummyTarget, DummyTarget2]

        with self.create_register(
                target_types=target_types) as backend_package:
            load_backend(self.bc_builder, backend_package)
            assert self.bc_builder.create().target_types == (DummyTarget,
                                                             DummyTarget2)

        class PluginTarget(Target):
            alias = "plugin_tgt"
            core_fields = ()

        def plugin_targets():
            return [PluginTarget]

        self.working_set.add(
            self.get_mock_plugin("new-targets",
                                 "0.0.1",
                                 target_types=plugin_targets))
        self.load_plugins(["new-targets"])
        assert self.bc_builder.create().target_types == (DummyTarget,
                                                         DummyTarget2,
                                                         PluginTarget)
Beispiel #3
0
    def test_target_types(self):
        def target_types():
            return [DummyTarget, DummyTarget2]

        with self.create_register(
                target_types=target_types) as backend_package:
            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=True)
            assert self.build_configuration.target_types() == OrderedSet(
                [DummyTarget, DummyTarget2])

            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=False)
            assert self.build_configuration.target_types() == OrderedSet(
                [DummyTarget, DummyTarget2])

        class PluginTarget(Target):
            alias = "plugin_tgt"
            core_fields = ()

        def plugin_targets():
            return [PluginTarget]

        self.working_set.add(
            self.get_mock_plugin("new-targets",
                                 "0.0.1",
                                 target_types=plugin_targets))
        self.load_plugins(["new-targets"], is_v1_plugin=True)
        assert self.build_configuration.target_types() == OrderedSet(
            [DummyTarget, DummyTarget2, PluginTarget])
        self.load_plugins(["new-targets"], is_v1_plugin=False)
        assert self.build_configuration.target_types() == OrderedSet(
            [DummyTarget, DummyTarget2, PluginTarget])
 def test_subsystems(self):
   def global_subsystems():
     return {DummySubsystem1, DummySubsystem2}
   with self.create_register(global_subsystems=global_subsystems) as backend_package:
     load_backend(self.build_configuration, backend_package)
     self.assertEqual(self.build_configuration.subsystems(),
                      {DummySubsystem1, DummySubsystem2})
 def test_rules(self):
   def rules():
     return [example_rule, RootRule(RootType)]
   with self.create_register(rules=rules) as backend_package:
     load_backend(self.build_configuration, backend_package)
     self.assertEqual(self.build_configuration.rules(),
                      [example_rule, RootRule(RootType)])
  def test_load_invalid_entrypoint(self):
    def build_file_aliases(bad_arg):
      return BuildFileAliases()

    with self.create_register(build_file_aliases=build_file_aliases) as backend_package:
      with self.assertRaises(BuildConfigurationError):
        load_backend(self.build_configuration, backend_package)
Beispiel #7
0
  def test_load_invalid_entrypoint(self):
    def build_file_aliases(bad_arg):
      return BuildFileAliases()

    with self.create_register(build_file_aliases=build_file_aliases) as backend_package:
      with self.assertRaises(BuildConfigurationError):
        load_backend(self.build_configuration, backend_package)
    def test_rules(self):
        def backend_rules():
            return [example_rule, RootRule(RootType)]

        with self.create_register(rules=backend_rules) as backend_package:
            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=True)
            self.assertEqual(self.build_configuration.rules(), [])

            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=False)
            self.assertEqual(
                self.build_configuration.rules(),
                [example_rule.rule, RootRule(RootType)])

        def plugin_rules():
            return [example_plugin_rule]

        self.working_set.add(
            self.get_mock_plugin("this-plugin-rules",
                                 "0.0.1",
                                 rules=plugin_rules))
        self.load_plugins(["this-plugin-rules"], is_v1_plugin=True)
        self.assertEqual(
            self.build_configuration.rules(),
            [example_rule.rule, RootRule(RootType)])

        self.load_plugins(["this-plugin-rules"], is_v1_plugin=False)
        self.assertEqual(
            self.build_configuration.rules(),
            [example_rule.rule,
             RootRule(RootType), example_plugin_rule.rule],
        )
Beispiel #9
0
 def test_subsystems(self):
   def global_subsystems():
     return {DummySubsystem1, DummySubsystem2}
   with self.create_register(global_subsystems=global_subsystems) as backend_package:
     load_backend(self.build_configuration, backend_package)
     self.assertEqual(self.build_configuration.subsystems(),
                      {DummySubsystem1, DummySubsystem2})
    def test_load_valid_partial_goals(self):
        def register_goals():
            Goal.by_name("jack").install(TaskRegistrar("jill", DummyTask))

        with self.create_register(
                register_goals=register_goals) as backend_package:
            Goal.clear()
            self.assertEqual(0, len(Goal.all()))

            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=False)
            self.assertEqual(0, len(Goal.all()))

            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=True)
            self.assert_empty_aliases()
            self.assertEqual(1, len(Goal.all()))

            task_names = Goal.by_name("jack").ordered_task_names()
            self.assertEqual(1, len(task_names))

            task_name = task_names[0]
            self.assertEqual("jill", task_name)
    def test_load_valid_partial_aliases(self):
        aliases = BuildFileAliases(targets={"bob": DummyTarget},
                                   objects={
                                       "obj1": DummyObject1,
                                       "obj2": DummyObject2
                                   })
        with self.create_register(
                build_file_aliases=lambda: aliases) as backend_package:
            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=False)
            self.assert_empty_aliases()

            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=True)
            registered_aliases = self.build_configuration.registered_aliases()
            self.assertEqual(DummyTarget,
                             registered_aliases.target_types["bob"])
            self.assertEqual(DummyObject1, registered_aliases.objects["obj1"])
            self.assertEqual(DummyObject2, registered_aliases.objects["obj2"])
            self.assertEqual(
                self.build_configuration.optionables(),
                OrderedSet([DummySubsystem1, DummySubsystem2]),
            )
Beispiel #12
0
  def test_load_invalid_entrypoint(self):
    def build_file_aliases(bad_arg):
      return BuildFileAliases()

    with self.create_register(build_file_aliases=build_file_aliases) as backend_package:
      # Loading as v2 shouldn't raise.
      load_backend(self.build_configuration, backend_package, is_v1_backend=False)
      with self.assertRaises(BuildConfigurationError):
        load_backend(self.build_configuration, backend_package, is_v1_backend=True)
Beispiel #13
0
 def test_load_invalid_module(self):
     with self.create_register(module_name="register2") as backend_package:
         with self.assertRaises(BuildConfigurationError):
             load_backend(self.bc_builder,
                          backend_package,
                          is_v1_backend=False)
         with self.assertRaises(BuildConfigurationError):
             load_backend(self.bc_builder,
                          backend_package,
                          is_v1_backend=True)
Beispiel #14
0
  def test_subsystems(self):
    def global_subsystems():
      return {DummySubsystem1, DummySubsystem2}
    with self.create_register(global_subsystems=global_subsystems) as backend_package:
      load_backend(self.build_configuration, backend_package, is_v1_backend=False)
      self.assertEqual(self.build_configuration.optionables(), set())

      load_backend(self.build_configuration, backend_package, is_v1_backend=True)
      self.assertEqual(self.build_configuration.optionables(),
                       {DummySubsystem1, DummySubsystem2})
Beispiel #15
0
 def test_load_valid_partial_aliases(self):
     aliases = BuildFileAliases(objects={"obj1": DummyObject1, "obj2": DummyObject2})
     with self.create_register(build_file_aliases=lambda: aliases) as backend_package:
         load_backend(self.bc_builder, backend_package)
         build_configuration = self.bc_builder.create()
         registered_aliases = build_configuration.registered_aliases
         self.assertEqual(DummyObject1, registered_aliases.objects["obj1"])
         self.assertEqual(DummyObject2, registered_aliases.objects["obj2"])
         self.assertEqual(
             build_configuration.optionables, FrozenOrderedSet([DummySubsystem]),
         )
 def test_load_valid_partial_aliases(self):
   aliases = BuildFileAliases(targets={'bob': DummyTarget},
                              objects={'obj1': DummyObject1,
                                       'obj2': DummyObject2})
   with self.create_register(build_file_aliases=lambda: aliases) as backend_package:
     load_backend(self.build_configuration, backend_package)
     registered_aliases = self.build_configuration.registered_aliases()
     self.assertEqual(DummyTarget, registered_aliases.target_types['bob'])
     self.assertEqual(DummyObject1, registered_aliases.objects['obj1'])
     self.assertEqual(DummyObject2, registered_aliases.objects['obj2'])
     self.assertEqual(self.build_configuration.subsystems(), {DummySubsystem1, DummySubsystem2})
Beispiel #17
0
 def test_load_valid_partial_aliases(self):
   aliases = BuildFileAliases(targets={'bob': DummyTarget},
                              objects={'obj1': DummyObject1,
                                       'obj2': DummyObject2})
   with self.create_register(build_file_aliases=lambda: aliases) as backend_package:
     load_backend(self.build_configuration, backend_package)
     registered_aliases = self.build_configuration.registered_aliases()
     self.assertEqual(DummyTarget, registered_aliases.target_types['bob'])
     self.assertEqual(DummyObject1, registered_aliases.objects['obj1'])
     self.assertEqual(DummyObject2, registered_aliases.objects['obj2'])
     self.assertEqual(self.build_configuration.subsystems(), {DummySubsystem1, DummySubsystem2})
Beispiel #18
0
    def test_subsystems(self):
        def global_subsystems():
            return [DummySubsystem1, DummySubsystem2]

        with self.create_register(
                global_subsystems=global_subsystems) as backend_package:
            load_backend(self.bc_builder, backend_package, is_v1_backend=False)
            self.assertEqual(self.bc_builder.create().optionables(),
                             FrozenOrderedSet())

            load_backend(self.bc_builder, backend_package, is_v1_backend=True)
            self.assertEqual(
                self.bc_builder.create().optionables(),
                FrozenOrderedSet([DummySubsystem1, DummySubsystem2]),
            )
  def test_rules(self):
    def backend_rules():
      return [example_rule, RootRule(RootType)]
    with self.create_register(rules=backend_rules) as backend_package:
      load_backend(self.build_configuration, backend_package)
      self.assertEqual(self.build_configuration.rules(),
                       [example_rule.rule, RootRule(RootType)])

    def plugin_rules():
      return [example_plugin_rule]

    self.working_set.add(self.get_mock_plugin('this-plugin-rules', '0.0.1', rules=plugin_rules))
    self.load_plugins(['this-plugin-rules'])
    self.assertEqual(self.build_configuration.rules(),
                     [example_rule.rule, RootRule(RootType), example_plugin_rule.rule])
  def test_load_valid_partial_goals(self):
    def register_goals():
      Goal.by_name('jack').install(TaskRegistrar('jill', DummyTask))

    with self.create_register(register_goals=register_goals) as backend_package:
      Goal.clear()
      self.assertEqual(0, len(Goal.all()))

      load_backend(self.build_configuration, backend_package)
      self.assert_empty_aliases()
      self.assertEqual(1, len(Goal.all()))

      task_names = Goal.by_name('jack').ordered_task_names()
      self.assertEqual(1, len(task_names))

      task_name = task_names[0]
      self.assertEqual('jill', task_name)
Beispiel #21
0
    def test_rules(self):
        def backend_rules():
            return [example_rule, RootRule(RootType)]

        with self.create_register(rules=backend_rules) as backend_package:
            load_backend(self.bc_builder, backend_package)
            self.assertEqual(
                self.bc_builder.create().rules,
                FrozenOrderedSet([example_rule.rule, RootRule(RootType)]),
            )

        def plugin_rules():
            return [example_plugin_rule]

        self.working_set.add(self.get_mock_plugin("this-plugin-rules", "0.0.1", rules=plugin_rules))
        self.load_plugins(["this-plugin-rules"])
        self.assertEqual(
            self.bc_builder.create().rules,
            FrozenOrderedSet([example_rule.rule, RootRule(RootType), example_plugin_rule.rule]),
        )
    def test_rules(self):
        def backend_rules():
            return [example_rule, RootRule(RootType)]

        with self.create_register(rules=backend_rules) as backend_package:
            load_backend(self.build_configuration, backend_package)
            self.assertEqual(
                self.build_configuration.rules(),
                [example_rule.rule, RootRule(RootType)])

        def plugin_rules():
            return [example_plugin_rule]

        self.working_set.add(
            self.get_mock_plugin('this-plugin-rules',
                                 '0.0.1',
                                 rules=plugin_rules))
        self.load_plugins(['this-plugin-rules'])
        self.assertEqual(
            self.build_configuration.rules(),
            [example_rule.rule,
             RootRule(RootType), example_plugin_rule.rule])
Beispiel #23
0
 def test_load_invalid_module(self):
     with self.create_register(module_name='register2') as backend_package:
         with self.assertRaises(BuildConfigurationError):
             load_backend(self.build_configuration, backend_package)
Beispiel #24
0
 def test_load_valid_empty(self):
     with self.create_register() as backend_package:
         load_backend(self.build_configuration, backend_package)
         self.assert_empty_aliases()
 def test_load_valid_empty(self):
   with self.create_register() as backend_package:
     load_backend(self.build_configuration, backend_package)
     self.assert_empty_aliases()
 def test_load_invalid_module(self):
   with self.create_register(module_name='register2') as backend_package:
     with self.assertRaises(BuildConfigurationError):
       load_backend(self.build_configuration, backend_package)
 def test_load_valid_empty(self):
     with self.create_register() as backend_package:
         load_backend(self.bc_builder, backend_package)
         self.assert_empty()