diff --git a/src/test/java/org/luaj/vm/LuaJTest.java b/src/test/java/org/luaj/vm/LuaJTest.java index 6c277f96..feae903b 100644 --- a/src/test/java/org/luaj/vm/LuaJTest.java +++ b/src/test/java/org/luaj/vm/LuaJTest.java @@ -252,9 +252,27 @@ public class LuaJTest extends TestCase { }); outputCopier.start(); + // start another thread to read output from the subprocess. + Thread errorCopier = (new Thread() { + public void run() { + try { + InputStream processError = p.getErrorStream(); + try { + copy( processError, System.err ); + } finally { + processError.close(); + } + } catch ( IOException ioe ) { + ioe.printStackTrace(); + } + } + }); + errorCopier.start(); + p.waitFor(); inputCopier.join(); outputCopier.join(); + errorCopier.join(); return new String( baos.toByteArray() ); diff --git a/src/test/res/errors.lua b/src/test/res/errors.lua index a4eee00d..8fe2af99 100644 --- a/src/test/res/errors.lua +++ b/src/test/res/errors.lua @@ -1,4 +1,5 @@ -- object ids +package.path = "?.lua;src/test/res/?.lua" require 'ids' ids = {} @@ -83,6 +84,9 @@ t = {} print( 'a(setmetatable(t)) ', a(function() return sm(t,{}) end) ) print( 'a(setmetatable(t*)) ', a(function() return sm(t,{__metatable='some string'}) end) ) print( 'a(setmetatable(t)) ', a(function() return sm(t,{}) end) ) +print( 'a(setmetatable(t,nil)) ', a(function() return sm(t,nil) end) ) +print( 'a(setmetatable(t)) ', a(function() return sm(t) end) ) +print( 'a(setmetatable({},"abc")) ', a(function() return sm({},'abc') end) ) -- bad args to error! print( 'error("msg","arg")', a(function() error('some message', 'some bad arg') end) )