From: Fabien Date: Sat, 26 Nov 2011 14:44:10 +0000 (+0100) Subject: fix portability on tests/tun.mlua X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=0737467399406ca9762a166a65085a3b9e386313;p=metalua.git fix portability on tests/tun.mlua --- diff --git a/src/tests/run.mlua b/src/tests/run.mlua index dd2f3a2..b452056 100644 --- a/src/tests/run.mlua +++ b/src/tests/run.mlua @@ -3,12 +3,23 @@ -{ extension 'xloop' } -ls = io.popen ( (os.getenv("OS") or "") :match "^Windows" and "dir /b" or "ls") +LS_COMMANDS = { "ls", "dir /b" } +for i, cmd in ipairs(LS_COMMANDS) do + local f = io.popen (cmd) + ls = f :read '*a' + f :close() + if ls ~= '' then + break + elseif i == #LS_COMMANDS then + error "Can't figure out how to list files on your OS" + end +end + this_script = arg[1] local errors = {} -for filename in ls :lines() if filename ~= this_script and filename :strmatch "%.m?lua$" do +for filename in ls :gmatch "[^\n]+" if filename ~= this_script and filename :strmatch "%.m?lua$" do printf ("*** running %s ***", filename) local ret = os.execute ("metalua "..filename) if ret ~= 0 then @@ -16,8 +27,6 @@ for filename in ls :lines() if filename ~= this_script and filename :strmatch " end end -ls :close() - if #errors > 0 then print("\n\n================================================================================") error(