# # # patch "tester.cc" # from [15f9df6af209097db87c510ca37c8c93f4a4e6e9] # to [ebcd0595b678ca833fae72cd88ef06ce04900c3e] # # patch "testsuite.lua" # from [290429519a074746762528fb37c5ffed326fe873] # to [ab6fffa4c9d0bf6564bb073298e59f0e016c9d0e] # ============================================================ --- tester.cc 15f9df6af209097db87c510ca37c8c93f4a4e6e9 +++ tester.cc ebcd0595b678ca833fae72cd88ef06ce04900c3e @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -28,11 +29,6 @@ using std::make_pair; using boost::lexical_cast; -#include -#include -// for stat, to get mtime -// maybe factor this out of inodeprint instead? - namespace redirect { enum what {in, out, err}; @@ -321,19 +317,12 @@ mtime(lua_State *L) { char const * file = luaL_checkstring(L, -1); -#ifdef WIN32 - struct _stat st; - int r = _stat(file, &st); -#else - struct stat st; - int r = stat(file, &st); -#endif - if (r != 0) - { - lua_pushnil(L); - return 1; - } - lua_pushnumber(L, st.st_mtime); + fs::path fn(file); + std::time_t t = fs::last_write_time(file); + if (t == std::time_t(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, t); return 1; } @@ -341,8 +330,16 @@ exists(lua_State *L) { char const * name = luaL_checkstring(L, -1); - fs::path p(name, fs::native); - lua_pushboolean(L, fs::exists(p)); + fs::path p; + try + { + p = fs::path(name, fs::native); + lua_pushboolean(L, fs::exists(p)); + } + catch(fs::filesystem_error & e) + { + lua_pushnil(L); + } return 1; } @@ -446,10 +443,19 @@ needhelp = true; if (argc > 1 && !needhelp) { - fs::path file = fs::complete(fs::path(argv[1], fs::native)); - testfile = file.native_file_string(); save_initial_path(); - source_dir = file.branch_path(); + try + { + std::string name = argv[1]; + fs::path file = fs::complete(fs::path(name, fs::native)); + testfile = file.native_file_string(); + source_dir = file.branch_path(); + } + catch(fs::filesystem_error & e) + { + fprintf(stderr, "Error during initialization: %s", e.what()); + exit(1); + } firstdir = fs::initial_path().native_file_string(); run_dir = fs::initial_path() / "tester_dir"; fs::create_directory(run_dir); @@ -518,6 +524,7 @@ } catch (std::exception &e) { + fprintf(stderr, "Error: %s", e.what()); } lua_close(st); ============================================================ --- testsuite.lua 290429519a074746762528fb37c5ffed326fe873 +++ testsuite.lua ab6fffa4c9d0bf6564bb073298e59f0e016c9d0e @@ -21,7 +21,11 @@ local now = initial_dir.."/"..exe if exists(now) then return gotit(now) end for x in string.gfind(path, "[^"..char.."]*"..char) do - local now = string.sub(x, 0, -2).."/"..exe + local dir = string.sub(x, 0, -2) + if string.find(dir, "[\\/]$") then + dir = string.sub(dir, 0, -2) + end + local now = dir.."/"..exe if exists(now) then return gotit(now) end end if test_log == nil then