# The XML node associated to the module
var testsuite: HTMLTag
- # All failures from a same `ADoc`
- var failures = new Array[String]
-
# Markdown processor used to parse markdown comments and extract code.
var mdproc = new MarkdownProcessor
fun extract(mdoc: MDoc, xml_classname, xml_name: String)
do
last_docunit = null
- failures.clear
self.xml_classname = xml_classname
self.xml_name = xml_name
mdproc.process(mdoc.content.join("\n"))
toolcontext.check_errors
-
- if not failures.is_empty then
- for msg in failures do
- var ne = new HTMLTag("failure")
- ne.attr("message", msg)
- tc.add ne
- toolcontext.modelbuilder.unit_entities += 1
- toolcontext.modelbuilder.failed_entities += 1
- end
- if last_docunit == null then testsuite.add(tc)
- end
end
# All extracted docunits
do
var simple_du = new Array[DocUnit]
for du in docunits do
+ # Skip existing errors
+ if du.error != null then continue
+
var ast = toolcontext.parse_something(du.block)
if ast isa AExpr then
simple_du.add du
i += 1
toolcontext.info("Execute doc-unit {du.full_name} in {file} {i}", 1)
var res2 = toolcontext.safe_exec("{file.to_program_name}.bin {i} >'{file}.out1' 2>&1 </dev/null")
+ du.was_exec = true
var content = "{file}.out1".to_path.read_all
var msg = content.trunc(8192).filter_nonprintable
var res2 = 0
if res == 0 then
res2 = toolcontext.safe_exec("{file.to_program_name}.bin >'{file}.out1' 2>&1 </dev/null")
+ du.was_exec = true
end
var content = "{file}.out1".to_path.read_all
toolcontext.warning(du.location, "failure", "FAILURE: {du.full_name} (in {file}):\n{msg}")
toolcontext.modelbuilder.failed_entities += 1
else if res2 != 0 then
+ du.error = content
toolcontext.warning(du.location, "error", "ERROR: {du.full_name} (in {file}):\n{msg}")
toolcontext.modelbuilder.failed_entities += 1
end
end
executor.toolcontext.warning(location, "invalid-block", "{message} To suppress this message, enclose the block with a fence tagged `nitish` or `raw` (see `man nitdoc`).")
- executor.failures.add("{location}: {message}")
+ executor.toolcontext.modelbuilder.failed_entities += 1
+
+ var du = new_docunit
+ du.block += code
+ du.error = "{location}: {message}"
return
end