mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Add also the result/stack if possible also if execution of the script is failing.
This commit is contained in:
parent
3e4d1794a4
commit
8ce6c1d919
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 - 2021 Volker Berlin (i-net software)
|
* Copyright 2017 - 2022 Volker Berlin (i-net software)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -617,21 +617,28 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
stdoutMessage += readStream( process.getInputStream(), false );
|
stdoutMessage += readStream( process.getInputStream(), false );
|
||||||
errorMessage += readStream( process.getErrorStream(), false );
|
errorMessage += readStream( process.getErrorStream(), false );
|
||||||
int exitCode = process.exitValue();
|
int exitCode = process.exitValue();
|
||||||
|
|
||||||
|
// read the result from file
|
||||||
|
File resultFile = new File( getRoot(), "testresult.json" );
|
||||||
|
String result = null;
|
||||||
|
if( resultFile.exists() ) {
|
||||||
|
try( InputStreamReader jsonData = new InputStreamReader( new FileInputStream( new File( getRoot(), "testresult.json" ) ), StandardCharsets.UTF_8 ) ) {
|
||||||
|
@SuppressWarnings( "unchecked" )
|
||||||
|
Map<String, String> map = new Gson().fromJson( jsonData, Map.class );
|
||||||
|
if( testData != null ) {
|
||||||
|
testResults.put( script, map );
|
||||||
|
}
|
||||||
|
result = map.get( methodName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( exitCode != 0 || !stdoutMessage.isEmpty() || !errorMessage.isEmpty() ) {
|
if( exitCode != 0 || !stdoutMessage.isEmpty() || !errorMessage.isEmpty() ) {
|
||||||
System.err.println( stdoutMessage );
|
System.err.println( stdoutMessage );
|
||||||
System.err.println( errorMessage );
|
System.err.println( errorMessage );
|
||||||
fail( stdoutMessage + '\n' + errorMessage + "\nExit code: " + exitCode );
|
fail( stdoutMessage + '\n' + errorMessage + '\n' + result + "\nExit code: " + exitCode );
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the result from file
|
return result;
|
||||||
try( InputStreamReader jsonData = new InputStreamReader( new FileInputStream( new File( getRoot(), "testresult.json" ) ), StandardCharsets.UTF_8 ) ) {
|
|
||||||
@SuppressWarnings( "unchecked" )
|
|
||||||
Map<String, String> map = new Gson().fromJson( jsonData, Map.class );
|
|
||||||
if( testData != null ) {
|
|
||||||
testResults.put( script, map );
|
|
||||||
}
|
|
||||||
return map.get( methodName );
|
|
||||||
}
|
|
||||||
} catch( Throwable ex ) {
|
} catch( Throwable ex ) {
|
||||||
failed = true;
|
failed = true;
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user