q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7924660d54500285d3844bfa384394c683825cd9

commit 7924660d54500285d3844bfa384394c683825cd9
Author: Daniel Kolesa <d.kol...@samsung.com>
Date:   Wed Feb 27 18:38:43 2019 +0100

    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.
---
 src/tests/elua/elua_lib.c | 48 +++++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/src/tests/elua/elua_lib.c b/src/tests/elua/elua_lib.c
index bcf1b26f90..c39d056701 100644
--- a/src/tests/elua/elua_lib.c
+++ b/src/tests/elua/elua_lib.c
@@ -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

-- 


Reply via email to