Skip to content

Commit 0d49e81

Browse files
committed
separate out debug server-side into new project
1 parent 4e8c436 commit 0d49e81

15 files changed

Lines changed: 17 additions & 1666 deletions

karate-core/src/main/java/com/intuit/karate/Main.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import com.intuit.karate.core.MockServer;
2727
import com.intuit.karate.core.RuntimeHookFactory;
28-
import com.intuit.karate.debug.DapServer;
2928
import com.intuit.karate.http.HttpServer;
3029
import com.intuit.karate.http.RequestHandler;
3130
import com.intuit.karate.http.ServerConfig;
@@ -126,9 +125,6 @@ public class Main implements Callable<Void> {
126125
description = "debug mode (optional port else dynamically chosen)")
127126
int debugPort;
128127

129-
@Option(names = {"--debug-keepalive"}, defaultValue = "false", arity = "0..1", fallbackValue = "true", description = "keep debug server open for connections after disconnect")
130-
boolean keepDebugServerAlive;
131-
132128
@Option(names = {"-D", "--dryrun"}, description = "dry run, generate html reports only")
133129
boolean dryRun;
134130

@@ -200,10 +196,10 @@ public static Main parseKarateOptions(String line) {
200196
String[] args = Command.tokenize(line);
201197
return CommandLine.populateCommand(new Main(), args);
202198
}
203-
199+
204200
public static Main parseKarateArgs(List<String> args) {
205201
return CommandLine.populateCommand(new Main(), args.toArray(new String[args.size()]));
206-
}
202+
}
207203

208204
// matches ( -X XXX )* (XXX)
209205
private static final Pattern CLI_ARGS = Pattern.compile("(\\s*-{1,2}\\w\\s\\S*\\s*)*(.*)$");
@@ -322,8 +318,15 @@ public Void call() throws Exception {
322318
logger.info("deleted directory: {}", output);
323319
}
324320
if (debugPort != -1) {
325-
DapServer server = new DapServer(debugPort, !keepDebugServerAlive);
326-
server.waitSync();
321+
try {
322+
Class clazz = Class.forName("io.karatelabs.debug.Main");
323+
Method method = clazz.getMethod("main", String[].class);
324+
String[] params = new String[]{debugPort + ""};
325+
method.invoke(null, (Object) params);
326+
} catch (Exception e) {
327+
String message = "error: debug server failed, is 'karate-debugserver' added as a dependency ?";
328+
System.out.println(message);
329+
}
327330
return null;
328331
}
329332
if (paths != null) {

karate-core/src/main/java/com/intuit/karate/core/ScenarioEngine.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,12 @@ private Channel channel(String type) {
760760
} catch (KarateException ke) {
761761
throw ke;
762762
} catch (Exception e) {
763-
String message = "cannot instantiate " + type + ", is 'karate-" + type + "' included as a maven / gradle dependency ? " + e.getMessage();
763+
String message;
764+
if (e instanceof ClassNotFoundException) {
765+
message = "cannot instantiate [" + type + "], is 'karate-" + type + "' included as a maven / gradle dependency ?";
766+
} else {
767+
message = e.getMessage();
768+
}
764769
logger.error(message);
765770
throw new RuntimeException(message, e);
766771
}

karate-core/src/main/java/com/intuit/karate/debug/Breakpoint.java

Lines changed: 0 additions & 98 deletions
This file was deleted.

karate-core/src/main/java/com/intuit/karate/debug/DapClient.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

karate-core/src/main/java/com/intuit/karate/debug/DapClientHandler.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

karate-core/src/main/java/com/intuit/karate/debug/DapDecoder.java

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)