Skip to content

Commit

Permalink
separate out debug server-side into new project
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Oct 10, 2023
1 parent 4e8c436 commit 0d49e81
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 1,666 deletions.
19 changes: 11 additions & 8 deletions karate-core/src/main/java/com/intuit/karate/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import com.intuit.karate.core.MockServer;
import com.intuit.karate.core.RuntimeHookFactory;
import com.intuit.karate.debug.DapServer;
import com.intuit.karate.http.HttpServer;
import com.intuit.karate.http.RequestHandler;
import com.intuit.karate.http.ServerConfig;
Expand Down Expand Up @@ -126,9 +125,6 @@ public class Main implements Callable<Void> {
description = "debug mode (optional port else dynamically chosen)")
int debugPort;

@Option(names = {"--debug-keepalive"}, defaultValue = "false", arity = "0..1", fallbackValue = "true", description = "keep debug server open for connections after disconnect")
boolean keepDebugServerAlive;

@Option(names = {"-D", "--dryrun"}, description = "dry run, generate html reports only")
boolean dryRun;

Expand Down Expand Up @@ -200,10 +196,10 @@ public static Main parseKarateOptions(String line) {
String[] args = Command.tokenize(line);
return CommandLine.populateCommand(new Main(), args);
}

public static Main parseKarateArgs(List<String> args) {
return CommandLine.populateCommand(new Main(), args.toArray(new String[args.size()]));
}
}

// matches ( -X XXX )* (XXX)
private static final Pattern CLI_ARGS = Pattern.compile("(\\s*-{1,2}\\w\\s\\S*\\s*)*(.*)$");
Expand Down Expand Up @@ -322,8 +318,15 @@ public Void call() throws Exception {
logger.info("deleted directory: {}", output);
}
if (debugPort != -1) {
DapServer server = new DapServer(debugPort, !keepDebugServerAlive);
server.waitSync();
try {
Class clazz = Class.forName("io.karatelabs.debug.Main");
Method method = clazz.getMethod("main", String[].class);
String[] params = new String[]{debugPort + ""};
method.invoke(null, (Object) params);
} catch (Exception e) {
String message = "error: debug server failed, is 'karate-debugserver' added as a dependency ?";
System.out.println(message);
}
return null;
}
if (paths != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,12 @@ private Channel channel(String type) {
} catch (KarateException ke) {
throw ke;
} catch (Exception e) {
String message = "cannot instantiate " + type + ", is 'karate-" + type + "' included as a maven / gradle dependency ? " + e.getMessage();
String message;
if (e instanceof ClassNotFoundException) {
message = "cannot instantiate [" + type + "], is 'karate-" + type + "' included as a maven / gradle dependency ?";
} else {
message = e.getMessage();
}
logger.error(message);
throw new RuntimeException(message, e);
}
Expand Down
98 changes: 0 additions & 98 deletions karate-core/src/main/java/com/intuit/karate/debug/Breakpoint.java

This file was deleted.

60 changes: 0 additions & 60 deletions karate-core/src/main/java/com/intuit/karate/debug/DapClient.java

This file was deleted.

This file was deleted.

94 changes: 0 additions & 94 deletions karate-core/src/main/java/com/intuit/karate/debug/DapDecoder.java

This file was deleted.

Loading

0 comments on commit 0d49e81

Please sign in to comment.