mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Add a test with enabled GC
This commit is contained in:
parent
6ea1955886
commit
c029c48be5
@ -27,6 +27,7 @@ public enum ScriptEngine {
|
|||||||
NodeWat,
|
NodeWat,
|
||||||
SpiderMonkeyWat,
|
SpiderMonkeyWat,
|
||||||
Wat2Wasm,
|
Wat2Wasm,
|
||||||
|
SpiderMonkeyGC,
|
||||||
;
|
;
|
||||||
|
|
||||||
public static ScriptEngine[] testEngines() {
|
public static ScriptEngine[] testEngines() {
|
||||||
|
@ -68,6 +68,8 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
|
|
||||||
private File spiderMonkeyScript;
|
private File spiderMonkeyScript;
|
||||||
|
|
||||||
|
private File spiderMonkeyScriptGC;
|
||||||
|
|
||||||
private File nodeWatScript;
|
private File nodeWatScript;
|
||||||
|
|
||||||
private File spiderMonkeyWatScript;
|
private File spiderMonkeyWatScript;
|
||||||
@ -130,7 +132,7 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
*/
|
*/
|
||||||
private void writeJsonTestData( Map<String, Object[]> data ) throws IOException {
|
private void writeJsonTestData( Map<String, Object[]> data ) throws IOException {
|
||||||
// a character we need to convert an integer
|
// a character we need to convert an integer
|
||||||
HashMap<String, Object[]> copy = new HashMap( data );
|
HashMap<String, Object[]> copy = new HashMap<>( data );
|
||||||
for( Entry<String, Object[]> entry : copy.entrySet() ) {
|
for( Entry<String, Object[]> entry : copy.entrySet() ) {
|
||||||
Object[] params = entry.getValue();
|
Object[] params = entry.getValue();
|
||||||
for( int i = 0; i < params.length; i++ ) {
|
for( int i = 0; i < params.length; i++ ) {
|
||||||
@ -395,10 +397,13 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
|
|
||||||
switch( script ) {
|
switch( script ) {
|
||||||
case SpiderMonkey:
|
case SpiderMonkey:
|
||||||
processBuilder = spiderMonkeyCommand( true );
|
processBuilder = spiderMonkeyCommand( true, false );
|
||||||
break;
|
break;
|
||||||
case SpiderMonkeyWat:
|
case SpiderMonkeyWat:
|
||||||
processBuilder = spiderMonkeyCommand( false );
|
processBuilder = spiderMonkeyCommand( false, false );
|
||||||
|
break;
|
||||||
|
case SpiderMonkeyGC:
|
||||||
|
processBuilder = spiderMonkeyCommand( true, true );
|
||||||
break;
|
break;
|
||||||
case NodeJS:
|
case NodeJS:
|
||||||
processBuilder = nodeJsCommand( nodeScript );
|
processBuilder = nodeJsCommand( nodeScript );
|
||||||
@ -455,15 +460,25 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
* Create a ProcessBuilder for spider monkey script shell.
|
* Create a ProcessBuilder for spider monkey script shell.
|
||||||
*
|
*
|
||||||
* @param binary true, if the WASM format should be test; false, if the WAT format should be tested.
|
* @param binary true, if the WASM format should be test; false, if the WAT format should be tested.
|
||||||
|
* @param gc true, if with gc should be test
|
||||||
* @return the value from the script
|
* @return the value from the script
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if the download failed
|
* if the download failed
|
||||||
*/
|
*/
|
||||||
private ProcessBuilder spiderMonkeyCommand( boolean binary ) throws IOException {
|
private ProcessBuilder spiderMonkeyCommand( boolean binary, boolean gc ) throws IOException {
|
||||||
File script;
|
File script;
|
||||||
try {
|
try {
|
||||||
System.setProperty( "SpiderMonkey", "true" );
|
System.setProperty( "SpiderMonkey", "true" );
|
||||||
if( binary ) {
|
if( gc ) {
|
||||||
|
if( spiderMonkeyScriptGC == null ) {
|
||||||
|
File file = newFile( "spiderMonkeyGC.wasm" );
|
||||||
|
compiler.setProperty( JWebAssembly.WASM_USE_GC, "true" );
|
||||||
|
compiler.compileToBinary( file );
|
||||||
|
spiderMonkeyScriptGC = createScript( "SpiderMonkeyTest.js", "{test.wasm}", file.getName() );
|
||||||
|
}
|
||||||
|
script = spiderMonkeyScriptGC;
|
||||||
|
|
||||||
|
} else if( binary ) {
|
||||||
if( spiderMonkeyScript == null ) {
|
if( spiderMonkeyScript == null ) {
|
||||||
File file = newFile( "spiderMonkey.wasm" );
|
File file = newFile( "spiderMonkey.wasm" );
|
||||||
compiler.compileToBinary( file );
|
compiler.compileToBinary( file );
|
||||||
@ -479,9 +494,10 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
script = spiderMonkeyWatScript;
|
script = spiderMonkeyWatScript;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
compiler.setProperty( JWebAssembly.WASM_USE_GC, null );
|
||||||
System.clearProperty( "SpiderMonkey" );
|
System.clearProperty( "SpiderMonkey" );
|
||||||
}
|
}
|
||||||
return new ProcessBuilder( spiderMonkey.getCommand(), "--wasm-gc", script.getAbsolutePath() );
|
return new ProcessBuilder( spiderMonkey.getCommand(), "--wasm-gc", /*"--wasm-bigint",*/ script.getAbsolutePath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package de.inetsoftware.jwebassembly.runtime;
|
package de.inetsoftware.jwebassembly.runtime;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.junit.Assume;
|
import org.junit.Assume;
|
||||||
@ -28,19 +29,23 @@ import de.inetsoftware.jwebassembly.ScriptEngine;
|
|||||||
import de.inetsoftware.jwebassembly.WasmRule;
|
import de.inetsoftware.jwebassembly.WasmRule;
|
||||||
import de.inetsoftware.jwebassembly.api.annotation.Export;
|
import de.inetsoftware.jwebassembly.api.annotation.Export;
|
||||||
|
|
||||||
public class Arrays extends AbstractBaseTest {
|
public class ArrayOperations extends AbstractBaseTest {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static WasmRule rule = new WasmRule( TestClass.class );
|
public static WasmRule rule = new WasmRule( TestClass.class );
|
||||||
|
|
||||||
public Arrays( ScriptEngine script, String method, Object[] params ) {
|
public ArrayOperations( ScriptEngine script, String method, Object[] params ) {
|
||||||
super( rule, script, method, params );
|
super( rule, script, method, params );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters( name = "{0}-{1}" )
|
@Parameters( name = "{0}-{1}" )
|
||||||
public static Collection<Object[]> data() {
|
public static Collection<Object[]> data() {
|
||||||
ArrayList<Object[]> list = new ArrayList<>();
|
ArrayList<Object[]> list = new ArrayList<>();
|
||||||
for( ScriptEngine script : ScriptEngine.testEngines() ) {
|
|
||||||
|
ScriptEngine[] engines = ScriptEngine.testEngines();
|
||||||
|
engines = Arrays.copyOf( engines, engines.length + 1 );
|
||||||
|
engines[engines.length - 1] = ScriptEngine.SpiderMonkeyGC;
|
||||||
|
for( ScriptEngine script : engines ) {
|
||||||
addParam( list, script, "length" );
|
addParam( list, script, "length" );
|
||||||
addParam( list, script, "loopByte" );
|
addParam( list, script, "loopByte" );
|
||||||
addParam( list, script, "loopShort" );
|
addParam( list, script, "loopShort" );
|
||||||
@ -58,7 +63,7 @@ public class Arrays extends AbstractBaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Override
|
@Override
|
||||||
public void test() {
|
public void test() {
|
||||||
Assume.assumeFalse( (getScriptEngine() == ScriptEngine.SpiderMonkeyWat || getScriptEngine() == ScriptEngine.SpiderMonkey)
|
Assume.assumeFalse( (getScriptEngine().name().startsWith( "SpiderMonkey" ) )
|
||||||
&& "loopLong".equals( getMethod() ) ); // TODO SpiderMonkey https://bugzilla.mozilla.org/show_bug.cgi?id=1511958
|
&& "loopLong".equals( getMethod() ) ); // TODO SpiderMonkey https://bugzilla.mozilla.org/show_bug.cgi?id=1511958
|
||||||
super.test();
|
super.test();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user