Repository navigation
Add headless tests for response, feedback and sound items - #842
Merged
smathot merged 3 commits intoDec 1, 2026
Merged
Conversation
Extend the headless suite with three self-asserting experiments that exercise runtime paths that were previously untested: - mouse_response_test.osexp: mouseclick and mouserelease collection, cursor position/ROI variables, allowed/correct responses - feedback_test.osexp: feedback item execution and reset_variables, keypress and keyrelease keyboard responses - sampler_test.osexp: synth (generated tone) and sampler (pool sample) playback plus a keypress response Responses time out deterministically headless (no input devices), and each experiment ends with an inline_script item asserting the expected response variables. SDL_AUDIODRIVER=dummy is set so the sound items do not require audio hardware.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Several recent bug fixes (#836 tree crash, #777 form flush, #838 embedded browser help commands, #840 General tab booleans) shipped without regression tests, largely because the test suite only exercised the experiment model and the legacy canvas backend — not the runtime paths those bugs lived in. Overall coverage is ~27%, and whole item types (
mouse_response,feedback,sampler,synth, theform_*plugins, sketchpad response collection, and loop break-if conditions) had 0% coverage.Solution
Add seven self-asserting experiments to
tests/data/, run by the existing headless suite intests/headless/test_headless.py(six through the shared runner, plusform_consent_test.osexpthrough a dedicated test that stubsForm._execto simulate the participant accepting the form):mouse_response_test.osexp— mouseclick and mouserelease collection, cursor position/ROI variables, allowed/correct responses, linked sketchpadfeedback_test.osexp— feedback item execution andreset_variables, keypress and keyrelease keyboard responsessampler_test.osexp—synth(generated tone) andsampler(pool sample__pool__/test.wav) playback plus a keypress responseform_test.osexp—form_text_display,form_multiple_choiceandform_text_inputwidget construction and timeout handling throughFormBase/widgets/_form.py, plus anadvanced_delayitemsketchpad_response_test.osexp— sketchpad used as a response item (duration mouseclick), coveringBaseResponseItemresponse collection, cursor variables and timeout behaviourloop_break_if_test.osexp— a loop whosebreak_ifcondition exits early, verifying conditional loop terminationform_consent_test.osexp— consent form widget construction and the accept/decline loop inFormConsent.run();Form._execis stubbed to simulate checking the box and clicking accept, since the loop never exits without a real responseEach experiment ends with an
inline_scriptitem asserting the expected runtime variables (response_time_*,correct_*,cursor_*,delay_*, loop variables), following the pattern already used byresponse_test.osexpandloop_test.osexp. Responses and forms time out deterministically because no input devices exist headless.SDL_AUDIODRIVER=dummyis set so the sound items do not require audio hardware.Why headless?
SDL_VIDEODRIVER=dummy/SDL_AUDIODRIVER=dummy/QT_QPA_PLATFORM=offscreenmean no display, no audio device, and no real input — timeouts make responses reproducible.Coverage impact
libopensesame/mouse_response.py0% → 71%libopensesame/feedback.py0% → 84%libopensesame/sampler.py0% → 73%libopensesame/synth.py0% → 82%openexp/_mouse/legacy.py0% → 61%openexp/_sampler/legacy.py0% → 60%openexp/_keyboard/legacy.py71% → 72% (keyrelease path)libopensesame/widgets/_form.py0% → 69%opensesame_plugins/core/form_base/form_base.py0% → 78%opensesame_plugins/core/form_multiple_choice/form_multiple_choice.py0% → 75%opensesame_plugins/core/form_text_input/form_text_input.py0% → 82%opensesame_plugins/core/form_text_display/form_text_display.py0% → 92%opensesame_plugins/core/form_consent/form_consent.py0% → 74%libopensesame/loop.pybreak-if path andlibopensesame/sketchpad.pyresponse collection now exercised end-to-endTest plan
pytest tests/headless tests/basic— 16 passed locally