Content deleted Content added
better still, just display the error as normal |
skip templates that are not at start of line to reduce unwanted tests when reading a page; also show fails in wikitext; tweaks |
||
Line 34:
local function status_box(stats, expected, actual)
local label, bgcolor, align, isfail
if expected == '' then
stats.ignored = stats.ignored + 1
Line 49:
bgcolor = 'red'
label = 'Fail'
isfail = true
end
return actual, 'style="text-align:' .. align .. ';color:white;background:' .. bgcolor .. ';" | ' .. label, isfail
end
Line 113 ⟶ 114:
text = text:gsub('{', '{'):gsub('|', '|') -- escape '{' and '|'
text = text:gsub('%z', '|') -- restore pipe in piped link
if multiline then
text = text:gsub('\\n', '<br />')
end
return text
end
local function nowiki_cell(text, multiline)
text = mw.text.nowiki(text)
if multiline then
text = text:gsub('\\n', '<br />')
Line 122 ⟶ 130:
result:add('{| class="wikitable"')
result:add('! Template !! Expected !! Actual, if different !! Status')
for pos, template, expected in all_tests:gmatch('()({{.-}})(.-)\n') do
-- Skip templates that are not at the start of a line to reduce likelihood
-- of using unwanted templates when reading a page.
local actual = collapse_multiline(run_template(frame, template))▼
if pos == 1 or all_tests:sub(pos-1, pos-1) == '\n' then
result:add('| ' .. safe_cell(expected, true))▼
result:add('|
result:add('| ' .. safe_cell(template))
▲ result:add('| ' .. safe_cell(expected, true))
result:add('| ' .. safe_cell(actual, true))
result:add('| ' .. sbox)
if isfail then
result:add('|-')
result:add('| (above, nowiki)')
result:add('| ' .. nowiki_cell(expected, true))
result:add('| ' .. nowiki_cell(actual, true))
result:add('|')
end
end
end
result:add('|}')
Line 144 ⟶ 164:
end
end
error('Could not read wikitext from "[[
end
Line 183 ⟶ 203:
if not empty(test_text) then
error('Invoke must not set "page=' .. page_title .. '" if also setting p.tests.', 0)
end
if page_title:sub(1, 2) == '[[' and page_title:sub(-2) == ']]' then
page_title = strip(page_title:sub(3, -3))
end
test_text = get_page_content(page_title)
Line 213 ⟶ 236:
end
end
return '<strong class="
end
|