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
|
- rm -rf tools/idea/idea-artifacts/dependencies
|
||||||
|
|
||||||
script:
|
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`
|
- BASE_PATH=`pwd`
|
||||||
- pushd tests/src/test/js
|
- pushd tests/src/test/js
|
||||||
- "export DISPLAY=:99.0"
|
- "export DISPLAY=:99.0"
|
||||||
|
|
|
@ -67,8 +67,9 @@ class HtmlUnitRunStrategy implements TestRunStrategy {
|
||||||
Object[] args = new Object[] { new NativeJavaObject(function, asyncResult, AsyncResult.class) };
|
Object[] args = new Object[] { new NativeJavaObject(function, asyncResult, AsyncResult.class) };
|
||||||
page.get().executeJavaScriptFunctionIfPossible(function, function, args, page.get());
|
page.get().executeJavaScriptFunctionIfPossible(function, function, args, page.get());
|
||||||
|
|
||||||
RhinoResultParser.parseResult((Scriptable) asyncResult.getResult(), run.getCallback(),
|
boolean decodeStack = Boolean.parseBoolean(System.getProperty(TeaVMTestRunner.JS_DECODE_STACK, "true"));
|
||||||
new File(run.getBaseDirectory(), run.getFileName() + ".teavmdbg"));
|
File debugFile = decodeStack ? new File(run.getBaseDirectory(), run.getFileName() + ".teavmdbg") : null;
|
||||||
|
RhinoResultParser.parseResult((Scriptable) asyncResult.getResult(), run.getCallback(), debugFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanUp() {
|
private void cleanUp() {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -50,21 +51,30 @@ final class RhinoResultParser {
|
||||||
callback.complete();
|
callback.complete();
|
||||||
break;
|
break;
|
||||||
case "exception": {
|
case "exception": {
|
||||||
DebugInformation debugInformation = getDebugInformation(debugFile);
|
DebugInformation debugInformation = debugFile != null ? getDebugInformation(debugFile) : null;
|
||||||
|
|
||||||
String className = String.valueOf(result.get("className", result));
|
String className = String.valueOf(result.get("className", result));
|
||||||
|
if (debugInformation != null) {
|
||||||
String decodedName = debugInformation.getClassNameByJsName(className);
|
String decodedName = debugInformation.getClassNameByJsName(className);
|
||||||
if (decodedName != null) {
|
if (decodedName != null) {
|
||||||
className = decodedName;
|
className = decodedName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String message = String.valueOf(result.get("message", result));
|
String message = String.valueOf(result.get("message", result));
|
||||||
|
|
||||||
String stack = result.get("stack", result).toString();
|
String stack = result.get("stack", result).toString();
|
||||||
|
StackTraceElement[] decodedStack = null;
|
||||||
|
if (debugInformation != null) {
|
||||||
String[] script = getScript(new File(debugFile.getParentFile(),
|
String[] script = getScript(new File(debugFile.getParentFile(),
|
||||||
debugFile.getName().substring(0, debugFile.getName().length() - 9)));
|
debugFile.getName().substring(0, debugFile.getName().length() - 9)));
|
||||||
StackTraceElement[] decodedStack = decodeStack(stack, script, debugInformation);
|
List<StackTraceElement> elements = new ArrayList<>();
|
||||||
if (decodedStack != null) {
|
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 = "";
|
stack = "";
|
||||||
|
} else {
|
||||||
|
stack = "\n" + stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
Throwable e;
|
Throwable e;
|
||||||
|
@ -73,7 +83,9 @@ final class RhinoResultParser {
|
||||||
} else {
|
} else {
|
||||||
e = new RuntimeException(className + ": " + message + stack);
|
e = new RuntimeException(className + ": " + message + stack);
|
||||||
}
|
}
|
||||||
|
if (decodedStack != null) {
|
||||||
e.setStackTrace(decodedStack);
|
e.setStackTrace(decodedStack);
|
||||||
|
}
|
||||||
callback.error(e);
|
callback.error(e);
|
||||||
break;
|
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 JS_RUNNER = "teavm.junit.js.runner";
|
||||||
private static final String THREAD_COUNT = "teavm.junit.js.threads";
|
private static final String THREAD_COUNT = "teavm.junit.js.threads";
|
||||||
private static final String JS_ENABLED = "teavm.junit.js";
|
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 C_ENABLED = "teavm.junit.c";
|
||||||
private static final String WASM_ENABLED = "teavm.junit.wasm";
|
private static final String WASM_ENABLED = "teavm.junit.wasm";
|
||||||
private static final String C_COMPILER = "teavm.junit.c.compiler";
|
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,
|
private CompileResult compileToJs(Method method, TeaVMTestConfiguration<JavaScriptTarget> configuration,
|
||||||
File path) {
|
File path) {
|
||||||
|
boolean decodeStack = Boolean.parseBoolean(System.getProperty(JS_DECODE_STACK, "true"));
|
||||||
DebugInformationBuilder debugEmitter = new DebugInformationBuilder();
|
DebugInformationBuilder debugEmitter = new DebugInformationBuilder();
|
||||||
Supplier<JavaScriptTarget> targetSupplier = () -> {
|
Supplier<JavaScriptTarget> targetSupplier = () -> {
|
||||||
JavaScriptTarget target = new JavaScriptTarget();
|
JavaScriptTarget target = new JavaScriptTarget();
|
||||||
|
if (decodeStack) {
|
||||||
target.setDebugEmitter(debugEmitter);
|
target.setDebugEmitter(debugEmitter);
|
||||||
|
}
|
||||||
return target;
|
return target;
|
||||||
};
|
};
|
||||||
CompilePostProcessor postBuild = (vm, file) -> {
|
CompilePostProcessor postBuild = null;
|
||||||
|
if (decodeStack) {
|
||||||
|
postBuild = (vm, file) -> {
|
||||||
DebugInformation debugInfo = debugEmitter.getDebugInformation();
|
DebugInformation debugInfo = debugEmitter.getDebugInformation();
|
||||||
File sourceMapsFile = new File(file.getPath() + ".map");
|
File sourceMapsFile = new File(file.getPath() + ".map");
|
||||||
File debugFile = new File(file.getPath() + ".teavmdbg");
|
File debugFile = new File(file.getPath() + ".teavmdbg");
|
||||||
|
@ -579,6 +585,7 @@ public class TeaVMTestRunner extends Runner implements Filterable {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
return compileTest(method, configuration, targetSupplier, TestEntryPoint.class.getName(), path, ".js",
|
return compileTest(method, configuration, targetSupplier, TestEntryPoint.class.getName(), path, ".js",
|
||||||
postBuild);
|
postBuild);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user