Exemplo n.º 1
0
  def execute(self, targets):
    if not self.skip:
      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()

      args = []
      if self.color:
        args.append('--color')

      if self.tests:
        args.append('--classes')
        args.append(','.join(self.tests))
        run_tests('run', args)
      else:
        with safe_args(self.calculate_tests(targets)) as tests:
          if tests:
            args.append('--specs-files=%s' % ','.join(tests))
            run_tests('com.twitter.common.testing.ExplicitSpecsRunnerMain', args)
Exemplo n.º 2
0
 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()
Exemplo n.º 3
0
 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()
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 def run_tests(classpath, main, jvmargs=None):
     if self.only_write_cmd_line is 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,
             )
     else:
         with safe_open(self.only_write_cmd_line, 'w') as fd:
             result = runjava(jvmargs=(jvmargs or []) +
                              self.java_args,
                              classpath=classpath,
                              main=main,
                              args=self.flags + tests,
                              only_write_cmd_line_to=fd)
     if result != 0:
         raise TaskError()
Exemplo n.º 7
0
 def run_tests(classpath, main, jvmargs=None):
   if self.only_write_cmd_line is 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,
       )
   else:
     with safe_open(self.only_write_cmd_line, 'w') as fd:
       result = runjava(
         jvmargs=(jvmargs or []) + self.java_args,
         classpath=classpath,
         main=main,
         args=self.flags + tests,
         only_write_cmd_line_to=fd
       )
   if result != 0:
     raise TaskError()
Exemplo n.º 8
0
  def execute(self, targets):
    if not self.skip:
      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()

      if self.tests:
        run_tests(self.tests)
      else:
        with safe_args(self.calculate_tests(targets)) as tests:
          if tests:
            run_tests(tests)
Exemplo n.º 9
0
    def execute(self, targets):
        if not self.skip:

            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()

            if self.tests:
                run_tests(self.tests)
            else:
                with safe_args(self.calculate_tests(targets)) as tests:
                    if tests:
                        run_tests(tests)
Exemplo n.º 10
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:
        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)

        with safe_args(tests) as all_tests:
          result = runjava(
            jvmargs=self.java_args,
            classpath=classpath,
            main='com.twitter.common.testing.runner.JUnitConsoleRunner',
            args=self.flags + all_tests
          )
          if result != 0:
            raise TaskError()