Esempio n. 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),
    }
  )
Esempio n. 2
0
  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))
Esempio n. 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'))
Esempio n. 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})
Esempio n. 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,
     },
   )
Esempio n. 7
0
 def alias_groups(self):
     return BuildFileAliases(objects={'fake_object': object()})
Esempio n. 8
0
def build_file_aliases():
    return BuildFileAliases(targets={
        'python_thrift_library': PythonThriftLibrary,
    })
Esempio n. 9
0
def build_file_aliases():
    return BuildFileAliases(targets={
        'java_antlr_library': JavaAntlrLibrary,
    })
Esempio n. 10
0
 def reg_alias():
     return BuildFileAliases(targets={"override-alias": DummyTarget2})
Esempio n. 11
0
def build_file_aliases():
    return BuildFileAliases(targets={"python_antlr_library": PythonAntlrLibrary})
Esempio n. 12
0
 def alias_groups(cls) -> BuildFileAliases:
     return BuildFileAliases(objects={
         "python_requirement": PythonRequirement,
         "setup_py": PythonArtifact,
     })
Esempio n. 13
0
def build_file_aliases():
  return BuildFileAliases(
    targets={
      'java_thrift_library': JavaThriftLibrary,
      }
    )
 def alias_groups(cls):
     return BuildFileAliases(objects={"python_requirement": PythonRequirement})
Esempio n. 15
0
 def alias_groups(cls) -> BuildFileAliases:
     return BuildFileAliases(targets={"python_library": PythonLibraryV1})
Esempio n. 16
0
def build_file_aliases():
  return BuildFileAliases(
    targets={
      'absolute_resources': AbsoluteResources,
    },
  )
Esempio n. 17
0
 def test_bad_context_aware_object_factories(self):
     with self.assertRaises(TypeError):
         BuildFileAliases(context_aware_object_factories={'george': 1})
Esempio n. 18
0
 def alias_groups(self):
     return super(JUnitRunnerTest, self).alias_groups.merge(
         BuildFileAliases(targets={
             'java_tests': JavaTests,
             'python_tests': PythonTests,
         }, ))
Esempio n. 19
0
 def test_target_types(self):
     aliases = BuildFileAliases(targets={
         'jake': Target,
         'jill': self.target_macro_factory
     })
     self.assertEqual({'jake': Target}, aliases.target_types)
Esempio n. 20
0
 def alias_groups(self):
     """
 :API: public
 """
     return BuildFileAliases(targets={'target': Target})
Esempio n. 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))
Esempio n. 22
0
 def alias_groups(cls):
     return BuildFileAliases(targets={"go_library": GoLibrary})
Esempio n. 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})
Esempio n. 24
0
 def alias_groups(cls):
     return BuildFileAliases(targets={
         'java_library': JavaLibrary,
     }, )
Esempio n. 25
0
 def alias_groups(cls):
     """
 :API: public
 """
     return BuildFileAliases(targets={'files': Files})
Esempio n. 26
0
 def alias_groups(self):
     return BuildFileAliases(targets={'fake': ErrorTarget})
Esempio n. 27
0
 def alias_groups(cls):
   return super(ScalaFmtTestBase, cls).alias_groups().merge(
     BuildFileAliases(targets={'java_tests': JUnitTests,
                               'junit_tests': JUnitTests,
                               'scala_library': ScalaLibrary}))
Esempio n. 28
0
def build_file_aliases():
  return BuildFileAliases(
    objects={
      'sjar': JarDependencyWithGlobalExcludes,
    },
  )
Esempio n. 29
0
def build_file_aliases():
    return BuildFileAliases(targets={
        'cpp_library': CppLibrary,
        'cpp_binary': CppBinary,
    })
Esempio n. 30
0
def build_file_aliases():
    return BuildFileAliases(targets={
        'yoyo': YoyoTarget,
    }, )
Esempio n. 31
0
 def alias_groups(self):
     return BuildFileAliases(targets={'python_library': PythonLibrary})
Esempio n. 32
0
def build_file_aliases():
  return BuildFileAliases(
    context_aware_object_factories={
      'maven_layout': BuildFileAliases.curry_context(maven_layout)
    }
  )
Esempio n. 33
0
 def build_file_aliases(bad_arg):
     return BuildFileAliases()
Esempio n. 34
0
 def alias_groups(cls):
     return (super().alias_groups().merge(
         BuildFileAliases(targets={
             "junit_tests": JUnitTests,
             "scala_library": ScalaLibrary
         })))
Esempio n. 35
0
 def alias_groups(cls):
     return BuildFileAliases(targets={"java_library": JavaLibrary, "junit_tests": JUnitTests})