FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge and formatting. · SatGarcia/drjava@1de2ade · GitHub

Repository navigation

Commit 1de2ade

Browse files
achooie
committed
Merge and formatting.
Changes to be committed: modified: src/edu/rice/cs/drjava/model/junit/JUnitTestManager.java modified: src/edu/rice/cs/util/IterableOps.java
1 parent 600e7f2 commit 1de2ade

2 files changed

Lines changed: 35 additions & 32 deletions

File tree

‎drjava/src/edu/rice/cs/drjava/model/junit/JUnitTestManager.java‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,26 @@
4242

4343
import java.io.File;
4444
import java.io.InputStream;
45-
import java.io.PrintWriter;
46-
import java.io.StringWriter;
4745

4846
import java.net.MalformedURLException;
4947
import java.net.URL;
5048
import java.net.URLClassLoader;
5149
import java.util.*;
5250

5351
import edu.rice.cs.drjava.model.coverage.CoverageMetadata;
54-
import edu.rice.cs.drjava.model.coverage.JacocoClassLoader;
5552
import edu.rice.cs.drjava.model.coverage.ReportGenerator;
5653

57-
import edu.rice.cs.drjava.model.compiler.LanguageLevelStackTraceMapper;
5854
import edu.rice.cs.drjava.model.repl.newjvm.ClassPathManager;
5955
import edu.rice.cs.util.Log;
6056
import edu.rice.cs.util.UnexpectedException;
6157
import edu.rice.cs.util.classloader.ClassFileError;
6258
import edu.rice.cs.plt.io.IOUtil;
63-
import edu.rice.cs.plt.lambda.Lambda;
6459
import edu.rice.cs.plt.tuple.Pair;
6560
import edu.rice.cs.plt.iter.IterUtil;
66-
import edu.rice.cs.plt.reflect.ShadowingClassLoader;
6761

6862
import java.lang.reflect.Method;
6963
import java.lang.reflect.Modifier;
7064

71-
import static edu.rice.cs.plt.debug.DebugUtil.debug;
7265
import static edu.rice.cs.plt.debug.DebugUtil.error;
7366

7467
import org.jacoco.core.analysis.Analyzer;
@@ -81,9 +74,6 @@
8174
import org.jacoco.core.runtime.LoggerRuntime;
8275
import org.jacoco.core.runtime.RuntimeData;
8376

84-
import edu.rice.cs.util.UnexpectedException;
85-
import edu.rice.cs.util.swing.Utilities;
86-
8777
/** Runs in the InterpreterJVM. Runs tests given a classname and formats the results into a (serializable) array of
8878
* JUnitError that can be passed back to the MainJVM.
8979
* @version $Id$
@@ -114,10 +104,9 @@ public class JUnitTestManager {
114104
private String _coverageOutdir = null;
115105
private IRuntime _runtime = null;
116106
private RuntimeData _myData = null;
117-
private List<File> _files = null;
118107
private List<String> _nonTestClassNames = null;
119108
private JUnitResultTuple _finalResult = new JUnitResultTuple(false, null);
120-
109+
121110
/** Standard constructor
122111
* @param jmc a JUnitModelCallback
123112
* @param loaderFactory factory to create class loaders
@@ -143,7 +132,7 @@ private URLClassLoader newURLLoader() {
143132
}
144133
return new URLClassLoader(urls.toArray(new URL[urls.size()]), EmptyClassLoader.INSTANCE);
145134
}
146-
135+
147136
/** Find the test classes among the given classNames and accumulate them in
148137
* TestSuite for junit. Returns null if a test suite is already pending.
149138
* @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
186175
_testFiles = new ArrayList<File>();
187176
_nonTestClassNames = new ArrayList(classNames.size());
188177
_suite = new TestSuite();
189-
178+
190179
// Assemble test suite (as _suite) and return list of test class names
191180
for (Pair<String, File> pair : IterUtil.zip(classNames, files)) {
192181
String cName = pair.first();
@@ -199,8 +188,7 @@ public List<String> findTestClasses(final List<String> classNames, final List<Fi
199188
Test test = new JUnit4TestAdapter(possibleTest);
200189
_suite.addTest(test);
201190
_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
204192
_nonTestClassNames.add(cName);
205193
_log.log("adding " + cName + " to nonTestClassNames");
206194
}
@@ -269,13 +257,13 @@ public boolean runTestSuite() {
269257
i++;
270258
}
271259
}
272-
260+
273261
_log.log("Testing doCoverage");
274262

275263
if (_runtime != null) { /* doCoverage was true */
276264

277265
_log.log("Analyzing coverage data for " + _nonTestClassNames);
278-
266+
279267
/* Collect session info (including which code was executed) */
280268
final ExecutionDataStore _executionDataStore = new ExecutionDataStore();
281269
final SessionInfoStore sessionInfos = new SessionInfoStore();
@@ -317,8 +305,7 @@ public boolean runTestSuite() {
317305
lineColors = rg.getAllLineColors();
318306
_finalResult = new JUnitResultTuple(true, lineColors);
319307

320-
}
321-
else {
308+
} else {
322309
_log.log("runtime was null");
323310
}
324311
/* Reset the runtime */
@@ -468,8 +455,9 @@ private JUnitError _makeJUnitError(TestFailure failure, List<String> classNames,
468455
String message = (isError) ? failure.thrownException().toString():
469456
failure.thrownException().getMessage();
470457

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");
473461

474462
// for debugging
475463
// try{

‎drjava/src/edu/rice/cs/util/IterableOps.java‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,35 @@
2525
* This file is part of DrJava. Download the current version of this project from http://www.drjava.org/ or
2626
* http://github.com/DrJavaAtRice/drjava.
2727
*
28-
* END_COPYRIGHT_BLOCK*/
28+
* END_COPYRIGHT_BLOCK */
2929

3030
package edu.rice.cs.util;
3131

32-
import java.util.ArrayList;
3332
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+
}
3454

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);
4358
}
4459
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL