test fails
mcepl opened this issue · comments
When packaging SLAXML for OpenSUSE, I get this error while running the testsuite:
[ 2s] + cd test
[ 2s] + lua test.lua
[ 2s] ==============================================================================
[ 2s] (test suite)
[ 2s] ==============================================================================
[ 2s] comments: .......pass
[ 2s] dom: .........................................................pass
[ 2s] dom_entities: ....pass
[ 2s] dom_namespaces: ......................pass
[ 2s] dom_serializer: pass
[ 2s] invalid_documents: .......FAIL!
[ 2s] test.lua:225: assertErrors() failed: function: 0x55e0b01f1390 did not raise an error
[ 2s] namespace: ....pass
[ 2s] serialize_sorting: ....pass
[ 2s] serializer: ......pass
[ 2s] simplest: .......pass
[ 2s] slim_and_trim_dom: .................................pass
[ 2s] utf8: ......pass
[ 2s] whitespace: ................pass
[ 2s] xml_namespace: .pass
[ 2s] xml_namespace_immediate_use: ....................pass
[ 2s] ------------------------------------------------------------------------------
[ 2s] 14/15 tests passed (93.3%)
[ 2s] 194 total successful assertions in ~2ms (103579 assertions/second)
Thank you for the report. This is a known issue, documented in the top bullet here:
https://github.com/Phrogz/SLAXML#known-limitations--todo
It is a goal of the library to be a proper validating parser, and so this test exists that is currently failing.
Sorry for bothering you, but I am lost, what’s wrong with this super simple script:
#!/usr/bin/lua
local SLAXML = require 'slaxml'
local myxml = io.open('CzeCEP.xml'):read('*all')
-- Czech version
local counter = { ["‚"] = 0, ["„"] = 0}
local counter_keys = ""
for k in pairs(counter) do
counter_keys = counter_keys .. k
end
local qparis = { ["‚"] = "‘", ["‘"] = "‚", ["„"] = "“", ["“"] = "„" }
parser = SLAXML:parser{
text = function(text,cdata)
for ch in text:gmatch("[‚‘„“]") do
if counter_keys:find(ch, 1, true) then
counter[ch] = counter[ch] + 1
else
counter[qpairs[ch]] = counter[qpairs[ch]] - 1
if counter[qpairs[ch]] < 0 then
print("This is wrong: " .. text)
os.exit(1)
end
end
end
end
}
-- Ignore whitespace-only text nodes and strip leading/trailing whitespace from text
-- (does not strip leading/trailing whitespace from CDATA)
parser:parse(myxml,{stripWhitespace=true})
When run, it fails like this:
xml-unpaired@stitny (master)$ lua dumptext.lua
lua: dumptext.lua:19: attempt to perform arithmetic on a nil value (field '?')
stack traceback:
dumptext.lua:19: in field 'text'
/usr/share/lua/5.4/slaxml.lua:87: in upvalue 'finishText'
/usr/share/lua/5.4/slaxml.lua:125: in local 'startElement'
/usr/share/lua/5.4/slaxml.lua:239: in function 'slaxml.parse'
dumptext.lua:33: in main chunk
[C]: in ?
Any idea, what’s going on, please?