forked from enlightenment/efl
elua tests: fix distcheck
The elua tests need to create a temporary file, so chdir'ing first will not work, as the tests source dir is immutable during distcheck. Therefore, only chdir once absolutely necessary, and before that make sure that all file accesses are to temporary ones.
This commit is contained in:
parent
300b1993d8
commit
7924660d54
|
@ -29,11 +29,6 @@ EFL_START_TEST(elua_api)
|
|||
st = elua_state_new("test");
|
||||
fail_if(!st);
|
||||
|
||||
/* elua APIs here try accessing files by relative path,
|
||||
* prevent any unintentional file accesses in cwd
|
||||
*/
|
||||
fail_if(chdir(TESTS_SRC_DIR));
|
||||
|
||||
/* test env vars */
|
||||
setenv("ELUA_CORE_DIR", "foo", 1);
|
||||
setenv("ELUA_MODULES_DIR", "bar", 1);
|
||||
|
@ -85,22 +80,6 @@ EFL_START_TEST(elua_api)
|
|||
fail_if(lua_type(lst, -1) != LUA_TFUNCTION);
|
||||
lua_pop(lst, 1);
|
||||
|
||||
fail_if(!elua_util_require(st, "util"));
|
||||
fail_if(!elua_util_string_run(st, "return 1337", "foo"));
|
||||
fail_if(elua_util_string_run(st, "foo bar", "foo")); /* invalid code */
|
||||
fail_if(elua_util_app_load(st, "test"));
|
||||
fail_if(lua_type(lst, -1) != LUA_TFUNCTION);
|
||||
lua_pop(lst, 1);
|
||||
fail_if(!elua_util_app_load(st, "non_existent_app"));
|
||||
fail_if(lua_type(lst, -1) != LUA_TSTRING);
|
||||
lua_pop(lst, 1);
|
||||
fail_if(elua_io_loadfile(st, ELUA_CORE_DIR "/util.lua"));
|
||||
fail_if(lua_type(lst, -1) != LUA_TFUNCTION);
|
||||
lua_pop(lst, 1);
|
||||
fail_if(!elua_io_loadfile(st, ELUA_CORE_DIR "/non_existent_file.lua"));
|
||||
fail_if(lua_type(lst, -1) != LUA_TSTRING);
|
||||
lua_pop(lst, 1);
|
||||
|
||||
fd = mkstemp(buf);
|
||||
fail_if(fd < 0);
|
||||
f = fdopen(fd, "wb");
|
||||
|
@ -118,6 +97,11 @@ EFL_START_TEST(elua_api)
|
|||
fail_if(!elua_util_error_report(st, 5));
|
||||
fail_if(lua_gettop(lst) > 0);
|
||||
|
||||
f = fopen(buf, "wb");
|
||||
fail_if(!f);
|
||||
fprintf(f, "return true");
|
||||
fclose(f);
|
||||
cargv[1] = buf;
|
||||
fail_if(!elua_util_script_run(st, 2, cargv, 1, &quit));
|
||||
fail_if(quit != 1);
|
||||
|
||||
|
@ -125,11 +109,31 @@ EFL_START_TEST(elua_api)
|
|||
fail_if(!f);
|
||||
fprintf(f, "return false");
|
||||
fclose(f);
|
||||
cargv[1] = buf;
|
||||
fail_if(!elua_util_script_run(st, 2, cargv, 1, &quit));
|
||||
fail_if(quit != 0);
|
||||
fail_if(remove(buf));
|
||||
|
||||
/* elua API here tries accessing files by relative path,
|
||||
* prevent any unintentional file accesses in cwd
|
||||
*/
|
||||
fail_if(chdir(TESTS_SRC_DIR));
|
||||
|
||||
fail_if(!elua_util_require(st, "util"));
|
||||
fail_if(!elua_util_string_run(st, "return 1337", "foo"));
|
||||
fail_if(elua_util_string_run(st, "foo bar", "foo")); /* invalid code */
|
||||
fail_if(elua_util_app_load(st, "test"));
|
||||
fail_if(lua_type(lst, -1) != LUA_TFUNCTION);
|
||||
lua_pop(lst, 1);
|
||||
fail_if(!elua_util_app_load(st, "non_existent_app"));
|
||||
fail_if(lua_type(lst, -1) != LUA_TSTRING);
|
||||
lua_pop(lst, 1);
|
||||
fail_if(elua_io_loadfile(st, ELUA_CORE_DIR "/util.lua"));
|
||||
fail_if(lua_type(lst, -1) != LUA_TFUNCTION);
|
||||
lua_pop(lst, 1);
|
||||
fail_if(!elua_io_loadfile(st, ELUA_CORE_DIR "/non_existent_file.lua"));
|
||||
fail_if(lua_type(lst, -1) != LUA_TSTRING);
|
||||
lua_pop(lst, 1);
|
||||
|
||||
elua_state_free(st);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
|
Loading…
Reference in New Issue