예제 #1
0
 def configure_profiles(self, scala_compiler_profile):
     checkstyle_enabled = len(Phase.goals_of_type(Checkstyle)) > 0
     self.checkstyle_classpath = profile_classpath(
         'checkstyle') if checkstyle_enabled else []
     self.scala_compiler_classpath = []
     if self.has_scala:
         self.scala_compiler_classpath.extend(
             profile_classpath(scala_compiler_profile))
예제 #2
0
 def execute(self, targets):
     runjava(
         jvmargs=self.jvm_args,
         classpath=self.classpath(profile_classpath(self.profile), confs=self.confs),
         main=self.main,
         args=self.args,
     )
예제 #3
0
  def execute(self, targets):
    if not self.skip:
      args = []
      if self.tests:
        args.append('--classes')
        args.append(','.join(self.tests))
      else:
        tests = self.calculate_tests(targets)
        if tests:
          args.append('--specs-files=%s' % ','.join(tests))

      if args:
        if self.color:
          args.append('--color')

        classpath = profile_classpath(self.profile)
        classpath.extend(os.path.join(get_buildroot(), path)
                         for path in ('src/resources', 'tests/resources'))
        with self.context.state('classpath', []) as cp:
          classpath.extend(jar for conf, jar in cp if conf in self.confs)

        result = runjava(
          jvmargs=self.java_args,
          classpath=classpath,
          main='run' if self.tests else 'com.twitter.common.testing.ExplicitSpecsRunnerMain',
          args=args
        )
        if result != 0:
          raise TaskError()
예제 #4
0
 def execute(self, targets):
     self.context.lock.release()
     runjava(jvmargs=self.jvm_args,
             classpath=self.classpath(profile_classpath(self.profile),
                                      confs=self.confs),
             main=self.main,
             args=self.args)
예제 #5
0
 def execute(self, targets):
   runjava(
     jvmargs=self.jvm_args,
     classpath=self.classpath(profile_classpath(self.profile), confs=self.confs),
     main=self.main,
     args=self.args
   )
예제 #6
0
 def execute(self, targets):
   self.context.lock.release()
   runjava(
     jvmargs=self.jvm_args,
     classpath=self.classpath(profile_classpath(self.profile), confs=self.confs),
     main=self.main,
     args=self.args
   )
예제 #7
0
      def run_tests(main, args):
        classpath = profile_classpath(self.profile)
        classpath.extend(os.path.join(get_buildroot(), path)
                         for path in ('src/resources', 'tests/resources'))
        with self.context.state('classpath', []) as cp:
          classpath.extend(jar for conf, jar in cp if conf in self.confs)

        result = runjava(jvmargs=self.java_args, classpath=classpath, main=main, args=args)
        if result != 0:
          raise TaskError()
예제 #8
0
파일: specs_run.py 프로젝트: nsanch/commons
            def run_tests(tests):
                args = ["--color"] if self.color else []
                args.append("--specs=%s" % ",".join(tests))

                result = runjava(
                    jvmargs=self.java_args,
                    classpath=self.classpath(profile_classpath(self.profile), confs=self.confs),
                    main="com.twitter.common.testing.ExplicitSpecsRunnerMain",
                    args=args,
                )
                if result != 0:
                    raise TaskError()
예제 #9
0
      def run_tests(tests):
        args = ['--color'] if self.color else []
        args.append('--specs=%s' % ','.join(tests))

        result = runjava(
          jvmargs=self.java_args,
          classpath=self.classpath(profile_classpath(self.profile), confs=self.confs),
          main='com.twitter.common.testing.ExplicitSpecsRunnerMain',
          args=args
        )
        if result != 0:
          raise TaskError()
예제 #10
0
  def execute(self, targets):
    if not self.context.options.junit_run_skip:
      tests = self.tests or self.calculate_tests(targets)
      if tests:
        classpath = profile_classpath(self.profile)

        # TODO(John Sirois): undo cheeseball! - derive src/resources from target attribute and then
        # later fix tests to declare their resources as well?
        classpath.extend(os.path.join(get_buildroot(), path)
                         for path in ('src/resources', 'tests/resources'))

        with self.context.state('classpath', []) as cp:
          classpath.extend(jar for conf, jar in cp if conf in self.confs)

        result = runjava(
          jvmargs=self.java_args,
          classpath=classpath,
          main='com.twitter.common.testing.runner.JUnitConsoleRunner',
          args=self.flags + list(tests)
        )
        if result != 0:
          raise TaskError()
예제 #11
0
파일: ide_gen.py 프로젝트: SeungEun/commons
 def configure_profiles(self, scala_compiler_profile):
   checkstyle_enabled = len(Phase.goals_of_type(Checkstyle)) > 0
   self.checkstyle_classpath = profile_classpath('checkstyle') if checkstyle_enabled else []
   self.scala_compiler_classpath = []
   if self.has_scala:
     self.scala_compiler_classpath.extend(profile_classpath(scala_compiler_profile))
예제 #12
0
  def execute(self, targets):
    if not self.context.options.junit_run_skip:
      tests = list(self.normalize_test_classes() if self.test_classes
                                                 else self.calculate_tests(targets))
      if tests:
        junit_classpath = self.classpath(profile_classpath(self.junit_profile), confs=self.confs)

        def run_tests(classpath, main, jvmargs=None):
          with safe_args(tests) as all_tests:
            result = runjava(
              jvmargs=(jvmargs or []) + self.java_args,
              classpath=classpath,
              main=main,
              args=self.flags + all_tests
            )
            if result != 0:
              raise TaskError()

        if self.coverage:
          emma_classpath = profile_classpath(self.emma_profile)

          def instrument_code():
            safe_mkdir(self.coverage_instrument_dir, clean=True)
            with safe_args(self.get_coverage_patterns(targets)) as patterns:
              args = [
                'instr',
                '-out', self.coverage_metadata_file,
                '-d', self.coverage_instrument_dir,
                '-cp', os.pathsep.join(junit_classpath),
                '-exit'
              ]
              for pattern in patterns:
                args.extend(['-filter', pattern])
              result = runjava(classpath=emma_classpath, main='emma', args=args)
              if result != 0:
                raise TaskError('Emma instrumentation failed with: %d' % result)

          def generate_reports():
            args = [
              'report',
              '-in', self.coverage_metadata_file,
              '-in', self.coverage_file,
              '-exit'
            ]
            source_bases = set(t.target_base for t in targets)
            for source_base in source_bases:
              args.extend(['-sp', source_base])

            sorting = ['-Dreport.sort', '+name,+class,+method,+block']
            if self.coverage_report_console:
              args.extend(['-r', 'txt',
                           '-Dreport.txt.out.file=%s' % self.coverage_console_file] + sorting)
            if self.coverage_report_xml:
              args.extend(['-r', 'xml','-Dreport.xml.out.file=%s' % self.coverage_xml_file])
            if self.coverage_report_html:
              args.extend(['-r', 'html',
                           '-Dreport.html.out.file=%s' % self.coverage_html_file,
                           '-Dreport.out.encoding=UTF-8'] + sorting)

            result = runjava(
              classpath=emma_classpath,
              main='emma',
              args=args
            )
            if result != 0:
              raise TaskError('Failed to emma generate code coverage reports: %d' % result)

            if self.coverage_report_console:
              with safe_open(self.coverage_console_file) as console_report:
                sys.stdout.write(console_report.read())
            if self.coverage_report_html_open:
              binary_utils.open(self.coverage_html_file)

          instrument_code()
          try:
            # Coverage runs over instrumented classes require the instrumented classes come 1st in
            # the classpath followed by the normal classpath.  The instrumentation also adds a
            # dependency on emma libs that must be satisfied on the classpath.
            run_tests(
              [self.coverage_instrument_dir] + junit_classpath + emma_classpath,
              'com.twitter.common.testing.runner.JUnitConsoleRunner',
              jvmargs=['-Demma.coverage.out.file=%s' % self.coverage_file]
            )
          finally:
            generate_reports()
        else:
          self.context.lock.release()
          run_tests(junit_classpath, 'com.twitter.common.testing.runner.JUnitConsoleRunner')
예제 #13
0
파일: ide.py 프로젝트: znewman01/commons
 def _configure_profiles(self, scala_compiler_profile):
   self.checkstyle_classpath = profile_classpath('checkstyle')
   self.scala_compiler_classpath = []
   if self.has_scala:
     self.scala_compiler_classpath.extend(profile_classpath(scala_compiler_profile))
예제 #14
0
 def cp_for_profile(profile):
   return profile_classpath(profile, java_runner=self._java_runner, config=self._context.config)
예제 #15
0
    def execute(self, targets):
        classpath = profile_classpath(self.profile)
        with self.context.state("classpath", []) as cp:
            classpath.extend(jar for conf, jar in cp if conf in self.confs)

        result = runjava(jvmargs=self.jvm_args, classpath=classpath, main=self.main, args=[])
예제 #16
0
    def execute(self, targets):
        if not self.context.options.junit_run_skip:
            tests = list(self.normalize_test_classes() if self.
                         test_classes else self.calculate_tests(targets))
            if tests:
                junit_classpath = self.classpath(profile_classpath(
                    self.junit_profile),
                                                 confs=self.confs)

                def run_tests(classpath, main, jvmargs=None):
                    with safe_args(tests) as all_tests:
                        result = runjava(jvmargs=(jvmargs or []) +
                                         self.java_args,
                                         classpath=classpath,
                                         main=main,
                                         args=self.flags + all_tests)
                        if result != 0:
                            raise TaskError()

                if self.coverage:
                    emma_classpath = profile_classpath(self.emma_profile)

                    def instrument_code():
                        safe_mkdir(self.coverage_instrument_dir, clean=True)
                        with safe_args(self.get_coverage_patterns(
                                targets)) as patterns:
                            args = [
                                'instr', '-out', self.coverage_metadata_file,
                                '-d', self.coverage_instrument_dir, '-cp',
                                os.pathsep.join(junit_classpath), '-exit'
                            ]
                            for pattern in patterns:
                                args.extend(['-filter', pattern])
                            result = runjava(classpath=emma_classpath,
                                             main='emma',
                                             args=args)
                            if result != 0:
                                raise TaskError(
                                    'Emma instrumentation failed with: %d' %
                                    result)

                    def generate_reports():
                        args = [
                            'report', '-in', self.coverage_metadata_file,
                            '-in', self.coverage_file, '-exit'
                        ]
                        source_bases = set(t.target_base for t in targets)
                        for source_base in source_bases:
                            args.extend(['-sp', source_base])

                        sorting = [
                            '-Dreport.sort', '+name,+class,+method,+block'
                        ]
                        if self.coverage_report_console:
                            args.extend([
                                '-r', 'txt',
                                '-Dreport.txt.out.file=%s' %
                                self.coverage_console_file
                            ] + sorting)
                        if self.coverage_report_xml:
                            args.extend([
                                '-r', 'xml',
                                '-Dreport.xml.out.file=%s' %
                                self.coverage_xml_file
                            ])
                        if self.coverage_report_html:
                            args.extend([
                                '-r', 'html',
                                '-Dreport.html.out.file=%s' %
                                self.coverage_html_file,
                                '-Dreport.out.encoding=UTF-8'
                            ] + sorting)

                        result = runjava(classpath=emma_classpath,
                                         main='emma',
                                         args=args)
                        if result != 0:
                            raise TaskError(
                                'Failed to emma generate code coverage reports: %d'
                                % result)

                        if self.coverage_report_console:
                            with safe_open(self.coverage_console_file
                                           ) as console_report:
                                sys.stdout.write(console_report.read())
                        if self.coverage_report_html_open:
                            binary_utils.open(self.coverage_html_file)

                    instrument_code()
                    try:
                        # Coverage runs over instrumented classes require the instrumented classes come 1st in
                        # the classpath followed by the normal classpath.  The instrumentation also adds a
                        # dependency on emma libs that must be satisfied on the classpath.
                        run_tests(
                            [self.coverage_instrument_dir] + junit_classpath +
                            emma_classpath,
                            'com.twitter.common.testing.runner.JUnitConsoleRunner',
                            jvmargs=[
                                '-Demma.coverage.out.file=%s' %
                                self.coverage_file
                            ])
                    finally:
                        generate_reports()
                else:
                    run_tests(
                        junit_classpath,
                        'com.twitter.common.testing.runner.JUnitConsoleRunner')
예제 #17
0
 def cp_for_profile(profile):
     return profile_classpath(profile,
                              java_runner=self._java_runner,
                              config=self._context.config)