The regex matching is made to be more precise to capture subscribed params via Robot.get_value(). The regex now properly handles whitespace, multiple subscriptions per line, and variable name-sharing.
Important note: if the student code has a variable that shares the name with a variable used in studentcode.pyx, then
eval(<that variable>) would cause undefined behavior. For example, if the student named a variable code_file in their code, it may evaluate to studentcode, as it does in studentcode.pyx. To reduce the occurrence of this, we prefixed all variables in get_all_params with an underscore, assuming that students won't do the same.
Test tc_159_1 covers several cases that should (or shouldn't) prompt a subscription. This test may fail for the current executor.
To properly check the device subscriptions, a new assertion check_sub_requests was added to test.c.
A utility function check_start_pos() was also added to test.c/test.h and tc_71_1 was changed accordingly to avoid using the shared memory print function.
Finally, this PR also adds additional sleeps to tc_150_1 because it sometimes fails due to latency between when a user input is sent and when it changes in shared memory.
The regex matching is made to be more precise to capture subscribed params via
Robot.get_value()
. The regex now properly handles whitespace, multiple subscriptions per line, and variable name-sharing.Important note: if the student code has a variable that shares the name with a variable used in
studentcode.pyx
, theneval(<that variable>)
would cause undefined behavior. For example, if the student named a variablecode_file
in their code, it may evaluate tostudentcode
, as it does instudentcode.pyx
. To reduce the occurrence of this, we prefixed all variables inget_all_params
with an underscore, assuming that students won't do the same.Test
tc_159_1
covers several cases that should (or shouldn't) prompt a subscription. This test may fail for the current executor. To properly check the device subscriptions, a new assertioncheck_sub_requests
was added totest.c
.A utility function
check_start_pos()
was also added totest.c
/test.h
andtc_71_1
was changed accordingly to avoid using the shared memory print function.Finally, this PR also adds additional sleeps to
tc_150_1
because it sometimes fails due to latency between when a user input is sent and when it changes in shared memory.Resolves #159