# # # patch "ChangeLog" # from [e4482ba6477ebe76678deaea1be021a73682aa49] # to [eaf17477c15761e59d283dfddb9d7d0b2a48a5f6] # # patch "tester.lua" # from [66cae018a22f78d18c2f340e76c2c72b5040f3cd] # to [1b33b5906f436eb072f524a94190b3e97d4fcc5c] # ============================================================ --- ChangeLog e4482ba6477ebe76678deaea1be021a73682aa49 +++ ChangeLog eaf17477c15761e59d283dfddb9d7d0b2a48a5f6 @@ -1,3 +1,7 @@ +2006-07-05 Timothy Brownawell + + * tester.lua: Use open_or_err more. + 2006-07-04 Timothy Brownawell * tester.cc: When setting env vars, don't take .c_str() of a temporary. ============================================================ --- tester.lua 66cae018a22f78d18c2f340e76c2c72b5040f3cd +++ tester.lua 1b33b5906f436eb072f524a94190b3e97d4fcc5c @@ -136,18 +136,14 @@ end function fsize(filename) - local file = io.open(filename, "r") - if file == nil then error("Cannot open file " .. filename, 2) end + local file = open_or_err(filename, "r", 3) local size = file:seek("end") file:close() return size end function readfile_q(filename) - local file = io.open(filename, "rb") - if file == nil then - error("Cannot open file " .. filename) - end + local file = open_or_err(filename, "rb", 3) local dat = file:read("*a") file:close() return dat @@ -165,14 +161,10 @@ function writefile_q(filename, dat) local file,e if dat == nil then - file,e = io.open(filename, "a+b") + file,e = open_or_err(filename, "a+b", 3) else - file,e = io.open(filename, "wb") + file,e = open_or_err(filename, "wb", 3) end - if file == nil then - L("Cannot open file ", filename, ": ", e, "\n") - return false - end if dat ~= nil then file:write(dat) end @@ -187,15 +179,10 @@ function append(filename, dat) L(locheader(), "append to file ", filename, "\n") - local file,e = io.open(filename, "a+") - if file == nil then - L("Cannot open file: ", e, "\n") - return false - else - file:write(dat) - file:close() - return true - end + local file,e = open_or_err(filename, "a+", 3) + file:write(dat) + file:close() + return true end do @@ -303,9 +290,9 @@ L("\nruncmd: ", tostring(cmd[1]), ", local_redir = ", tostring(local_redir), ", requested = ", tostring(cmd.local_redirect)) local redir if local_redir then - files.stdin = io.open(prefix.."stdin") - files.stdout = io.open(prefix.."stdout", "w") - files.stderr = io.open(prefix.."stderr", "w") + files.stdin = open_or_err(prefix.."stdin", nil, 2) + files.stdout = open_or_err(prefix.."stdout", "w", 2) + files.stderr = open_or_err(prefix.."stderr", "w", 2) else redir = set_redirect(prefix.."stdin", prefix.."stdout", prefix.."stderr") end @@ -411,8 +398,8 @@ if not quiet and files.stdout == nil then err("non-quiet grep not redirected") end local out = 1 local infile = files.stdin - if where ~= nil then infile = io.open(where) end - for line in io.lines(where) do + if where ~= nil then infile = open_or_err(where) end + for line in infile:lines() do local matched = regex.search(what, line) if reverse then matched = not matched end if matched then @@ -434,7 +421,7 @@ if x == "-" then infile = files.stdin else - infile = io.open(x, "rb") + infile = open_or_err(x, "rb", 3) end local block = infile:read(bsize) while block do @@ -474,7 +461,7 @@ if file == nil then infile = files.stdin else - infile = io.open(file) + infile = open_or_err(file) end local lines = {} for l in infile:lines() do @@ -501,7 +488,7 @@ elseif type(stdin) == "table" then unlogged_copy(stdin[1], ident .. "stdin") else - local infile = open_or_err(ident .. "stdin", "w") + local infile = open_or_err(ident .. "stdin", "w", 3) if stdin ~= nil and stdin ~= false then infile:write(stdin) end @@ -527,7 +514,7 @@ err("Check failed (stdout): not empty", 3) end elseif type(stdout) == "string" then - local realout = io.open(ident .. "stdout") + local realout = open_or_err(ident .. "stdout", nil, 3) local contents = realout:read("*a") realout:close() if contents ~= stdout then @@ -547,7 +534,7 @@ err("Check failed (stderr): not empty", 3) end elseif type(stderr) == "string" then - local realerr = io.open(ident .. "stderr") + local realerr = open_or_err(ident .. "stderr", nil, 3) local contents = realerr:read("*a") realerr:close() if contents ~= stderr then