|
4 | 4 | import fi.helsinki.cs.tmc.core.domain.Exercise;
|
5 | 5 | import fi.helsinki.cs.tmc.core.domain.ProgressObserver;
|
6 | 6 | import fi.helsinki.cs.tmc.data.ResultCollector;
|
| 7 | +import fi.helsinki.cs.tmc.langs.abstraction.ValidationResult; |
| 8 | +import fi.helsinki.cs.tmc.langs.domain.RunResult; |
7 | 9 | import fi.helsinki.cs.tmc.model.CourseDb;
|
8 | 10 | import fi.helsinki.cs.tmc.model.ProjectMediator;
|
| 11 | +import fi.helsinki.cs.tmc.model.TmcProjectInfo; |
| 12 | +import fi.helsinki.cs.tmc.utilities.AggregatingBgTaskListener; |
| 13 | +import fi.helsinki.cs.tmc.utilities.BgTask; |
| 14 | +import fi.helsinki.cs.tmc.utilities.BgTaskListener; |
9 | 15 |
|
| 16 | +import java.util.List; |
| 17 | +import java.util.logging.Level; |
10 | 18 | import java.util.logging.Logger;
|
11 | 19 | import org.netbeans.api.project.Project;
|
12 | 20 | import org.openide.nodes.Node;
|
@@ -70,14 +78,42 @@ protected boolean enabledFor(Exercise exercise) {
|
70 | 78 | @Override
|
71 | 79 | public void run() {
|
72 | 80 | Exercise exercise = exerciseForProject(project);
|
| 81 | + final ResultCollector resultCollector = new ResultCollector(exercise); |
| 82 | + |
73 | 83 | if (exercise != null) {
|
74 |
| - try { |
75 |
| - ResultCollector resultCollector = new ResultCollector(exercise); |
76 |
| - resultCollector.setLocalTestResults(TmcCore.get().runTests(ProgressObserver.NULL_OBSERVER, exercise).call()); |
77 |
| - resultCollector.setValidationResult(TmcCore.get().runCheckStyle(ProgressObserver.NULL_OBSERVER, exercise).call()); |
78 |
| - } catch (Exception ex) { |
79 |
| - Exceptions.printStackTrace(ex); |
80 |
| - } |
| 84 | + BgTask.start("Running tests for " + exercise.getName(), TmcCore.get().runTests(ProgressObserver.NULL_OBSERVER, exercise), new BgTaskListener<RunResult>() { |
| 85 | + @Override |
| 86 | + public void bgTaskReady(RunResult result) { |
| 87 | + resultCollector.setLocalTestResults(result); |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public void bgTaskCancelled() { |
| 92 | + // NOP |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public void bgTaskFailed(Throwable ex) { |
| 97 | + log.log(Level.WARNING, "Test run failed:", ex); |
| 98 | + } |
| 99 | + }); |
81 | 100 | }
|
| 101 | + |
| 102 | + BgTask.start("Running code style validations", TmcCore.get().runCheckStyle(ProgressObserver.NULL_OBSERVER, exercise), new BgTaskListener<ValidationResult>() { |
| 103 | + @Override |
| 104 | + public void bgTaskReady(ValidationResult result) { |
| 105 | + resultCollector.setValidationResult(result); |
| 106 | + } |
| 107 | + |
| 108 | + @Override |
| 109 | + public void bgTaskCancelled() { |
| 110 | + // NOP |
| 111 | + } |
| 112 | + |
| 113 | + @Override |
| 114 | + public void bgTaskFailed(Throwable ex) { |
| 115 | + log.log(Level.WARNING, "Code style run failed:", ex); |
| 116 | + } |
| 117 | + }); |
82 | 118 | }
|
83 | 119 | }
|
0 commit comments