Skip to content

Commit

Permalink
Improved Lua API testing system
Browse files Browse the repository at this point in the history
Now the testing system allows vis to perform a few main loop cycles before quit.
It is necessary to check events in upcoming subprocess tests.
  • Loading branch information
xomachine committed Jun 19, 2023
1 parent d35540c commit e3634bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lua/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ for t in $test_files; do
t=${t%.lua}
t=${t#./}
printf "%-30s" "$t"
$VIS "$t.in" < /dev/null 2> /dev/null > "$t.busted"

mkfifo infifo
$VIS "$t.in" <infifo 2> /dev/null > "$t.busted" &
for i in 1; do sleep 0.1s; echo ":qall!"; done > infifo &
wait %1 && wait %2
if [ $? -ne 0 ]; then
printf "FAIL\n"
cat "$t.busted"
else
TESTS_OK=$((TESTS_OK + 1))
printf "OK\n"
fi
rm infifo
done

printf "Tests ok %d/%d\n" $TESTS_OK $TESTS_RUN
Expand Down
3 changes: 1 addition & 2 deletions lua/visrc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ io.stderr = io.stdout

-- make sure we gracefully terminate, cleanup terminal state etc.
os.exit = function(status)
vis:exit(status)
if status ~= 0 then vis:exit(status) end
end

vis.events.subscribe(vis.events.WIN_OPEN, function(win)
Expand All @@ -24,5 +24,4 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win)
return
end
end
vis:exit(0)
end)

0 comments on commit e3634bd

Please sign in to comment.