Beispiel #1
0
def build_file_aliases():
  return BuildFileAliases(
    targets={
      'python_binary': PythonBinary,
      'python_library': PythonLibrary,
      'python_requirement_library': PythonRequirementLibrary,
      'python_tests': PythonTests,
    },
    objects={
      'python_requirement': PythonRequirement,
      'python_artifact': PythonArtifact,
      'setup_py': PythonArtifact,
    },
    context_aware_object_factories={
      'python_requirements': BuildFileAliases.curry_context(python_requirements),
      'pants_requirement': BuildFileAliases.curry_context(pants_requirement),
    }
  )
  def test_merge(self):
    e_factory = lambda ctx: 'e'
    f_factory = lambda ctx: 'f'

    first = BuildFileAliases(targets={'a': Target},
                             objects={'d': 2},
                             context_aware_object_factories={'e': e_factory})

    second = BuildFileAliases(targets={'b': self.target_macro_factory},
                              objects={'c': 1, 'd': 42},
                              context_aware_object_factories={'f': f_factory})

    expected = BuildFileAliases(
        # nothing to merge
        targets={'a': Target, 'b': self.target_macro_factory},
        # second overrides first
        objects={'c': 1, 'd': 42},
        # combine
        context_aware_object_factories={'e': e_factory, 'f': f_factory})
    self.assertEqual(expected, first.merge(second))
Beispiel #3
0
  def test_curry_context(self):
    def curry_me(ctx, bob):
      """original doc"""
      return ctx, bob

    curried = BuildFileAliases.curry_context(curry_me)
    func = curried(42)

    self.assertEqual('original doc', curried.__doc__)
    self.assertTrue('curry_me' in curried.__name__,
                    'Unhelpful __name__: ' + curried.__name__)
    self.assertEqual((42, 'fred'), func('fred'))
Beispiel #4
0
def build_file_aliases():
    fixed_python_tests = BuildFileAliases.curry_context(python_tests)
    return BuildFileAliases(context_aware_object_factories={"python_tests": fixed_python_tests})
Beispiel #5
0
 def alias_groups(cls):
     return super(AntlrJavaGenTest, cls).alias_groups().merge(
         BuildFileAliases(targets={
             'java_antlr_library': JavaAntlrLibrary,
         }, ))
 def alias_groups(self):
   return BuildFileAliases(
     targets={
       'prep_command': PrepCommand,
     },
   )
Beispiel #7
0
 def alias_groups(self):
     return BuildFileAliases(objects={'fake_object': object()})
Beispiel #8
0
def build_file_aliases():
    return BuildFileAliases(targets={
        'python_thrift_library': PythonThriftLibrary,
    })
Beispiel #9
0
def build_file_aliases():
    return BuildFileAliases(targets={
        'java_antlr_library': JavaAntlrLibrary,
    })
 def reg_alias():
     return BuildFileAliases(targets={"override-alias": DummyTarget2})
Beispiel #11
0
def build_file_aliases():
    return BuildFileAliases(targets={"python_antlr_library": PythonAntlrLibrary})
Beispiel #12
0
 def alias_groups(cls) -> BuildFileAliases:
     return BuildFileAliases(objects={
         "python_requirement": PythonRequirement,
         "setup_py": PythonArtifact,
     })
Beispiel #13
0
def build_file_aliases():
  return BuildFileAliases(
    targets={
      'java_thrift_library': JavaThriftLibrary,
      }
    )
 def alias_groups(cls):
     return BuildFileAliases(objects={"python_requirement": PythonRequirement})
Beispiel #15
0
 def alias_groups(cls) -> BuildFileAliases:
     return BuildFileAliases(targets={"python_library": PythonLibraryV1})
Beispiel #16
0
def build_file_aliases():
  return BuildFileAliases(
    targets={
      'absolute_resources': AbsoluteResources,
    },
  )
Beispiel #17
0
 def test_bad_context_aware_object_factories(self):
     with self.assertRaises(TypeError):
         BuildFileAliases(context_aware_object_factories={'george': 1})
Beispiel #18
0
 def alias_groups(self):
     return super(JUnitRunnerTest, self).alias_groups.merge(
         BuildFileAliases(targets={
             'java_tests': JavaTests,
             'python_tests': PythonTests,
         }, ))
Beispiel #19
0
 def test_target_types(self):
     aliases = BuildFileAliases(targets={
         'jake': Target,
         'jill': self.target_macro_factory
     })
     self.assertEqual({'jake': Target}, aliases.target_types)
Beispiel #20
0
 def alias_groups(self):
     """
 :API: public
 """
     return BuildFileAliases(targets={'target': Target})
Beispiel #21
0
    def test_create(self):
        self.assertEqual(
            BuildFileAliases(targets={},
                             objects={},
                             context_aware_object_factories={}),
            BuildFileAliases())

        targets = {'jake': Target, 'jill': self.target_macro_factory}
        self.assertEqual(
            BuildFileAliases(targets=targets,
                             objects={},
                             context_aware_object_factories={}),
            BuildFileAliases(targets=targets))

        objects = {'jane': 42}
        self.assertEqual(
            BuildFileAliases(targets={},
                             objects=objects,
                             context_aware_object_factories={}),
            BuildFileAliases(objects=objects))

        factories = {'jim': lambda ctx: 'bob'}
        self.assertEqual(
            BuildFileAliases(targets={},
                             objects={},
                             context_aware_object_factories=factories),
            BuildFileAliases(context_aware_object_factories=factories))

        self.assertEqual(
            BuildFileAliases(targets=targets,
                             objects=objects,
                             context_aware_object_factories={}),
            BuildFileAliases(targets=targets, objects=objects))

        self.assertEqual(
            BuildFileAliases(targets=targets,
                             objects={},
                             context_aware_object_factories=factories),
            BuildFileAliases(targets=targets,
                             context_aware_object_factories=factories))

        self.assertEqual(
            BuildFileAliases(targets={},
                             objects=objects,
                             context_aware_object_factories=factories),
            BuildFileAliases(objects=objects,
                             context_aware_object_factories=factories))

        self.assertEqual(
            BuildFileAliases(targets=targets,
                             objects=objects,
                             context_aware_object_factories=factories),
            BuildFileAliases(targets=targets,
                             objects=objects,
                             context_aware_object_factories=factories))
Beispiel #22
0
 def alias_groups(cls):
     return BuildFileAliases(targets={"go_library": GoLibrary})
Beispiel #23
0
    def test_create_bad_objects(self):
        with self.assertRaises(TypeError):
            BuildFileAliases(objects={'jane': Target})

        with self.assertRaises(TypeError):
            BuildFileAliases(objects={'jane': self.target_macro_factory})
Beispiel #24
0
 def alias_groups(cls):
     return BuildFileAliases(targets={
         'java_library': JavaLibrary,
     }, )
Beispiel #25
0
 def alias_groups(cls):
     """
 :API: public
 """
     return BuildFileAliases(targets={'files': Files})
Beispiel #26
0
 def alias_groups(self):
     return BuildFileAliases(targets={'fake': ErrorTarget})
Beispiel #27
0
 def alias_groups(cls):
   return super(ScalaFmtTestBase, cls).alias_groups().merge(
     BuildFileAliases(targets={'java_tests': JUnitTests,
                               'junit_tests': JUnitTests,
                               'scala_library': ScalaLibrary}))
Beispiel #28
0
def build_file_aliases():
  return BuildFileAliases(
    objects={
      'sjar': JarDependencyWithGlobalExcludes,
    },
  )
Beispiel #29
0
def build_file_aliases():
    return BuildFileAliases(targets={
        'cpp_library': CppLibrary,
        'cpp_binary': CppBinary,
    })
Beispiel #30
0
def build_file_aliases():
    return BuildFileAliases(targets={
        'yoyo': YoyoTarget,
    }, )
Beispiel #31
0
 def alias_groups(self):
     return BuildFileAliases(targets={'python_library': PythonLibrary})
Beispiel #32
0
def build_file_aliases():
  return BuildFileAliases(
    context_aware_object_factories={
      'maven_layout': BuildFileAliases.curry_context(maven_layout)
    }
  )
 def build_file_aliases(bad_arg):
     return BuildFileAliases()
Beispiel #34
0
 def alias_groups(cls):
     return (super().alias_groups().merge(
         BuildFileAliases(targets={
             "junit_tests": JUnitTests,
             "scala_library": ScalaLibrary
         })))
Beispiel #35
0
 def alias_groups(cls):
     return BuildFileAliases(targets={"java_library": JavaLibrary, "junit_tests": JUnitTests})