def setUp(self):
        init_subsystems(
            [LibcDev],
            options={"libc": {"enable_libc_search": False, "libc_dir": "/does/not/exist",},},
        )

        self.libc = global_subsystem_instance(LibcDev)
        self.platform = Platform.current
Beispiel #2
0
    def setUp(self):
        super().setUp()
        init_subsystems([SourceRootConfig, JUnit])
        self.add_to_build_file(
            "projectB/src/test/scala",
            'junit_tests(name="test", sources=["a/source"])')

        self.add_to_build_file("projectA/subproject/src/main/java",
                               'java_library(name="test", sources=[])')
  def setUp(self):
    init_subsystems([LibcDev], options={
      'libc': {
        'enable_libc_search': True,
        'host_compiler': 'this_executable_does_not_exist',
      },
    })

    self.libc = global_subsystem_instance(LibcDev)
    self.platform = Platform.current
  def setUp(self):
    init_subsystems([LibcDev], options={
      'libc': {
        'enable_libc_search': False,
        'libc_dir': '/does/not/exist',
      },
    })

    self.libc = global_subsystem_instance(LibcDev)
    self.platform = Platform.current
Beispiel #5
0
    def setUp(self):
        super().setUp()

        init_subsystems([LibcDev, NativeToolchain], options={"libc": {"enable_libc_search": True}})

        self.platform = Platform.current
        self.toolchain = global_subsystem_instance(NativeToolchain)

        gcc_subsystem = global_subsystem_instance(GCC)
        self.gcc_version = gcc_subsystem.version()
        llvm_subsystem = global_subsystem_instance(LLVM)
        self.llvm_version = llvm_subsystem.version()
    def setUp(self):
        init_subsystems(
            [LibcDev],
            options={
                "libc": {
                    "enable_libc_search": True,
                    "host_compiler": "this_executable_does_not_exist",
                },
            },
        )

        self.libc = global_subsystem_instance(LibcDev)
        self.platform = Platform.current
Beispiel #7
0
    def setUp(self):
        super().setUp()
        init_subsystems(
            [SourceRootConfig, JUnit],
            {"source": {
                "root_patterns": ["src/main/*", "src/test/*"]
            }})
        self.create_file("projectB/src/test/scala/a/source")
        self.add_to_build_file(
            "projectB/src/test/scala",
            'junit_tests(name="test", sources=["a/source"])')

        self.add_to_build_file("projectA/subproject/src/main/java",
                               'java_library(name="test", sources=[])')
Beispiel #8
0
    def setUp(self):
        super().setUp()

        init_subsystems([LibcDev, NativeToolchain],
                        options={
                            'libc': {
                                'enable_libc_search': True,
                            },
                        })

        self.platform = Platform.current
        self.toolchain = global_subsystem_instance(NativeToolchain)
        self.rules = native_backend_rules() + create_platform_rules()

        gcc_subsystem = global_subsystem_instance(GCC)
        self.gcc_version = gcc_subsystem.version()
        llvm_subsystem = global_subsystem_instance(LLVM)
        self.llvm_version = llvm_subsystem.version()
Beispiel #9
0
 def create_and_return_classpath_products(self, targets, required_products):
     """Executes our mocked out JvmCompile class, with certain required products
     args:
       required_products: list of str. The products to declare a dependency on.f
     rtype: tuple(ClasspathProducts)
     """
     init_subsystems([JvmPlatform])
     context = self.context(
         target_roots=[targets["a"], targets["c"]],
         options={"jvm-platform": {"compiler": "dummy"}},
     )
     context.products.get_data(
         "compile_classpath", ClasspathProducts.init_func(self.pants_workdir)
     )
     # This should cause the jvm compile execution to exclude target roots and their
     # dependees from the set of relevant targets.
     for rp in required_products:
         context.products.require_data(rp)
     self.execute(context)
     return context.products.get_data("runtime_classpath")
Beispiel #10
0
 def create_and_return_classpath_products(self, targets, required_products):
     """Executes our mocked out JvmCompile class, with certain required products
 args:
   required_products: list of str. The products to declare a dependency on.f
 rtype: tuple(ClasspathProducts)
 """
     init_subsystems([JvmPlatform])
     context = self.context(target_roots=[targets['a'], targets['c']],
                            options={'jvm-platform': {
                                'compiler': 'dummy'
                            }})
     context.products.get_data(
         'compile_classpath',
         ClasspathProducts.init_func(self.pants_workdir))
     # This should cause the jvm compile execution to exclude target roots and their
     # dependess from the set of relevant targets.
     for rp in required_products:
         context.products.require_data(rp)
     self.execute(context)
     return (context.products.get_data('runtime_classpath'),
             context.products.get_data('export_dep_as_jar_classpath'))
 def setUp(self):
     super().setUp()
     init_subsystems([
         SourceRootConfig, PythonSetup, PythonNativeCode,
         SubprocessEnvironment, Lambdex
     ])
Beispiel #12
0
    def setUp(self):
        super().setUp()
        # We need an initialized ScalaPlatform in order to make ScalaLibrary targets below.
        scala_options = {ScalaPlatform.options_scope: {"version": "custom"}}
        init_subsystems([JUnit, ScalaPlatform, ScoveragePlatform], scala_options)

        self.make_target(
            ":jar-tool", JarLibrary, jars=[JarDependency("org.pantsbuild", "jar-tool", "0.0.10")]
        )

        # NB: `test_has_python_requirements` will attempt to inject every possible scala compiler target
        # spec, for versions 2.10, 2.11, 2.12, and custom, and will error out if they are not
        # available. This isn't a problem when running pants on the command line, but in unit testing
        # there's probably some task or subsystem that needs to be initialized to avoid this.
        for empty_target in [
            "scalac",
            "scala-repl",
            "scala-library",
            "scala-reflect",
            "scalastyle",
        ]:
            for unused_scala_version in ["2_10", "2_11"]:
                self.make_target(
                    f":{empty_target}_{unused_scala_version}", Target,
                )
        self.make_target(
            ":scalac-plugin-dep", Target,
        )

        self.make_target(
            ":jarjar",
            JarLibrary,
            jars=[JarDependency(org="org.pantsbuild", name="jarjar", rev="1.7.2")],
        )

        self.make_target(
            ":scala-library",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-library", self._scala_toolchain_version)],
        )

        self.make_target(
            ":scalac",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-compiler", self._scala_toolchain_version)],
        )

        self.make_target(
            ":scalac_2_12",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-compiler", "2.12.8")],
        )
        self.make_target(
            ":scala-library_2_12",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-library", "2.12.8")],
        )
        self.make_target(
            ":scala-reflect_2_12",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-reflect", "2.12.8")],
        )
        self.make_target(
            ":scala-repl_2_12",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-repl", "2.12.8")],
        )
        self.make_target(
            ":scalastyle_2_12", Target,
        )
        self.make_target(
            ":scalastyle", Target,
        )

        self.make_target(
            ":scala-reflect",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-reflect", self._scala_toolchain_version)],
        )

        self.make_target(
            ":scala-repl",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-repl", self._scala_toolchain_version)],
        )

        self.make_target(
            ":nailgun-server",
            JarLibrary,
            jars=[JarDependency(org="com.martiansoftware", name="nailgun-server", rev="0.9.1")],
        )
Beispiel #13
0
 def setUp(self):
     super().setUp()
     init_subsystems([PythonSetup, PythonNativeCode, SubprocessEnvironment])
Beispiel #14
0
    def setUp(self):
        super().setUp()

        # We need an initialized ScalaPlatform in order to make ScalaLibrary targets below.
        scala_options = {ScalaPlatform.options_scope: {'version': 'custom'}}
        init_subsystems([JUnit, ScalaPlatform, ScoveragePlatform],
                        scala_options)

        self.make_target(
            ':jar-tool',
            JarLibrary,
            jars=[JarDependency('org.pantsbuild', 'jar-tool', '0.0.10')])

        # NB: `test_has_python_requirements` will attempt to inject every possible scala compiler target
        # spec, for versions 2.10, 2.11, 2.12, and custom, and will error out if they are not
        # available. This isn't a problem when running pants on the command line, but in unit testing
        # there's probably some task or subsystem that needs to be initialized to avoid this.
        for empty_target in [
                'scalac', 'scala-repl', 'scala-library', 'scala-reflect',
                'scalastyle'
        ]:
            for unused_scala_version in ['2_10', '2_11']:
                self.make_target(
                    f':{empty_target}_{unused_scala_version}',
                    Target,
                )
        self.make_target(
            ':scalac-plugin-dep',
            Target,
        )

        self.make_target(':jarjar',
                         JarLibrary,
                         jars=[
                             JarDependency(org='org.pantsbuild',
                                           name='jarjar',
                                           rev='1.7.2')
                         ])

        self.make_target(':scala-library',
                         JarLibrary,
                         jars=[
                             JarDependency('org.scala-lang', 'scala-library',
                                           self._scala_toolchain_version)
                         ])

        self.make_target(':scalac',
                         JarLibrary,
                         jars=[
                             JarDependency('org.scala-lang', 'scala-compiler',
                                           self._scala_toolchain_version)
                         ])

        self.make_target(
            ':scalac_2_12',
            JarLibrary,
            jars=[JarDependency('org.scala-lang', 'scala-compiler', '2.12.8')])
        self.make_target(
            ':scala-library_2_12',
            JarLibrary,
            jars=[JarDependency('org.scala-lang', 'scala-library', '2.12.8')])
        self.make_target(
            ':scala-reflect_2_12',
            JarLibrary,
            jars=[JarDependency('org.scala-lang', 'scala-reflect', '2.12.8')])
        self.make_target(
            ':scala-repl_2_12',
            JarLibrary,
            jars=[JarDependency('org.scala-lang', 'scala-repl', '2.12.8')])
        self.make_target(
            ':scalastyle_2_12',
            Target,
        )
        self.make_target(
            ':scalastyle',
            Target,
        )

        self.make_target(':scala-reflect',
                         JarLibrary,
                         jars=[
                             JarDependency('org.scala-lang', 'scala-reflect',
                                           self._scala_toolchain_version)
                         ])

        self.make_target(':scala-repl',
                         JarLibrary,
                         jars=[
                             JarDependency('org.scala-lang', 'scala-repl',
                                           self._scala_toolchain_version)
                         ])

        self.make_target(':nailgun-server',
                         JarLibrary,
                         jars=[
                             JarDependency(org='com.martiansoftware',
                                           name='nailgun-server',
                                           rev='0.9.1'),
                         ])

        self.make_target(
            'project_info:first',
            target_type=Target,
        )

        jar_lib = self.make_target(
            'project_info:jar_lib',
            target_type=JarLibrary,
            jars=[JarDependency('org.apache', 'apache-jar', '12.12.2012')],
        )

        self.make_target(
            'java/project_info:java_lib',
            target_type=JavaLibrary,
            sources=['com/foo/Bar.java', 'com/foo/Baz.java'],
        )

        self.make_target(
            'project_info:third',
            target_type=ScalaLibrary,
            dependencies=[jar_lib],
            java_sources=['java/project_info:java_lib'],
            sources=['com/foo/Bar.scala', 'com/foo/Baz.scala'],
        )

        self.make_target(
            'project_info:globular',
            target_type=ScalaLibrary,
            dependencies=[jar_lib],
            java_sources=['java/project_info:java_lib'],
            sources=['com/foo/*.scala'],
        )

        self.make_target(
            'project_info:jvm_app',
            target_type=JvmApp,
            dependencies=[jar_lib],
        )

        self.jvm_target_with_sources = self.make_target(
            'project_info:jvm_target',
            target_type=ScalaLibrary,
            dependencies=[jar_lib],
            sources=[
                'this/is/a/source/Foo.scala', 'this/is/a/source/Bar.scala'
            ],
        )

        test_resource = self.make_target(
            'project_info:test_resource',
            target_type=Resources,
            sources=['y_resource', 'z_resource'],
        )

        self.make_target(
            'project_info:java_test',
            target_type=JUnitTests,
            dependencies=[jar_lib, test_resource],
            sources=['this/is/a/test/source/FooTest.scala'],
        )

        jvm_binary = self.make_target(
            'project_info:jvm_binary',
            target_type=JvmBinary,
            dependencies=[jar_lib],
        )

        self.make_target(
            'project_info:top_dependency',
            target_type=Target,
            dependencies=[jvm_binary],
        )

        self.create_file('project_info/a_resource', contents='a')
        self.create_file('project_info/b_resource', contents='b')

        src_resource = self.make_target(
            'project_info:resource',
            target_type=Resources,
            sources=['a_resource', 'b_resource'],
        )

        self.make_target(
            'project_info:target_type',
            target_type=ScalaLibrary,
            dependencies=[jvm_binary, src_resource],
            sources=[],
        )

        self.make_target(
            'project_info:unrecognized_target_type',
            target_type=JvmTarget,
        )

        self.scala_with_source_dep = self.make_target(
            'project_info:scala_with_source_dep',
            target_type=ScalaLibrary,
            dependencies=[self.jvm_target_with_sources],
            sources=[])
Beispiel #15
0
    def setUp(self):
        super().setUp()

        # We need an initialized ScalaPlatform in order to make ScalaLibrary targets below.
        scala_options = {ScalaPlatform.options_scope: {"version": "custom"}}
        init_subsystems([JUnit, ScalaPlatform, ScoveragePlatform], scala_options)

        self.make_target(
            ":jar-tool", JarLibrary, jars=[JarDependency("org.pantsbuild", "jar-tool", "0.0.10")]
        )

        # NB: `test_has_python_requirements` will attempt to inject every possible scala compiler target
        # spec, for versions 2.10, 2.11, 2.12, and custom, and will error out if they are not
        # available. This isn't a problem when running pants on the command line, but in unit testing
        # there's probably some task or subsystem that needs to be initialized to avoid this.
        for empty_target in [
            "scalac",
            "scala-repl",
            "scala-library",
            "scala-reflect",
            "scalastyle",
        ]:
            for unused_scala_version in ["2_10", "2_11"]:
                self.make_target(
                    f":{empty_target}_{unused_scala_version}", Target,
                )
        self.make_target(
            ":scalac-plugin-dep", Target,
        )

        self.make_target(
            ":jarjar",
            JarLibrary,
            jars=[JarDependency(org="org.pantsbuild", name="jarjar", rev="1.7.2")],
        )

        self.make_target(
            ":scala-library",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-library", self._scala_toolchain_version)],
        )

        self.make_target(
            ":scalac",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-compiler", self._scala_toolchain_version)],
        )

        self.make_target(
            ":scalac_2_12",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-compiler", "2.12.8")],
        )
        self.make_target(
            ":scala-library_2_12",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-library", "2.12.8")],
        )
        self.make_target(
            ":scala-reflect_2_12",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-reflect", "2.12.8")],
        )
        self.make_target(
            ":scala-repl_2_12",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-repl", "2.12.8")],
        )
        self.make_target(
            ":scalastyle_2_12", Target,
        )
        self.make_target(
            ":scalastyle", Target,
        )

        self.make_target(
            ":scala-reflect",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-reflect", self._scala_toolchain_version)],
        )

        self.make_target(
            ":scala-repl",
            JarLibrary,
            jars=[JarDependency("org.scala-lang", "scala-repl", self._scala_toolchain_version)],
        )

        self.make_target(
            ":nailgun-server",
            JarLibrary,
            jars=[JarDependency(org="com.martiansoftware", name="nailgun-server", rev="0.9.1"),],
        )

        self.make_target(
            "project_info:first", target_type=Target,
        )

        jar_lib = self.make_target(
            "project_info:jar_lib",
            target_type=JarLibrary,
            jars=[JarDependency("org.apache", "apache-jar", "12.12.2012")],
        )

        self.make_target(
            "java/project_info:java_lib",
            target_type=JavaLibrary,
            sources=["com/foo/Bar.java", "com/foo/Baz.java"],
        )

        self.make_target(
            "project_info:third",
            target_type=ScalaLibrary,
            dependencies=[jar_lib],
            java_sources=["java/project_info:java_lib"],
            sources=["com/foo/Bar.scala", "com/foo/Baz.scala"],
        )

        self.make_target(
            "project_info:globular",
            target_type=ScalaLibrary,
            dependencies=[jar_lib],
            java_sources=["java/project_info:java_lib"],
            sources=["com/foo/*.scala"],
        )

        self.make_target(
            "project_info:jvm_app", target_type=JvmApp, dependencies=[jar_lib],
        )

        self.make_target(
            "project_info:jvm_target",
            target_type=ScalaLibrary,
            dependencies=[jar_lib],
            sources=["this/is/a/source/Foo.scala", "this/is/a/source/Bar.scala"],
        )

        test_resource = self.make_target(
            "project_info:test_resource",
            target_type=Resources,
            sources=["y_resource", "z_resource"],
        )

        self.make_target(
            "project_info:java_test",
            target_type=JUnitTests,
            dependencies=[jar_lib, test_resource],
            sources=["this/is/a/test/source/FooTest.scala"],
        )

        jvm_binary = self.make_target(
            "project_info:jvm_binary", target_type=JvmBinary, dependencies=[jar_lib],
        )

        self.make_target(
            "project_info:top_dependency", target_type=Target, dependencies=[jvm_binary],
        )

        src_resource = self.make_target(
            "project_info:resource", target_type=Resources, sources=["a_resource", "b_resource"],
        )

        self.make_target(
            "project_info:target_type",
            target_type=ScalaLibrary,
            dependencies=[jvm_binary, src_resource],
            sources=[],
        )

        self.make_target(
            "project_info:unrecognized_target_type", target_type=JvmTarget,
        )

        self.add_to_build_file(
            "src/python/x/BUILD",
            """
            python_library(name="x", sources=["*.py"])
            """.strip(),
        )

        self.add_to_build_file(
            "src/python/y/BUILD",
            dedent(
                """
                python_library(name="y", sources=["**/*.py"])
                python_library(name="y2", sources=["subdir/**/*.py"])
                python_library(name="y3", sources=["Test*.py"])
                """
            ),
        )

        self.add_to_build_file(
            "src/python/exclude/BUILD",
            """
            python_library(name="exclude", sources=["*.py", "!foo.py"])
            """.strip(),
        )

        self.add_to_build_file(
            "src/BUILD",
            """
            target(name="alias")
            """.strip(),
        )

        self.add_to_build_file(
            "src/python/has_reqs/BUILD",
            textwrap.dedent(
                """
                python_library(name="has_reqs", sources=["*.py"], dependencies=[':six'])

                python_requirement_library(
                    name='six',
                    requirements=[
                        python_requirement('six==1.9.0')
                    ]
                )
                """
            ),
        )
Beispiel #16
0
 def setUp(self):
     super().setUp()
     # Init engine because decompression now goes through native code.
     self._init_engine()
     TarballArtifact.NATIVE_BINARY = self._scheduler._scheduler._native
     init_subsystems([RequestsSession.Factory])
Beispiel #17
0
 def _init_target_subsystem(self):
   if not self._inited_target:
     subsystem_util.init_subsystems(self.subsystems)
     self._inited_target = True