mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Add option to suppress decoding stack when running JUnit tests
This commit is contained in:
parent
b018e61615
commit
1c09a52ef9
|
@ -43,7 +43,7 @@ install:
|
|||
- rm -rf tools/idea/idea-artifacts/dependencies
|
||||
|
||||
script:
|
||||
- $MVN_CMD -e install -Dteavm.junit.optimized=false -P with-idea -P with-cli -Dteavm.junit.js.runner=none -V
|
||||
- $MVN_CMD -e install -Dteavm.junit.optimized=false -Dteavm.junit.js.decodeStack=false -P with-idea -P with-cli -Dteavm.junit.js.runner=none -V
|
||||
- BASE_PATH=`pwd`
|
||||
- pushd tests/src/test/js
|
||||
- "export DISPLAY=:99.0"
|
||||
|
|
|
@ -67,8 +67,9 @@ class HtmlUnitRunStrategy implements TestRunStrategy {
|
|||
Object[] args = new Object[] { new NativeJavaObject(function, asyncResult, AsyncResult.class) };
|
||||
page.get().executeJavaScriptFunctionIfPossible(function, function, args, page.get());
|
||||
|
||||
RhinoResultParser.parseResult((Scriptable) asyncResult.getResult(), run.getCallback(),
|
||||
new File(run.getBaseDirectory(), run.getFileName() + ".teavmdbg"));
|
||||
boolean decodeStack = Boolean.parseBoolean(System.getProperty(TeaVMTestRunner.JS_DECODE_STACK, "true"));
|
||||
File debugFile = decodeStack ? new File(run.getBaseDirectory(), run.getFileName() + ".teavmdbg") : null;
|
||||
RhinoResultParser.parseResult((Scriptable) asyncResult.getResult(), run.getCallback(), debugFile);
|
||||
}
|
||||
|
||||
private void cleanUp() {
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -50,21 +51,30 @@ final class RhinoResultParser {
|
|||
callback.complete();
|
||||
break;
|
||||
case "exception": {
|
||||
DebugInformation debugInformation = getDebugInformation(debugFile);
|
||||
DebugInformation debugInformation = debugFile != null ? getDebugInformation(debugFile) : null;
|
||||
|
||||
String className = String.valueOf(result.get("className", result));
|
||||
if (debugInformation != null) {
|
||||
String decodedName = debugInformation.getClassNameByJsName(className);
|
||||
if (decodedName != null) {
|
||||
className = decodedName;
|
||||
}
|
||||
}
|
||||
String message = String.valueOf(result.get("message", result));
|
||||
|
||||
String stack = result.get("stack", result).toString();
|
||||
StackTraceElement[] decodedStack = null;
|
||||
if (debugInformation != null) {
|
||||
String[] script = getScript(new File(debugFile.getParentFile(),
|
||||
debugFile.getName().substring(0, debugFile.getName().length() - 9)));
|
||||
StackTraceElement[] decodedStack = decodeStack(stack, script, debugInformation);
|
||||
if (decodedStack != null) {
|
||||
List<StackTraceElement> elements = new ArrayList<>();
|
||||
elements.addAll(Arrays.asList(decodeStack(stack, script, debugInformation)));
|
||||
List<StackTraceElement> currentElements = Arrays.asList(Thread.currentThread().getStackTrace());
|
||||
elements.addAll(currentElements.subList(2, currentElements.size()));
|
||||
decodedStack = elements.toArray(new StackTraceElement[0]);
|
||||
stack = "";
|
||||
} else {
|
||||
stack = "\n" + stack;
|
||||
}
|
||||
|
||||
Throwable e;
|
||||
|
@ -73,7 +83,9 @@ final class RhinoResultParser {
|
|||
} else {
|
||||
e = new RuntimeException(className + ": " + message + stack);
|
||||
}
|
||||
if (decodedStack != null) {
|
||||
e.setStackTrace(decodedStack);
|
||||
}
|
||||
callback.error(e);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ public class TeaVMTestRunner extends Runner implements Filterable {
|
|||
private static final String JS_RUNNER = "teavm.junit.js.runner";
|
||||
private static final String THREAD_COUNT = "teavm.junit.js.threads";
|
||||
private static final String JS_ENABLED = "teavm.junit.js";
|
||||
static final String JS_DECODE_STACK = "teavm.junit.js.decodeStack";
|
||||
private static final String C_ENABLED = "teavm.junit.c";
|
||||
private static final String WASM_ENABLED = "teavm.junit.wasm";
|
||||
private static final String C_COMPILER = "teavm.junit.c.compiler";
|
||||
|
@ -552,13 +553,18 @@ public class TeaVMTestRunner extends Runner implements Filterable {
|
|||
|
||||
private CompileResult compileToJs(Method method, TeaVMTestConfiguration<JavaScriptTarget> configuration,
|
||||
File path) {
|
||||
boolean decodeStack = Boolean.parseBoolean(System.getProperty(JS_DECODE_STACK, "true"));
|
||||
DebugInformationBuilder debugEmitter = new DebugInformationBuilder();
|
||||
Supplier<JavaScriptTarget> targetSupplier = () -> {
|
||||
JavaScriptTarget target = new JavaScriptTarget();
|
||||
if (decodeStack) {
|
||||
target.setDebugEmitter(debugEmitter);
|
||||
}
|
||||
return target;
|
||||
};
|
||||
CompilePostProcessor postBuild = (vm, file) -> {
|
||||
CompilePostProcessor postBuild = null;
|
||||
if (decodeStack) {
|
||||
postBuild = (vm, file) -> {
|
||||
DebugInformation debugInfo = debugEmitter.getDebugInformation();
|
||||
File sourceMapsFile = new File(file.getPath() + ".map");
|
||||
File debugFile = new File(file.getPath() + ".teavmdbg");
|
||||
|
@ -579,6 +585,7 @@ public class TeaVMTestRunner extends Runner implements Filterable {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
return compileTest(method, configuration, targetSupplier, TestEntryPoint.class.getName(), path, ".js",
|
||||
postBuild);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user