Skip to content

Commit 23e32f7

Browse files
committed
Add mechanism to check jog results
Setting the `QUARTO_JOG_CHECK` environment variable will run checks to identify filters for which the results of `jog` differ from those of pandoc's `walk`.
1 parent 9add002 commit 23e32f7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/resources/filters/ast/runemulation.lua

+13-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ end
4949

5050
local function run_emulated_filter_chain(doc, filters, afterFilterPass, profiling)
5151
init_trace(doc)
52+
local compare_jog_and_walk = os.getenv 'QUARTO_JOG_CHECK'
5253
for i, v in ipairs(filters) do
5354
local function callback()
5455
if v.flags then
@@ -80,7 +81,18 @@ local function run_emulated_filter_chain(doc, filters, afterFilterPass, profilin
8081
else
8182
_quarto.ast._current_doc = doc
8283

83-
doc = run_emulated_filter(doc, v.filter, v.force_pandoc_walk)
84+
if compare_jog_and_walk and not v.force_pandoc_walk then
85+
local expected = run_emulated_filter(doc:clone(), v.filter, true)
86+
doc = run_emulated_filter(doc:clone(), v.filter, false)
87+
if doc == expected then
88+
io.stderr:write("[ OK ] " .. v.name .. '\n')
89+
else
90+
io.stderr:write("[FAIL] " .. v.name .. '\n')
91+
doc = expected
92+
end
93+
else
94+
doc = run_emulated_filter(doc, v.filter, v.force_pandoc_walk)
95+
end
8496

8597
ensure_vault(doc)
8698

0 commit comments

Comments
 (0)