def execute(self, targets): if not self.skip: def run_tests(tests): def workunit_factory(name, labels=list(), cmd=''): return self.context.new_workunit(name=name, labels=[WorkUnit.TEST] + labels, cmd=cmd) opts = ['--color'] if self.color else [] opts.append('--specs=%s' % ','.join(tests)) result = runjava_indivisible( jvmargs=self.java_args, classpath=self.classpath(profile_classpath(self.profile), confs=self.confs), main='com.twitter.common.testing.ExplicitSpecsRunnerMain', opts=opts, workunit_factory=workunit_factory, workunit_name='specs' ) 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)
def execute(self, targets): if not self.skip: def run_tests(tests): def workunit_factory(name, labels=list(), cmd=''): return self.context.new_workunit(name=name, labels=[WorkUnit.TEST] + labels, cmd=cmd) opts = ['--color'] if self.color else [] opts.append('--specs=%s' % ','.join(tests)) bootstrapped_cp = self._bootstrap_utils.get_jvm_build_tools_classpath(self._specs_bootstrap_key) result = runjava_indivisible( jvmargs=self.java_args, classpath=self.classpath(bootstrapped_cp, confs=self.confs, exclusives_classpath=self.get_base_classpath_for_target(targets[0])), main='com.twitter.common.testing.ExplicitSpecsRunnerMain', opts=opts, workunit_factory=workunit_factory, workunit_name='specs' ) 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)
def execute(self, targets): if not self.skip: def run_tests(tests): args = ['--color'] if self.color else [] args.append('--specs=%s' % ','.join(tests)) specs_runner_main = 'com.twitter.common.testing.ExplicitSpecsRunnerMain' bootstrapped_cp = self._jvm_tool_bootstrapper.get_jvm_tool_classpath( self._specs_bootstrap_key) classpath = self.classpath( bootstrapped_cp, confs=self.confs, exclusives_classpath=self.get_base_classpath_for_target(targets[0])) result = execute_java( classpath=classpath, main=specs_runner_main, jvm_options=self._jvm_options, args=args, workunit_factory=self.context.new_workunit, workunit_name='specs', workunit_labels=[WorkUnit.TEST] ) if result != 0: raise TaskError('java %s ... exited non-zero (%i)' % (specs_runner_main, result)) if self.tests: run_tests(self.tests) else: with safe_args(self.calculate_tests(targets)) as tests: if tests: run_tests(tests)
def run_tests(classpath, main, jvmargs=None): def test_workunit_factory(name, labels=list(), cmd=''): return self.context.new_workunit( name=name, labels=[WorkUnit.TEST] + labels, cmd=cmd) # TODO(John Sirois): Integrated batching with the test runner. As things stand we get # results summaries for example for each batch but no overall summary. # http://jira.local.twitter.com/browse/AWESOME-1114 result = 0 for batch in self._partition(tests): with binary_util.safe_args(batch) as batch_tests: result += abs( binary_util.runjava_indivisible( jvmargs=(jvmargs or []) + self.java_args, classpath=classpath, main=main, opts=self.opts, args=batch_tests, workunit_factory=test_workunit_factory, workunit_name='run')) if result != 0 and self.fail_fast: break if result != 0: raise TaskError()
def instrument_code(): safe_mkdir(self.coverage_instrument_dir, clean=True) with binary_util.safe_args(self.get_coverage_patterns(targets)) as patterns: opts = [ 'instr', '-out', self.coverage_metadata_file, '-d', self.coverage_instrument_dir, '-cp', os.pathsep.join(junit_classpath), '-exit' ] for pattern in patterns: opts.extend(['-filter', pattern]) result = binary_util.runjava_indivisible(classpath=emma_classpath, main='emma', opts=opts, workunit_name='emma') if result != 0: raise TaskError('Emma instrumentation failed with: %d' % result)
def run_tests(classpath, main, jvmargs=None): # TODO(John Sirois): Integrated batching with the test runner. As things stand we get # results summaries for example for each batch but no overall summary. # http://jira.local.twitter.com/browse/AWESOME-1114 result = 0 for batch in self._partition(tests): with binary_util.safe_args(batch) as batch_tests: result += abs(binary_util.runjava_indivisible( jvmargs=(jvmargs or []) + self.java_args, classpath=classpath, main=main, opts=self.opts, args=batch_tests )) if result != 0 and self.fail_fast: break if result != 0: raise TaskError()
def instrument_code(): safe_mkdir(self.coverage_instrument_dir, clean=True) with binary_util.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]) main = 'emma' result = execute_java(classpath=emma_classpath, main=main, args=args, workunit_factory=self.context.new_workunit, workunit_name='emma-instrument') if result != 0: raise TaskError("java %s ... exited non-zero (%i)" " 'failed to instrument'" % (main, result))
def run_tests(classpath, main, jvm_args=None): # TODO(John Sirois): Integrated batching with the test runner. As things stand we get # results summaries for example for each batch but no overall summary. # http://jira.local.twitter.com/browse/AWESOME-1114 result = 0 for batch in self._partition(tests): with binary_util.safe_args(batch) as batch_tests: result += abs(execute_java( classpath=classpath, main=main, jvm_options=(jvm_args or []) + self.jvm_args, args=self.opts + batch_tests, workunit_factory=self.context.new_workunit, workunit_name='run', workunit_labels=[WorkUnit.TEST] )) if result != 0 and self.fail_fast: break if result != 0: raise TaskError('java %s ... exited non-zero (%i)' % (main, result))
def instrument_code(): safe_mkdir(self.coverage_instrument_dir, clean=True) with binary_util.safe_args( self.get_coverage_patterns( targets)) as patterns: opts = [ 'instr', '-out', self.coverage_metadata_file, '-d', self.coverage_instrument_dir, '-cp', os.pathsep.join(junit_classpath), '-exit' ] for pattern in patterns: opts.extend(['-filter', pattern]) result = binary_util.runjava_indivisible( classpath=emma_classpath, main='emma', opts=opts, workunit_name='emma') if result != 0: raise TaskError( 'Emma instrumentation failed with: %d' % result)
def execute(self, targets): if not self.skip: def run_tests(tests): opts = ['--color'] if self.color else [] opts.append('--specs=%s' % ','.join(tests)) result = runjava_indivisible( jvmargs=self.java_args, classpath=self.classpath(profile_classpath(self.profile), confs=self.confs), main='com.twitter.common.testing.ExplicitSpecsRunnerMain', opts=opts ) 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)
def run_tests(classpath, main, jvm_args=None): # TODO(John Sirois): Integrated batching with the test runner. As things stand we get # results summaries for example for each batch but no overall summary. # http://jira.local.twitter.com/browse/AWESOME-1114 result = 0 for batch in self._partition(tests): with binary_util.safe_args(batch) as batch_tests: result += abs( execute_java( classpath=classpath, main=main, jvm_options=(jvm_args or []) + self.jvm_args, args=self.opts + batch_tests, workunit_factory=self.context.new_workunit, workunit_name='run', workunit_labels=[WorkUnit.TEST])) if result != 0 and self.fail_fast: break if result != 0: raise TaskError('java %s ... exited non-zero (%i)' % (main, result))
def run_tests(classpath, main, jvmargs=None): def test_workunit_factory(name, labels=list(), cmd=''): return self.context.new_workunit(name=name, labels=[WorkUnit.TEST] + labels, cmd=cmd) # TODO(John Sirois): Integrated batching with the test runner. As things stand we get # results summaries for example for each batch but no overall summary. # http://jira.local.twitter.com/browse/AWESOME-1114 result = 0 for batch in self._partition(tests): with binary_util.safe_args(batch) as batch_tests: result += abs(binary_util.runjava_indivisible( jvmargs=(jvmargs or []) + self.java_args, classpath=classpath, main=main, opts=self.opts, args=batch_tests, workunit_factory=test_workunit_factory, workunit_name='run' )) if result != 0 and self.fail_fast: break if result != 0: raise TaskError()
def instrument_code(): safe_mkdir(self.coverage_instrument_dir, clean=True) with binary_util.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]) main = 'emma' result = execute_java( classpath=emma_classpath, main=main, args=args, workunit_factory=self.context.new_workunit, workunit_name='emma-instrument') if result != 0: raise TaskError( "java %s ... exited non-zero (%i)" " 'failed to instrument'" % (main, result))