|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| package edu.rice.cs.drjava.model.junit; |
|
38 |
| |
|
39 |
| import java.awt.EventQueue; |
|
40 |
| import java.io.File; |
|
41 |
| import java.io.IOException; |
|
42 |
| import java.io.BufferedReader; |
|
43 |
| import java.io.InputStreamReader; |
|
44 |
| import java.io.FileReader; |
|
45 |
| import java.rmi.RemoteException; |
|
46 |
| |
|
47 |
| import java.util.List; |
|
48 |
| import java.util.LinkedList; |
|
49 |
| import java.util.ArrayList; |
|
50 |
| import java.util.Arrays; |
|
51 |
| import java.util.HashMap; |
|
52 |
| import java.util.HashSet; |
|
53 |
| import java.util.Set; |
|
54 |
| import java.util.TreeMap; |
|
55 |
| import java.util.jar.JarFile; |
|
56 |
| import java.util.jar.JarEntry; |
|
57 |
| |
|
58 |
| import javax.swing.JOptionPane; |
|
59 |
| |
|
60 |
| import edu.rice.cs.drjava.config.BooleanOption; |
|
61 |
| import edu.rice.cs.drjava.model.GlobalModel; |
|
62 |
| import edu.rice.cs.drjava.model.FileMovedException; |
|
63 |
| import edu.rice.cs.drjava.model.OpenDefinitionsDocument; |
|
64 |
| import edu.rice.cs.drjava.model.DrJavaFileUtils; |
|
65 |
| import edu.rice.cs.drjava.model.repl.newjvm.MainJVM; |
|
66 |
| import edu.rice.cs.drjava.model.compiler.CompilerModel; |
|
67 |
| import edu.rice.cs.drjava.model.compiler.CompilerListener; |
|
68 |
| import edu.rice.cs.drjava.model.compiler.DummyCompilerListener; |
|
69 |
| import edu.rice.cs.drjava.model.definitions.InvalidPackageException; |
|
70 |
| import edu.rice.cs.drjava.ui.DrJavaErrorHandler; |
|
71 |
| import edu.rice.cs.drjava.config.OptionConstants; |
|
72 |
| |
|
73 |
| import edu.rice.cs.plt.io.IOUtil; |
|
74 |
| import edu.rice.cs.plt.iter.IterUtil; |
|
75 |
| import edu.rice.cs.plt.lambda.Box; |
|
76 |
| import edu.rice.cs.plt.lambda.SimpleBox; |
|
77 |
| import edu.rice.cs.plt.concurrent.JVMBuilder; |
|
78 |
| import edu.rice.cs.util.FileOps; |
|
79 |
| import edu.rice.cs.util.UnexpectedException; |
|
80 |
| import edu.rice.cs.util.classloader.ClassFileError; |
|
81 |
| import edu.rice.cs.util.text.SwingDocument; |
|
82 |
| import edu.rice.cs.util.swing.Utilities; |
|
83 |
| import edu.rice.cs.util.Log; |
|
84 |
| |
|
85 |
| import org.objectweb.asm.*; |
|
86 |
| |
|
87 |
| import static edu.rice.cs.plt.debug.DebugUtil.debug; |
|
88 |
| import edu.rice.cs.drjava.model.compiler.LanguageLevelStackTraceMapper; |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| public class DefaultJUnitModel implements JUnitModel, JUnitModelCallback { |
|
94 |
| |
|
95 |
| |
|
96 |
| private static Log _log = new Log("DefaultJUnitModel.txt", false); |
|
97 |
| |
|
98 |
| |
|
99 |
| private final JUnitEventNotifier _notifier = new JUnitEventNotifier(); |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| private final MainJVM _jvm; |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| private final CompilerModel _compilerModel; |
|
110 |
| |
|
111 |
| |
|
112 |
| private final GlobalModel _model; |
|
113 |
| |
|
114 |
| |
|
115 |
| private volatile JUnitErrorModel _junitErrorModel; |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
| |
|
120 |
| private volatile boolean _testInProgress = false; |
|
121 |
| |
|
122 |
| |
|
123 |
| private boolean _forceTestSuffix = false; |
|
124 |
| |
|
125 |
| |
|
126 |
| private final SwingDocument _junitDoc = new SwingDocument(); |
|
127 |
| |
|
128 |
| |
|
129 |
| |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
157
| public DefaultJUnitModel(MainJVM jvm, CompilerModel compilerModel, GlobalModel model) {
|
|
134 |
157
| _jvm = jvm;
|
|
135 |
157
| _compilerModel = compilerModel;
|
|
136 |
157
| _model = model;
|
|
137 |
157
| _junitErrorModel = new JUnitErrorModel(new JUnitError[0], _model, false);
|
|
138 |
157
| BooleanOption suffixOption = OptionConstants.FORCE_TEST_SUFFIX;
|
|
139 |
157
| _forceTestSuffix = edu.rice.cs.drjava.DrJava.getConfig().getSetting(suffixOption).booleanValue();
|
|
140 |
| } |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
0
| public void setForceTestSuffix(boolean b) { _forceTestSuffix = b; }
|
|
145 |
| |
|
146 |
| |
|
147 |
| |
|
148 |
47
| public boolean isTestInProgress() { return _testInProgress; }
|
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
| |
|
154 |
| |
|
155 |
157
| public void addListener(JUnitListener listener) { _notifier.addListener(listener); }
|
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
0
| public void removeListener(JUnitListener listener) { _notifier.removeListener(listener); }
|
|
162 |
| |
|
163 |
| |
|
164 |
0
| public void removeAllListeners() { _notifier.removeAllListeners(); }
|
|
165 |
| |
|
166 |
| |
|
167 |
| |
|
168 |
| |
|
169 |
3
| public SwingDocument getJUnitDocument() { return _junitDoc; }
|
|
170 |
| |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
2
| public void junitAll() { junitDocs(_model.getOpenDefinitionsDocuments()); }
|
|
175 |
| |
|
176 |
| |
|
177 |
| |
|
178 |
| |
|
179 |
| |
|
180 |
0
| public void junitProject() {
|
|
181 |
0
| LinkedList<OpenDefinitionsDocument> lod = new LinkedList<OpenDefinitionsDocument>();
|
|
182 |
| |
|
183 |
0
| for (OpenDefinitionsDocument doc : _model.getOpenDefinitionsDocuments()) {
|
|
184 |
0
| if (doc.inProjectPath()) lod.add(doc);
|
|
185 |
| } |
|
186 |
0
| junitOpenDefDocs(lod, true);
|
|
187 |
| } |
|
188 |
| |
|
189 |
| |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
| |
|
194 |
| |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
| |
|
199 |
| |
|
200 |
| |
|
201 |
| |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| |
|
208 |
| |
|
209 |
| |
|
210 |
| |
|
211 |
| |
|
212 |
| |
|
213 |
| |
|
214 |
| |
|
215 |
| |
|
216 |
| |
|
217 |
| |
|
218 |
| |
|
219 |
| |
|
220 |
| |
|
221 |
| |
|
222 |
| |
|
223 |
2
| public void junitDocs(List<OpenDefinitionsDocument> lod) { junitOpenDefDocs(lod, true); }
|
|
224 |
| |
|
225 |
| |
|
226 |
17
| public void junit(OpenDefinitionsDocument doc) throws ClassNotFoundException, IOException {
|
|
227 |
17
| debug.logStart("junit(doc)");
|
|
228 |
| |
|
229 |
17
| File testFile;
|
|
230 |
17
| try {
|
|
231 |
17
| testFile = doc.getFile();
|
|
232 |
17
| if (testFile == null) {
|
|
233 |
0
| nonTestCase(false, false);
|
|
234 |
0
| debug.logEnd("junit(doc): no corresponding file");
|
|
235 |
0
| return;
|
|
236 |
| } |
|
237 |
| } |
|
238 |
| catch(FileMovedException fme) { } |
|
239 |
| |
|
240 |
17
| LinkedList<OpenDefinitionsDocument> lod = new LinkedList<OpenDefinitionsDocument>();
|
|
241 |
17
| lod.add(doc);
|
|
242 |
17
| junitOpenDefDocs(lod, false);
|
|
243 |
17
| debug.logEnd("junit(doc)");
|
|
244 |
| } |
|
245 |
| |
|
246 |
| |
|
247 |
| |
|
248 |
19
| private void junitOpenDefDocs(final List<OpenDefinitionsDocument> lod, final boolean allTests) {
|
|
249 |
| |
|
250 |
| |
|
251 |
| |
|
252 |
| |
|
253 |
| |
|
254 |
0
| if (_testInProgress) return;
|
|
255 |
| |
|
256 |
| |
|
257 |
19
| _junitErrorModel = new JUnitErrorModel(new JUnitError[0], null, false);
|
|
258 |
| |
|
259 |
| |
|
260 |
19
| final List<OpenDefinitionsDocument> outOfSync = _model.getOutOfSyncDocuments(lod);
|
|
261 |
19
| if ((outOfSync.size() > 0) || _model.hasModifiedDocuments(lod)) {
|
|
262 |
| |
|
263 |
| |
|
264 |
| |
|
265 |
| |
|
266 |
3
| CompilerListener testAfterCompile = new DummyCompilerListener() {
|
|
267 |
0
| @Override public void compileAborted(Exception e) {
|
|
268 |
| |
|
269 |
| |
|
270 |
0
| final CompilerListener listenerThis = this;
|
|
271 |
0
| try {
|
|
272 |
0
| nonTestCase(allTests, false);
|
|
273 |
| } |
|
274 |
| finally { |
|
275 |
0
| EventQueue.invokeLater(new Runnable() {
|
|
276 |
0
| public void run() { _compilerModel.removeListener(listenerThis); }
|
|
277 |
| }); |
|
278 |
| } |
|
279 |
| } |
|
280 |
| |
|
281 |
3
| @Override public void compileEnded(File workDir, List<? extends File> excludedFiles) {
|
|
282 |
3
| final CompilerListener listenerThis = this;
|
|
283 |
3
| try {
|
|
284 |
3
| if (_model.hasOutOfSyncDocuments(lod) || _model.getNumCompErrors() > 0) {
|
|
285 |
1
| nonTestCase(allTests, _model.getNumCompErrors() > 0);
|
|
286 |
1
| return;
|
|
287 |
| } |
|
288 |
2
| EventQueue.invokeLater(new Runnable() {
|
|
289 |
2
| public void run() { _rawJUnitOpenDefDocs(lod, allTests); }
|
|
290 |
| }); |
|
291 |
| } |
|
292 |
| finally { |
|
293 |
3
| EventQueue.invokeLater(new Runnable() {
|
|
294 |
3
| public void run() { _compilerModel.removeListener(listenerThis); }
|
|
295 |
| }); |
|
296 |
| } |
|
297 |
| } |
|
298 |
| }; |
|
299 |
| |
|
300 |
| |
|
301 |
3
| _testInProgress = true;
|
|
302 |
3
| _notifyCompileBeforeJUnit(testAfterCompile, outOfSync);
|
|
303 |
3
| _testInProgress = false;
|
|
304 |
| } |
|
305 |
| |
|
306 |
16
| else _rawJUnitOpenDefDocs(lod, allTests);
|
|
307 |
| } |
|
308 |
| |
|
309 |
| |
|
310 |
| |
|
311 |
| |
|
312 |
| |
|
313 |
18
| private void _rawJUnitOpenDefDocs(List<OpenDefinitionsDocument> lod, final boolean allTests) {
|
|
314 |
18
| File buildDir = _model.getBuildDirectory();
|
|
315 |
| |
|
316 |
| |
|
317 |
| |
|
318 |
18
| HashSet<String> openDocFiles = new HashSet<String>();
|
|
319 |
| |
|
320 |
| |
|
321 |
| |
|
322 |
| |
|
323 |
18
| HashMap<File, File> classDirsAndRoots = new HashMap<File, File>();
|
|
324 |
| |
|
325 |
| |
|
326 |
| |
|
327 |
| |
|
328 |
18
| for (OpenDefinitionsDocument doc: lod) {
|
|
329 |
20
| if (doc.isSourceFile()) {
|
|
330 |
18
| try {
|
|
331 |
| |
|
332 |
18
| File sourceRoot = doc.getSourceRoot();
|
|
333 |
| |
|
334 |
| |
|
335 |
18
| openDocFiles.add(doc.getCanonicalPath());
|
|
336 |
| |
|
337 |
18
| String packagePath = doc.getPackageName().replace('.', File.separatorChar);
|
|
338 |
| |
|
339 |
| |
|
340 |
| |
|
341 |
18
| File buildRoot = (buildDir == FileOps.NULL_FILE) ? sourceRoot: buildDir;
|
|
342 |
| |
|
343 |
18
| File classFileDir = new File(IOUtil.attemptCanonicalFile(buildRoot), packagePath);
|
|
344 |
| |
|
345 |
18
| File sourceDir =
|
|
346 |
18
| (buildDir == FileOps.NULL_FILE) ? classFileDir :
|
|
347 |
| new File(IOUtil.attemptCanonicalFile(sourceRoot), packagePath); |
|
348 |
| |
|
349 |
18
| if (! classDirsAndRoots.containsKey(classFileDir)) {
|
|
350 |
18
| classDirsAndRoots.put(classFileDir, sourceDir);
|
|
351 |
| |
|
352 |
| |
|
353 |
| } |
|
354 |
| } |
|
355 |
| catch (InvalidPackageException e) { } |
|
356 |
| } |
|
357 |
| } |
|
358 |
| |
|
359 |
| |
|
360 |
| |
|
361 |
| |
|
362 |
18
| Set<File> classDirs = classDirsAndRoots.keySet();
|
|
363 |
| |
|
364 |
| |
|
365 |
| |
|
366 |
| |
|
367 |
18
| final ArrayList<String> classNames = new ArrayList<String>();
|
|
368 |
| |
|
369 |
| |
|
370 |
18
| final ArrayList<File> files = new ArrayList<File>();
|
|
371 |
| |
|
372 |
| |
|
373 |
18
| boolean isProject = _model.isProjectActive();
|
|
374 |
| |
|
375 |
18
| try {
|
|
376 |
18
| for (File dir: classDirs) {
|
|
377 |
| |
|
378 |
| |
|
379 |
18
| File[] listing = dir.listFiles();
|
|
380 |
| |
|
381 |
| |
|
382 |
| |
|
383 |
18
| if (listing != null) {
|
|
384 |
18
| for (File entry : listing) {
|
|
385 |
| |
|
386 |
| |
|
387 |
| |
|
388 |
| |
|
389 |
46
| String name = entry.getName();
|
|
390 |
23
| if (! name.endsWith(".class")) continue;
|
|
391 |
| |
|
392 |
| |
|
393 |
23
| if (_forceTestSuffix) {
|
|
394 |
0
| String noExtName = name.substring(0, name.length() - 6);
|
|
395 |
0
| int indexOfLastDot = noExtName.lastIndexOf('.');
|
|
396 |
0
| String simpleClassName = noExtName.substring(indexOfLastDot + 1);
|
|
397 |
| |
|
398 |
0
| if ( ! simpleClassName.endsWith("Test")) continue;
|
|
399 |
| } |
|
400 |
| |
|
401 |
| |
|
402 |
| |
|
403 |
| |
|
404 |
0
| if (! entry.isFile()) continue;
|
|
405 |
| |
|
406 |
| |
|
407 |
| |
|
408 |
| |
|
409 |
23
| try {
|
|
410 |
23
| final Box<String> className = new SimpleBox<String>();
|
|
411 |
23
| final Box<String> sourceName = new SimpleBox<String>();
|
|
412 |
23
| new ClassReader(IOUtil.toByteArray(entry)).accept(new ClassVisitor() {
|
|
413 |
23
| public void visit(int version, int access, String name, String sig, String sup, String[] inters) {
|
|
414 |
23
| className.set(name.replace('/', '.'));
|
|
415 |
| } |
|
416 |
23
| public void visitSource(String source, String debug) {
|
|
417 |
23
| sourceName.set(source);
|
|
418 |
| } |
|
419 |
0
| public void visitOuterClass(String owner, String name, String desc) { }
|
|
420 |
0
| public AnnotationVisitor visitAnnotation(String desc, boolean visible) { return null; }
|
|
421 |
0
| public void visitAttribute(Attribute attr) { }
|
|
422 |
0
| public void visitInnerClass(String name, String out, String in, int access) { }
|
|
423 |
0
| public FieldVisitor visitField(int a, String n, String d, String s, Object v) { return null; }
|
|
424 |
67
| public MethodVisitor visitMethod(int a, String n, String d, String s, String[] e) { return null; }
|
|
425 |
23
| public void visitEnd() { }
|
|
426 |
| }, 0); |
|
427 |
| |
|
428 |
23
| File rootDir = classDirsAndRoots.get(dir);
|
|
429 |
| |
|
430 |
| |
|
431 |
23
| String javaSourceFileName = getCanonicalPath(rootDir) + File.separator + sourceName.value();
|
|
432 |
| |
|
433 |
| |
|
434 |
| |
|
435 |
23
| int indexOfExtDot = javaSourceFileName.lastIndexOf('.');
|
|
436 |
| |
|
437 |
0
| if (indexOfExtDot == -1) continue;
|
|
438 |
| |
|
439 |
| |
|
440 |
| |
|
441 |
23
| String strippedName = javaSourceFileName.substring(0, indexOfExtDot);
|
|
442 |
| |
|
443 |
| |
|
444 |
23
| String sourceFileName;
|
|
445 |
| |
|
446 |
20
| if (openDocFiles.contains(javaSourceFileName)) sourceFileName = javaSourceFileName;
|
|
447 |
3
| else if (openDocFiles.contains(strippedName + OptionConstants.DJ_FILE_EXTENSION))
|
|
448 |
0
| sourceFileName = strippedName + OptionConstants.DJ_FILE_EXTENSION;
|
|
449 |
3
| else if (openDocFiles.contains(strippedName + OptionConstants.OLD_DJ0_FILE_EXTENSION))
|
|
450 |
0
| sourceFileName = strippedName + OptionConstants.OLD_DJ0_FILE_EXTENSION;
|
|
451 |
3
| else if (openDocFiles.contains(strippedName + OptionConstants.OLD_DJ1_FILE_EXTENSION))
|
|
452 |
0
| sourceFileName = strippedName + OptionConstants.OLD_DJ1_FILE_EXTENSION;
|
|
453 |
3
| else if (openDocFiles.contains(strippedName + OptionConstants.OLD_DJ2_FILE_EXTENSION))
|
|
454 |
0
| sourceFileName = strippedName + OptionConstants.OLD_DJ2_FILE_EXTENSION;
|
|
455 |
3
| else continue;
|
|
456 |
| |
|
457 |
20
| File sourceFile = new File(sourceFileName);
|
|
458 |
20
| classNames.add(className.value());
|
|
459 |
20
| files.add(sourceFile);
|
|
460 |
| |
|
461 |
| |
|
462 |
| } |
|
463 |
| catch(IOException e) { } |
|
464 |
| } |
|
465 |
| } |
|
466 |
| } |
|
467 |
| } |
|
468 |
| catch(Exception e) { |
|
469 |
| |
|
470 |
0
| throw new UnexpectedException(e);
|
|
471 |
| } |
|
472 |
| |
|
473 |
| |
|
474 |
18
| _testInProgress = true;
|
|
475 |
| |
|
476 |
18
| new Thread(new Runnable() {
|
|
477 |
18
| public void run() {
|
|
478 |
| |
|
479 |
| |
|
480 |
| |
|
481 |
| |
|
482 |
| |
|
483 |
| |
|
484 |
| |
|
485 |
| |
|
486 |
| |
|
487 |
| |
|
488 |
18
| synchronized(_compilerModel.getCompilerLock()) {
|
|
489 |
| |
|
490 |
| |
|
491 |
18
| List<String> tests = _jvm.findTestClasses(classNames, files).unwrap(null);
|
|
492 |
| |
|
493 |
18
| if (tests == null || tests.isEmpty()) {
|
|
494 |
2
| nonTestCase(allTests, false);
|
|
495 |
2
| return;
|
|
496 |
| } |
|
497 |
| } |
|
498 |
| |
|
499 |
16
| try {
|
|
500 |
| |
|
501 |
| |
|
502 |
16
| _notifyJUnitStarted();
|
|
503 |
16
| boolean testsPresent = _jvm.runTestSuite();
|
|
504 |
1
| if (! testsPresent) throw new RemoteException("No unit test classes were passed to the slave JVM");
|
|
505 |
| } |
|
506 |
| catch(RemoteException e) { |
|
507 |
1
| _notifyJUnitEnded();
|
|
508 |
1
| _testInProgress = false;
|
|
509 |
| } |
|
510 |
| } |
|
511 |
| }).start(); |
|
512 |
| } |
|
513 |
| |
|
514 |
| |
|
515 |
| |
|
516 |
| |
|
517 |
16
| private void _notifyJUnitStarted() {
|
|
518 |
| |
|
519 |
16
| EventQueue.invokeLater(new Runnable() { public void run() { _notifier.junitStarted(); } });
|
|
520 |
| } |
|
521 |
| |
|
522 |
| |
|
523 |
16
| private void _notifyJUnitEnded() {
|
|
524 |
| |
|
525 |
16
| EventQueue.invokeLater(new Runnable() { public void run() { _notifier.junitEnded(); } });
|
|
526 |
| } |
|
527 |
| |
|
528 |
| |
|
529 |
3
| private void _notifyCompileBeforeJUnit(final CompilerListener testAfterCompile,
|
|
530 |
| final List<OpenDefinitionsDocument> outOfSync) { |
|
531 |
3
| Utilities.invokeLater(new Runnable() {
|
|
532 |
3
| public void run() { _notifier.compileBeforeJUnit(testAfterCompile, outOfSync); }
|
|
533 |
| }); |
|
534 |
| } |
|
535 |
| |
|
536 |
| |
|
537 |
3
| private void _notifyNonTestCase(final boolean testAll, final boolean didCompileFail) {
|
|
538 |
3
| Utilities.invokeLater(new Runnable() { public void run() { _notifier.nonTestCase(testAll, didCompileFail); } });
|
|
539 |
| } |
|
540 |
| |
|
541 |
23
| private String getCanonicalPath(File f) throws IOException {
|
|
542 |
0
| if (f == null) return "";
|
|
543 |
23
| return f.getCanonicalPath();
|
|
544 |
| } |
|
545 |
| |
|
546 |
| |
|
547 |
| |
|
548 |
| |
|
549 |
55
| public JUnitErrorModel getJUnitErrorModel() { return _junitErrorModel; }
|
|
550 |
| |
|
551 |
| |
|
552 |
4
| public void resetJUnitErrors() { _junitErrorModel = new JUnitErrorModel(new JUnitError[0], _model, false); }
|
|
553 |
| |
|
554 |
| |
|
555 |
| |
|
556 |
| |
|
557 |
| |
|
558 |
| |
|
559 |
| |
|
560 |
3
| public void nonTestCase(final boolean isTestAll, boolean didCompileFail) {
|
|
561 |
| |
|
562 |
| |
|
563 |
| |
|
564 |
3
| _notifyNonTestCase(isTestAll, didCompileFail);
|
|
565 |
3
| _testInProgress = false;
|
|
566 |
| } |
|
567 |
| |
|
568 |
| |
|
569 |
| |
|
570 |
| |
|
571 |
0
| public void classFileError(final ClassFileError e) {
|
|
572 |
0
| Utilities.invokeLater(new Runnable() { public void run() {_notifier.classFileError(e); } });
|
|
573 |
| } |
|
574 |
| |
|
575 |
| |
|
576 |
| |
|
577 |
| |
|
578 |
16
| public void testSuiteStarted(final int numTests) {
|
|
579 |
16
| Utilities.invokeLater(new Runnable() { public void run() { _notifier.junitSuiteStarted(numTests); } });
|
|
580 |
| } |
|
581 |
| |
|
582 |
| |
|
583 |
| |
|
584 |
| |
|
585 |
25
| public void testStarted(final String testName) {
|
|
586 |
25
| Utilities.invokeLater(new Runnable() { public void run() { _notifier.junitTestStarted(testName); } });
|
|
587 |
| } |
|
588 |
| |
|
589 |
| |
|
590 |
| |
|
591 |
| |
|
592 |
| |
|
593 |
| |
|
594 |
24
| public void testEnded(final String testName, final boolean wasSuccessful, final boolean causedError) {
|
|
595 |
24
| EventQueue.invokeLater(new Runnable() {
|
|
596 |
24
| public void run() { _notifier.junitTestEnded(testName, wasSuccessful, causedError); }
|
|
597 |
| }); |
|
598 |
| } |
|
599 |
| |
|
600 |
| |
|
601 |
| |
|
602 |
| |
|
603 |
15
| public void testSuiteEnded(final JUnitError[] errors) {
|
|
604 |
| |
|
605 |
15
| Utilities.invokeLater(new Runnable() { public void run() {
|
|
606 |
15
| List<File> files = new ArrayList<File>();
|
|
607 |
0
| for(OpenDefinitionsDocument odd: _model.getLLOpenDefinitionsDocuments()) { files.add(odd.getRawFile()); }
|
|
608 |
| |
|
609 |
15
| for(JUnitError e: errors){
|
|
610 |
13
| try {
|
|
611 |
13
| e.setStackTrace(_compilerModel.getLLSTM().replaceStackTrace(e.stackTrace(),files));
|
|
612 |
0
| } catch(Exception ex) { DrJavaErrorHandler.record(ex); }
|
|
613 |
13
| File f = e.file();
|
|
614 |
13
| if ((f != null) && (DrJavaFileUtils.isLLFile(f))) {
|
|
615 |
0
| String dn = DrJavaFileUtils.getJavaForLLFile(f.getName());
|
|
616 |
0
| StackTraceElement ste = new StackTraceElement(e.className(), "", dn, e.lineNumber());
|
|
617 |
0
| ste = _compilerModel.getLLSTM().replaceStackTraceElement(ste, f);
|
|
618 |
0
| e.setLineNumber(ste.getLineNumber());
|
|
619 |
| } |
|
620 |
| } |
|
621 |
15
| _junitErrorModel = new JUnitErrorModel(errors, _model, true);
|
|
622 |
15
| _notifyJUnitEnded();
|
|
623 |
15
| _testInProgress = false;
|
|
624 |
| |
|
625 |
| }}); |
|
626 |
| } |
|
627 |
| |
|
628 |
| |
|
629 |
| |
|
630 |
| |
|
631 |
| |
|
632 |
| |
|
633 |
4
| public File getFileForClassName(String className) {
|
|
634 |
| |
|
635 |
4
| return _model.getSourceFile(className + OptionConstants.JAVA_FILE_EXTENSION);
|
|
636 |
| } |
|
637 |
| |
|
638 |
| |
|
639 |
0
| public Iterable<File> getClassPath() { return _jvm.getClassPath().unwrap(IterUtil.<File>empty()); }
|
|
640 |
| |
|
641 |
| |
|
642 |
177
| public void junitJVMReady() {
|
|
643 |
177
| Utilities.invokeLater(new Runnable() { public void run() {
|
|
644 |
177
| if (! _testInProgress) return;
|
|
645 |
| |
|
646 |
0
| JUnitError[] errors = new JUnitError[1];
|
|
647 |
0
| errors[0] = new JUnitError("Previous test suite was interrupted", true, "");
|
|
648 |
0
| _junitErrorModel = new JUnitErrorModel(errors, _model, true);
|
|
649 |
0
| _notifyJUnitEnded();
|
|
650 |
0
| _testInProgress = false;
|
|
651 |
| }}); |
|
652 |
| } |
|
653 |
| } |