add more comments on changes to the lua library
add basic test for the new os.outputof behavior
This commit is contained in:
parent
187a756ce7
commit
c8a18c4b4e
@ -105,15 +105,26 @@ static int io_noclose (lua_State *L) {
|
||||
/*
|
||||
** function to close 'popen' files
|
||||
*/
|
||||
/*
|
||||
* PREAAKE change: return both output and exit code
|
||||
*/
|
||||
static int io_pclose (lua_State *L) {
|
||||
FILE **p = tofilep(L);
|
||||
int result = lua_pclose(L, *p);
|
||||
*p = NULL;
|
||||
if (result == -1) {
|
||||
/*
|
||||
* pclose call failure
|
||||
*/
|
||||
return pushresult(L, 0, NULL);
|
||||
}
|
||||
lua_pushboolean(L, 1);
|
||||
lua_pushinteger(L, result / 255);
|
||||
/**
|
||||
* On success, pcluse returns a 2 byte length integer
|
||||
* where the higher byte contains the command exit code
|
||||
*/
|
||||
result /= 255;
|
||||
lua_pushinteger(L, result);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@ -668,11 +668,17 @@ union luai_Cast { double l_d; long l_l; };
|
||||
#if defined(LUA_USE_POPEN)
|
||||
|
||||
#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
|
||||
/*
|
||||
* PREMAKE change: get pclose return value
|
||||
*/
|
||||
#define lua_pclose(L,file) ((void)L, (pclose(file)))
|
||||
|
||||
#elif defined(LUA_WIN)
|
||||
|
||||
#define lua_popen(L,c,m) ((void)L, _popen(c,m))
|
||||
/*
|
||||
* PREMAKE change: get pclose return value
|
||||
*/
|
||||
#define lua_pclose(L,file) ((void)L, (_pclose(file)))
|
||||
|
||||
#else
|
||||
|
@ -103,3 +103,25 @@
|
||||
function suite.pathsearch_NilPathsAllowed()
|
||||
test.isequal(os.getcwd(), os.pathsearch("premake5.lua", nil, os.getcwd(), nil))
|
||||
end
|
||||
|
||||
--
|
||||
-- os.pathsearch() tests
|
||||
--
|
||||
function suite.outputof_commandExitCode()
|
||||
if os.is("macosx")
|
||||
or os.is("linux")
|
||||
or os.is("solaris")
|
||||
or os.is("bsd")
|
||||
then
|
||||
-- Assumes 'true' and 'false' commands exits
|
||||
-- which should be the case on all *nix platforms
|
||||
for cmd, exitcode in pairs ({
|
||||
["true"] = 0,
|
||||
["false"] = 1
|
||||
})
|
||||
do
|
||||
local o, e = os.outputof(cmd)
|
||||
test.isequal(e, exitcode)
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user