-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests for Lua API extension proposed in martanne/vis#675 #12
base: master
Are you sure you want to change the base?
Conversation
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.
Unused parameters in the PROCESS_RESPONSE event is set to nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I should have checked/committed this a long time ago. Comments inline.
lua/subprocess.lua
Outdated
print("Event assert failed for process", name) | ||
print("Got event type: ("..type(et)..")", et) | ||
print("Expected event type:", current_event.etype) | ||
print("Got event code: (", type(ec), ")", ec) | ||
print("Expected code:("..type(current_event.expected_code)..")", | ||
current_event.expected_code) | ||
print("Got event buffer: (", type(eb), ")", eb) | ||
print("Expected buffer:("..type(current_event.expected_buffer)..")", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print("Event assert failed for process", name) | |
print("Got event type: ("..type(et)..")", et) | |
print("Expected event type:", current_event.etype) | |
print("Got event code: (", type(ec), ")", ec) | |
print("Expected code:("..type(current_event.expected_code)..")", | |
current_event.expected_code) | |
print("Got event buffer: (", type(eb), ")", eb) | |
print("Expected buffer:("..type(current_event.expected_buffer)..")", | |
print("Event assert failed for process:", name) | |
print("Got event type:", "("..type(et)..")", et) | |
print("Expected:", "("..type(current_event.etype)..")", | |
current_event.etype) | |
print("Got event code:", "("..type(ec)..")", ec) | |
print("Expected:", "("..type(current_event.expected_code)..")", | |
current_event.expected_code) | |
print("Got event data:", "("..type(eb)..")", eb) | |
print("Expected:", "("..type(current_event.expected_buffer)..")", |
it("process termination", function() | ||
event_assert("termtest", "SIGNAL", 15, nil) | ||
local handle = vis:communicate("termtest", "sleep 1s") | ||
handle:close() | ||
end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this ever work? Shouldn't the assert be event_assert("termtest", "EXIT", 143, nil)
? I'm not sure there is a reliable way to catch a SIGNAL
event.
lua/test.sh
Outdated
|
||
mkfifo infifo | ||
$VIS "$t.in" <infifo 2> /dev/null > "$t.busted" & | ||
for i in 1; do sleep 0.1s; echo ":qall!"; done > infifo & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of the non-posix sleep usage here and in the lua script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not see any good way of performing it without the race condition. May be putting read -t 0.1
will be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read -t 0.1
Also not defined in posix. Its not elegant but to keep the script completely posix compatible and minimize the sleep cost something like this should work:
if [ $(grep -q "vis:communicate" < "$t.lua") ]; then
{ sleep 1; echo ":qall!"; } > infifo &
else
echo ":qall!" > infifo &
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "non-posix" and "not defined in posix"? I checked it on wiki and found both commands in the list of posix commands.
https://en.wikipedia.org/wiki/List_of_POSIX_commands
There is a problem with sleep in the shell script, because it is a bad way to overcome a race condition. We need to give async processes some time to finish and produce all necessary events, but there should be a better way for syncronization and I am still thinking about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "non-posix" and "not defined in posix"? I checked it on wiki and found both commands in the list of posix commands. https://en.wikipedia.org/wiki/List_of_POSIX_commands
There are some tests that cover all code (except error handling) of martanne/vis#675.
To make it possible to test the asynchronous events I slightly changed testing script and
visrc.lua
.Now it starts vis, gives it 0.1 seconds to cycle main loop and to fire events and terminates it by the command
:qall!
instead of terminating from the lua code byvis:exit()
.