prepare also script engines which currently are skipped

This commit is contained in:
Volker Berlin 2019-09-08 19:10:31 +02:00
parent 4e3c11553f
commit c5d514de73
2 changed files with 55 additions and 24 deletions

View File

@ -122,6 +122,24 @@ public class WasmRule extends TemporaryFolder {
}
}
/**
* Prepare the rule for the script engine
*
* @param script
* the script engine
* @throws Exception
* if any error occur
*/
public void before( ScriptEngine script ) throws Exception {
switch( script ) {
case Wat2Wasm:
// this is already part of execute and not only a compile
return;
default:
createCommand( script );
}
}
/**
* Write the test data as JSON file.
*
@ -370,6 +388,36 @@ public class WasmRule extends TemporaryFolder {
}
}
/**
* Compile the sources and create the ProcessBuilder
*
* @param script
* The script engine
* @return ProcessBuilder to execute the test
* @throws Exception
* if any error occur
*/
private ProcessBuilder createCommand( ScriptEngine script ) throws Exception {
switch( script ) {
case SpiderMonkey:
return spiderMonkeyCommand( true, false );
case SpiderMonkeyWat:
return spiderMonkeyCommand( false, false );
case SpiderMonkeyGC:
return spiderMonkeyCommand( true, true );
case NodeJS:
return nodeJsCommand( nodeScript );
case NodeWat:
prepareNodeWat();
return nodeJsCommand( nodeWatScript );
case Wat2Wasm:
prepareWat2Wasm();
return nodeJsCommand( wat2WasmScript );
default:
throw new IllegalStateException( script.toString() );
}
}
/**
* Evaluate the wasm exported function.
*
@ -395,30 +443,7 @@ public class WasmRule extends TemporaryFolder {
writeJsonTestData( Collections.singletonMap( methodName, params ) );
}
switch( script ) {
case SpiderMonkey:
processBuilder = spiderMonkeyCommand( true, false );
break;
case SpiderMonkeyWat:
processBuilder = spiderMonkeyCommand( false, false );
break;
case SpiderMonkeyGC:
processBuilder = spiderMonkeyCommand( true, true );
break;
case NodeJS:
processBuilder = nodeJsCommand( nodeScript );
break;
case NodeWat:
prepareNodeWat();
processBuilder = nodeJsCommand( nodeWatScript );
break;
case Wat2Wasm:
prepareWat2Wasm();
processBuilder = nodeJsCommand( wat2WasmScript );
break;
default:
throw new IllegalStateException( script.toString() );
}
processBuilder = createCommand( script );
processBuilder.directory( getRoot() );
Process process = processBuilder.start();
String result = readStream( process.getInputStream() ).trim();

View File

@ -17,6 +17,7 @@ package de.inetsoftware.jwebassembly.runtime;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -66,6 +67,11 @@ public abstract class AbstractBaseTest {
return method;
}
@Before
public void before() throws Exception {
wasm.before( script );
}
@Test
public void test() {
wasm.test( script, method, params );