|
26 | 26 |
|
27 | 27 | import javax.swing.JFrame;
|
28 | 28 |
|
| 29 | +import oracle.dbtools.raptor.runner.DBStarterFactory; |
| 30 | +import oracle.ide.Context; |
| 31 | +import oracle.jdevimpl.runner.debug.DebuggingProcess; |
| 32 | +import oracle.jdevimpl.runner.run.JRunner; |
29 | 33 | import org.utplsql.sqldev.coverage.CodeCoverageReporter;
|
30 | 34 | import org.utplsql.sqldev.dal.RealtimeReporterDao;
|
31 | 35 | import org.utplsql.sqldev.dal.RealtimeReporterEventConsumer;
|
| 36 | +import org.utplsql.sqldev.exception.GenericRuntimeException; |
32 | 37 | import org.utplsql.sqldev.model.DatabaseTools;
|
33 | 38 | import org.utplsql.sqldev.model.SystemTools;
|
34 | 39 | import org.utplsql.sqldev.model.runner.PostRunEvent;
|
@@ -63,6 +68,7 @@ public class UtplsqlRunner implements RealtimeReporterEventConsumer {
|
63 | 68 | private JFrame frame; // for testing purposes only (outside of SQL Developer)
|
64 | 69 | private Thread producerThread;
|
65 | 70 | private Thread consumerThread;
|
| 71 | + private Context context; // required for debugging |
66 | 72 |
|
67 | 73 | public UtplsqlRunner(final List<String> pathList, final String connectionName) {
|
68 | 74 | this.withCodeCoverage = false;
|
@@ -121,6 +127,10 @@ private void setConnection(final String connectionName) {
|
121 | 127 | this.connectionName = connectionName;
|
122 | 128 | }
|
123 | 129 |
|
| 130 | + public void enableDebugging(Context context) { |
| 131 | + this.context = context; |
| 132 | + } |
| 133 | + |
124 | 134 | public void dispose() {
|
125 | 135 | // running in SQL Developer
|
126 | 136 | DatabaseTools.closeConnection(producerConn);
|
@@ -275,14 +285,31 @@ private void doProcess(final PostTestEvent event) {
|
275 | 285 | panel.update(realtimeReporterId);
|
276 | 286 | }
|
277 | 287 |
|
| 288 | + private void produceReportWithDebugger(String anonymousPlsqlBlock) { |
| 289 | + try { |
| 290 | + Context processContext = JRunner.prepareProcessContext(context, false); |
| 291 | + DebuggingProcess process = new DebuggingProcess(processContext); |
| 292 | + DBStarterFactory.PlSqlStarter starter = new DBStarterFactory.PlSqlStarter(process, anonymousPlsqlBlock, connectionName, context); |
| 293 | + starter.start(); |
| 294 | + } catch (Throwable t) { |
| 295 | + String msg = t.getClass().getName() + " while debugging utPLSQL test."; |
| 296 | + logger.severe(() -> msg); |
| 297 | + throw new GenericRuntimeException(msg); |
| 298 | + } |
| 299 | + } |
| 300 | + |
278 | 301 | private void produce() {
|
279 | 302 | try {
|
280 | 303 | logger.fine(() -> "Running utPLSQL tests and producing events via reporter id " + realtimeReporterId + "...");
|
281 | 304 | final RealtimeReporterDao dao = new RealtimeReporterDao(producerConn);
|
282 | 305 | if (withCodeCoverage) {
|
283 | 306 | dao.produceReportWithCoverage(realtimeReporterId, coverageReporterId, pathList, schemaList, includeObjectList, excludeObjectList);
|
284 | 307 | } else {
|
285 |
| - dao.produceReport(realtimeReporterId, pathList); |
| 308 | + if (context == null) { |
| 309 | + dao.produceReport(realtimeReporterId, pathList); |
| 310 | + } else { |
| 311 | + produceReportWithDebugger(dao.getProduceReportPlsql(realtimeReporterId, pathList)); |
| 312 | + } |
286 | 313 | }
|
287 | 314 | logger.fine(() -> "All events produced for reporter id " + realtimeReporterId + ".");
|
288 | 315 | } catch (Exception e) {
|
|
0 commit comments