public void run(IPerfOutput output) throws Exception {
   final IRuntime runtime = new LoggerRuntime();
   ClassReader reader = new ClassReader(TargetLoader.getClassData(target));
   final Instrumenter instr = new Instrumenter(runtime);
   instr.instrument(reader);
   output.writeByteResult("instrumented class", instr.instrument(reader).length, reader.b.length);
 }
Example #2
0
 private void createClassfile(final String dir, final Class<?> source) throws IOException {
   File file = new File(folder.getRoot(), dir);
   file.mkdirs();
   file = new File(file, "some.class");
   OutputStream out = new FileOutputStream(file);
   out.write(TargetLoader.getClassDataAsBytes(source));
   out.close();
 }
Example #3
0
 @Test
 public void testAnalyzeAll2() throws IOException {
   final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
   final ZipOutputStream zip = new ZipOutputStream(buffer);
   zip.putNextEntry(new ZipEntry("org/jacoco/core/analysis/AnalyzerTest.class"));
   zip.write(TargetLoader.getClassDataAsBytes(AnalyzerTest.class));
   zip.finish();
   final int count = analyzer.analyzeAll(new ByteArrayInputStream(buffer.toByteArray()));
   assertEquals(1, count);
   assertEquals(Collections.singleton("org/jacoco/core/analysis/AnalyzerTest"), classes);
 }
Example #4
0
 @Test
 public void testAnalyzeAll1() throws IOException {
   final int count = analyzer.analyzeAll(TargetLoader.getClassData(AnalyzerTest.class));
   assertEquals(1, count);
   assertEquals(Collections.singleton("org/jacoco/core/analysis/AnalyzerTest"), classes);
 }
Example #5
0
 @Test
 public void testAnalyzeClass2() throws IOException {
   analyzer.analyzeClass(TargetLoader.getClassDataAsBytes(AnalyzerTest.class));
   assertEquals(Collections.singleton("org/jacoco/core/analysis/AnalyzerTest"), classes);
 }