Fix running multi-configuration tests in HTMLUnit

This commit is contained in:
Alexey Andreev 2017-11-05 14:53:08 +03:00
parent 2a07e67423
commit d3134d3941
4 changed files with 15 additions and 9 deletions

View File

@ -59,7 +59,7 @@ class HtmlUnitRunStrategy implements TestRunStrategy {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
page.get().executeJavaScript(readFile(new File(run.getBaseDirectory(), "runtime.js"))); page.get().executeJavaScript(readFile(new File(run.getBaseDirectory(), "runtime.js")));
page.get().executeJavaScript(readFile(new File(run.getBaseDirectory(), "test.js"))); page.get().executeJavaScript(readFile(new File(run.getBaseDirectory(), run.getFileName())));
AsyncResult asyncResult = new AsyncResult(); AsyncResult asyncResult = new AsyncResult();
Function function = (Function) page.get().executeJavaScript(readResource("teavm-htmlunit-adapter.js")) Function function = (Function) page.get().executeJavaScript(readResource("teavm-htmlunit-adapter.js"))

View File

@ -32,7 +32,6 @@ class SeleniumRunStrategy implements TestRunStrategy {
private URL url; private URL url;
private ThreadLocal<WebDriver> webDriver = new ThreadLocal<>(); private ThreadLocal<WebDriver> webDriver = new ThreadLocal<>();
private ThreadLocal<Integer> commandsSent = new ThreadLocal<>(); private ThreadLocal<Integer> commandsSent = new ThreadLocal<>();
private int rebootRate = Integer.getInteger("teavm.junit.js.selenium.rebootAfter", 1000);
public SeleniumRunStrategy(URL url) { public SeleniumRunStrategy(URL url) {
this.url = url; this.url = url;
@ -68,7 +67,7 @@ class SeleniumRunStrategy implements TestRunStrategy {
return (String) js.executeAsyncScript( return (String) js.executeAsyncScript(
readResource("teavm-selenium.js"), readResource("teavm-selenium.js"),
readFile(new File(run.getBaseDirectory(), "runtime.js")), readFile(new File(run.getBaseDirectory(), "runtime.js")),
readFile(new File(run.getBaseDirectory(), "test.js")), readFile(new File(run.getBaseDirectory(), run.getFileName())),
readResource("teavm-selenium-adapter.js")); readResource("teavm-selenium-adapter.js"));
} catch (Throwable e) { } catch (Throwable e) {
run.getCallback().error(e); run.getCallback().error(e);

View File

@ -332,7 +332,7 @@ public class TeaVMTestRunner extends Runner implements Filterable {
return new TestRun(compileResult.file.getParentFile(), child, return new TestRun(compileResult.file.getParentFile(), child,
new MethodReference(testClass.getName(), getDescriptor(child)), new MethodReference(testClass.getName(), getDescriptor(child)),
description, callback); description, compileResult.file.getName(), callback);
} }
private void submitRun(TestRun run) { private void submitRun(TestRun run) {
@ -402,6 +402,11 @@ public class TeaVMTestRunner extends Runner implements Filterable {
.setClassLoader(classLoader) .setClassLoader(classLoader)
.setClassSource(classSource) .setClassSource(classSource)
.build(); .build();
Properties properties = new Properties();
applyProperties(method.getDeclaringClass(), properties);
vm.setProperties(properties);
vm.setIncremental(false); vm.setIncremental(false);
configuration.apply(vm); configuration.apply(vm);
vm.installPlugins(); vm.installPlugins();
@ -409,10 +414,6 @@ public class TeaVMTestRunner extends Runner implements Filterable {
new TestExceptionPlugin().install(vm); new TestExceptionPlugin().install(vm);
new TestEntryPointTransformer(runnerType.getName(), methodHolder.getReference()).install(vm); new TestEntryPointTransformer(runnerType.getName(), methodHolder.getReference()).install(vm);
Properties properties = new Properties();
applyProperties(method.getDeclaringClass(), properties);
vm.setProperties(properties);
MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException", MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException",
Throwable.class, String.class); Throwable.class, String.class);
vm.entryPoint("runTest", new MethodReference(TestEntryPoint.class, "run", void.class)).async(); vm.entryPoint("runTest", new MethodReference(TestEntryPoint.class, "run", void.class)).async();

View File

@ -26,14 +26,16 @@ class TestRun {
private MethodReference reference; private MethodReference reference;
private Description description; private Description description;
private TestRunCallback callback; private TestRunCallback callback;
private String fileName;
TestRun(File baseDirectory, Method method, MethodReference reference, Description description, TestRun(File baseDirectory, Method method, MethodReference reference, Description description, String fileName,
TestRunCallback callback) { TestRunCallback callback) {
this.baseDirectory = baseDirectory; this.baseDirectory = baseDirectory;
this.method = method; this.method = method;
this.reference = reference; this.reference = reference;
this.description = description; this.description = description;
this.callback = callback; this.callback = callback;
this.fileName = fileName;
} }
public File getBaseDirectory() { public File getBaseDirectory() {
@ -55,4 +57,8 @@ class TestRun {
public TestRunCallback getCallback() { public TestRunCallback getCallback() {
return callback; return callback;
} }
public String getFileName() {
return fileName;
}
} }