| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 600e7f2 commit 1de2ade
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,33 +42,26 @@ | |||
| 42 | 42 | ||
| 43 | 43 | import java.io.File; | |
| 44 | 44 | import java.io.InputStream; | |
| 45 | - import java.io.PrintWriter; | ||
| 46 | - import java.io.StringWriter; | ||
| 47 | 45 | ||
| 48 | 46 | import java.net.MalformedURLException; | |
| 49 | 47 | import java.net.URL; | |
| 50 | 48 | import java.net.URLClassLoader; | |
| 51 | 49 | import java.util.*; | |
| 52 | 50 | ||
| 53 | 51 | import edu.rice.cs.drjava.model.coverage.CoverageMetadata; | |
| 54 | - import edu.rice.cs.drjava.model.coverage.JacocoClassLoader; | ||
| 55 | 52 | import edu.rice.cs.drjava.model.coverage.ReportGenerator; | |
| 56 | 53 | ||
| 57 | - import edu.rice.cs.drjava.model.compiler.LanguageLevelStackTraceMapper; | ||
| 58 | 54 | import edu.rice.cs.drjava.model.repl.newjvm.ClassPathManager; | |
| 59 | 55 | import edu.rice.cs.util.Log; | |
| 60 | 56 | import edu.rice.cs.util.UnexpectedException; | |
| 61 | 57 | import edu.rice.cs.util.classloader.ClassFileError; | |
| 62 | 58 | import edu.rice.cs.plt.io.IOUtil; | |
| 63 | - import edu.rice.cs.plt.lambda.Lambda; | ||
| 64 | 59 | import edu.rice.cs.plt.tuple.Pair; | |
| 65 | 60 | import edu.rice.cs.plt.iter.IterUtil; | |
| 66 | - import edu.rice.cs.plt.reflect.ShadowingClassLoader; | ||
| 67 | 61 | ||
| 68 | 62 | import java.lang.reflect.Method; | |
| 69 | 63 | import java.lang.reflect.Modifier; | |
| 70 | 64 | ||
| 71 | - import static edu.rice.cs.plt.debug.DebugUtil.debug; | ||
| 72 | 65 | import static edu.rice.cs.plt.debug.DebugUtil.error; | |
| 73 | 66 | ||
| 74 | 67 | import org.jacoco.core.analysis.Analyzer; | |
@@ -81,9 +74,6 @@ | |||
| 81 | 74 | import org.jacoco.core.runtime.LoggerRuntime; | |
| 82 | 75 | import org.jacoco.core.runtime.RuntimeData; | |
| 83 | 76 | ||
| 84 | - import edu.rice.cs.util.UnexpectedException; | ||
| 85 | - import edu.rice.cs.util.swing.Utilities; | ||
| 86 | - | ||
| 87 | 77 | /** Runs in the InterpreterJVM. Runs tests given a classname and formats the results into a (serializable) array of | |
| 88 | 78 | * JUnitError that can be passed back to the MainJVM. | |
| 89 | 79 | * @version $Id$ | |
@@ -114,10 +104,9 @@ public class JUnitTestManager { | |||
| 114 | 104 | private String _coverageOutdir = null; | |
| 115 | 105 | private IRuntime _runtime = null; | |
| 116 | 106 | private RuntimeData _myData = null; | |
| 117 | - private List<File> _files = null; | ||
| 118 | 107 | private List<String> _nonTestClassNames = null; | |
| 119 | 108 | private JUnitResultTuple _finalResult = new JUnitResultTuple(false, null); | |
| 120 | - | ||
| 109 | + | ||
| 121 | 110 | /** Standard constructor | |
| 122 | 111 | * @param jmc a JUnitModelCallback | |
| 123 | 112 | * @param loaderFactory factory to create class loaders | |
@@ -143,7 +132,7 @@ private URLClassLoader newURLLoader() { | |||
| 143 | 132 | } | |
| 144 | 133 | return new URLClassLoader(urls.toArray(new URL[urls.size()]), EmptyClassLoader.INSTANCE); | |
| 145 | 134 | } | |
| 146 | - | ||
| 135 | + | ||
| 147 | 136 | /** Find the test classes among the given classNames and accumulate them in | |
| 148 | 137 | * TestSuite for junit. Returns null if a test suite is already pending. | |
| 149 | 138 | * @param classNames the (fully qualified) class names that are test class candidates | |
@@ -186,7 +175,7 @@ public List<String> findTestClasses(final List<String> classNames, final List<Fi | |||
| 186 | 175 | _testFiles = new ArrayList<File>(); | |
| 187 | 176 | _nonTestClassNames = new ArrayList(classNames.size()); | |
| 188 | 177 | _suite = new TestSuite(); | |
| 189 | - | ||
| 178 | + | ||
| 190 | 179 | // Assemble test suite (as _suite) and return list of test class names | |
| 191 | 180 | for (Pair<String, File> pair : IterUtil.zip(classNames, files)) { | |
| 192 | 181 | String cName = pair.first(); | |
@@ -199,8 +188,7 @@ public List<String> findTestClasses(final List<String> classNames, final List<Fi | |||
| 199 | 188 | Test test = new JUnit4TestAdapter(possibleTest); | |
| 200 | 189 | _suite.addTest(test); | |
| 201 | 190 | _log.log("Adding test " + test + " to test suite"); | |
| 202 | - } | ||
| 203 | - else { // cName is a program class that is not a test class | ||
| 191 | + } else { // cName is a program class that is not a test class | ||
| 204 | 192 | _nonTestClassNames.add(cName); | |
| 205 | 193 | _log.log("adding " + cName + " to nonTestClassNames"); | |
| 206 | 194 | } | |
@@ -269,13 +257,13 @@ public boolean runTestSuite() { | |||
| 269 | 257 | i++; | |
| 270 | 258 | } | |
| 271 | 259 | } | |
| 272 | - | ||
| 260 | + | ||
| 273 | 261 | _log.log("Testing doCoverage"); | |
| 274 | 262 | ||
| 275 | 263 | if (_runtime != null) { /* doCoverage was true */ | |
| 276 | 264 | ||
| 277 | 265 | _log.log("Analyzing coverage data for " + _nonTestClassNames); | |
| 278 | - | ||
| 266 | + | ||
| 279 | 267 | /* Collect session info (including which code was executed) */ | |
| 280 | 268 | final ExecutionDataStore _executionDataStore = new ExecutionDataStore(); | |
| 281 | 269 | final SessionInfoStore sessionInfos = new SessionInfoStore(); | |
@@ -317,8 +305,7 @@ public boolean runTestSuite() { | |||
| 317 | 305 | lineColors = rg.getAllLineColors(); | |
| 318 | 306 | _finalResult = new JUnitResultTuple(true, lineColors); | |
| 319 | 307 | ||
| 320 | - } | ||
| 321 | - else { | ||
| 308 | + } else { | ||
| 322 | 309 | _log.log("runtime was null"); | |
| 323 | 310 | } | |
| 324 | 311 | /* Reset the runtime */ | |
@@ -468,8 +455,9 @@ private JUnitError _makeJUnitError(TestFailure failure, List<String> classNames, | |||
| 468 | 455 | String message = (isError) ? failure.thrownException().toString(): | |
| 469 | 456 | failure.thrownException().getMessage(); | |
| 470 | 457 | ||
| 471 | - boolean isFailure = (failure.thrownException() instanceof AssertionError || failure.thrownException() instanceof AssertionFailedError) && | ||
| 472 | - !classNameAndTest.equals("junit.framework.TestSuite$1.warning"); | ||
| 458 | + boolean isFailure = (failure.thrownException() instanceof AssertionError || | ||
| 459 | + failure.thrownException() instanceof AssertionFailedError) && | ||
| 460 | + !classNameAndTest.equals("junit.framework.TestSuite$1.warning"); | ||
| 473 | 461 | ||
| 474 | 462 | // for debugging | |
| 475 | 463 | // try{ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,20 +25,35 @@ | |||
| 25 | 25 | * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/ or | |
| 26 | 26 | * http://github.com/DrJavaAtRice/drjava. | |
| 27 | 27 | * | |
| 28 | - * END_COPYRIGHT_BLOCK*/ | ||
| 28 | + * END_COPYRIGHT_BLOCK */ | ||
| 29 | 29 | ||
| 30 | 30 | package edu.rice.cs.util; | |
| 31 | 31 | ||
| 32 | - import java.util.ArrayList; | ||
| 33 | 32 | import java.lang.reflect.Array; | |
| 33 | + import java.util.ArrayList; | ||
| 34 | + | ||
| 35 | + /** A class to provide some convenient Iterable operations as static methods. | ||
| 36 | + * It's abstract to prevent (useless) instantiation, though it can be subclassed | ||
| 37 | + * to provide convenient namespace importation of its methods. | ||
| 38 | + */ | ||
| 39 | + public abstract class IterableOps { | ||
| 40 | + | ||
| 41 | + /** Convert an Iterable to an array. | ||
| 42 | + * | ||
| 43 | + * @param iter Iterable object to be converted. | ||
| 44 | + * @param <T> Parameterized type of the iterable. | ||
| 45 | + * @return the array NOTE: at compile time the type of the array is Object[]; can cause ClassCastException. | ||
| 46 | + */ | ||
| 47 | + @SuppressWarnings("unchecked") | ||
| 48 | + public static <T> T[] toArray(Iterable<T> iter, Class<T> elemType) { | ||
| 49 | + ArrayList<T> al = new ArrayList(); | ||
| 50 | + | ||
| 51 | + for (T elem : iter) { | ||
| 52 | + al.add(elem); | ||
| 53 | + } | ||
| 34 | 54 | ||
| 35 | - public class IterableOps { | ||
| 36 | - public static <T> T[] toArray(Iterable<T> elements, Class<T> eltType) { | ||
| 37 | - ArrayList<T> arrayListElements = new ArrayList<T>(); | ||
| 38 | - for (T element : elements) arrayListElements.add(element); | ||
| 39 | - int size = arrayListElements.size(); | ||
| 40 | - @SuppressWarnings("unchecked") // Create an array of the proper type and size using reflection | ||
| 41 | - T[] arrayElements = (T[]) Array.newInstance(eltType, size); | ||
| 42 | - return arrayListElements.toArray(arrayElements); | ||
| 55 | + int size = al.size(); | ||
| 56 | + T[] array = (T[]) Array.newInstance(elemType, size); | ||
| 57 | + return al.toArray(array); | ||
| 43 | 58 | } | |
| 44 | 59 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments