diff options
Diffstat (limited to '')
| -rwxr-xr-x | mirror-checker.lua | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/mirror-checker.lua b/mirror-checker.lua index 9dd93bb..0e8567e 100755 --- a/mirror-checker.lua +++ b/mirror-checker.lua | |||
| @@ -79,34 +79,38 @@ local http = require 'socket.http' | |||
| 79 | local url = require 'socket.url' | 79 | local url = require 'socket.url' |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | -- Use this to print a table. | 82 | -- Use this to dump a table to a string. |
| 83 | printTable = function (table, space, name) | 83 | dumpTable = function (table, space, name) |
| 84 | if "" == space then print(space .. name .. " =") else print(space .. "[" .. name .. "] =") end | 84 | local r = "" |
| 85 | print(space .. "{") | 85 | if "" == space then r = r .. space .. name .. " =\n" else r = r .. space .. "[" .. name .. "] =\n" end |
| 86 | printTableSub(table, space .. " ") | 86 | r = r .. space .. "{\n" |
| 87 | if "" == space then print(space .. "}") else print(space .. "},") end | 87 | r = r .. dumpTableSub(table, space .. " ") |
| 88 | if "" == space then r = r .. space .. "}\n" else r = r .. space .. "},\n" end | ||
| 89 | return r | ||
| 88 | end | 90 | end |
| 89 | printTableSub = function (table, space) | 91 | dumpTableSub = function (table, space) |
| 92 | local r = "" | ||
| 90 | for k, v in pairs(table) do | 93 | for k, v in pairs(table) do |
| 91 | if type(k) == "string" then k = '"' .. k .. '"' end | 94 | if type(k) == "string" then k = '"' .. k .. '"' end |
| 92 | if type(v) == "table" then | 95 | if type(v) == "table" then |
| 93 | printTable(v, space, k) | 96 | r = r .. dumpTable(v, space, k) |
| 94 | elseif type(v) == "string" then | 97 | elseif type(v) == "string" then |
| 95 | print(space .. "[" .. k .. "] = '" .. v .. "';") | 98 | r = r .. space .. "[" .. k .. "] = '" .. v .. "';\n" |
| 96 | elseif type(v) == "function" then | 99 | elseif type(v) == "function" then |
| 97 | print(space .. "[" .. k .. "] = function ();") | 100 | r = r .. space .. "[" .. k .. "] = function ();\n" |
| 98 | elseif type(v) == "userdata" then | 101 | elseif type(v) == "userdata" then |
| 99 | print(space .. "userdata " .. "[" .. k .. "];") | 102 | r = r .. space .. "userdata " .. "[" .. k .. "];\n" |
| 100 | elseif type(v) == "boolean" then | 103 | elseif type(v) == "boolean" then |
| 101 | if (v) then | 104 | if (v) then |
| 102 | print(space .. "boolean " .. "[" .. k .. "] = true;") | 105 | r = r .. space .. "[" .. k .. "] = true;\n" |
| 103 | else | 106 | else |
| 104 | print(space .. "boolean " .. "[" .. k .. "] = false;") | 107 | r = r .. space .. "[" .. k .. "] = false;\n" |
| 105 | end | 108 | end |
| 106 | else | 109 | else |
| 107 | print(space .. "[" .. k .. "] = " .. v .. ";") | 110 | r = r .. space .. "[" .. k .. "] = " .. v .. ";\n" |
| 108 | end | 111 | end |
| 109 | end | 112 | end |
| 113 | return r | ||
| 110 | end | 114 | end |
| 111 | 115 | ||
| 112 | local log = function(v, t, s) | 116 | local log = function(v, t, s) |
| @@ -442,7 +446,7 @@ if 0 ~= #args then | |||
| 442 | end | 446 | end |
| 443 | end | 447 | end |
| 444 | 448 | ||
| 445 | --printTable(options.tests.value, "", "tests") | 449 | --print(dumpTable(options.tests.value, "", "tests")) |
| 446 | 450 | ||
| 447 | execute("mkdir -p results") | 451 | execute("mkdir -p results") |
| 448 | 452 | ||
