Open sezanzeb opened 2 years ago
I heave a few thoughts on this:
tests.toolbox
module.
tests.test
to the toolbox, that way we don't need the the workaround I implemented here: https://github.com/sezanzeb/input-remapper/pull/228/commits/da69aad60cc6025a3c644100669b389364ce92b0write toolbox functions for common data structures and method arguments. e.g.:
custom_mapping.change()
has an extra argument in the independent_uinput
branch. There are many places where I needed to change that, a simple toolbox method could have made that a lot less work.
def custom_mapping_change_args(key=Key(EV_KEY, BTN_A, 1), target="keyboard", mapping="a"):
return (key, target, mapping)
custom_mapping.change(*custom_mapping_change_args(mapping="c"))
now we only need to change the custom_mapping_change_args
function and edit the few places where we need a gampad or a mouse as target.
independent_uinput
) should not actually brake those tests, because it does not really change the behavior observed by a user.
It will obviously brake the testing, but not the test itself, only toolbox functions, that need to be adapted to account for the changed uinputsIt'd be nice to have a set of tests that are safe to run on CI and don't depend on system state to run. (The ones which are truly unit tests?)
Some tests care about timing (may fail if build machine is slow), some care about system services or start external processes, and some need a GUI.
I've been trying to package this for nixos and this is the set of tests I've ended up with that seem to be okay for CI:
It then probably makes sense to split them into two directories, "integration" and "unit". Can do
@jonasBoss are tests from test_gui super laggy for you out of nowhere as well? python3 tests/test.py integration.test_gui
even on the main branch
the commit hash that introduces the lags is 47bcefa, no lags on 76c3cadcfaa3f244d62bd911aa6642a86233ffa0. ffs
Seems fine to me. python3 tests/test.py integration.test_gui
runs in 25s
self.get("code_editor").get_buffer().set_text(symbol or "")
causes it. I can't believe it. Started to happen out of nowhere!
everything freezes up on my computer until the tests are finished if this line is executed. I'm going to do a full system upgrade now and see if that fixes anything
Tests should probably be very loose on timing requirements from now on.
They should also not use asyncio sleeps to wait until a macro is done or whatever. Instead they should wait for the coroutine to finish.
Just stumbled upon this. I think it provides valuable ideas on how we can improve and simplify our test: https://www.youtube.com/watch?v=Bq_oz7nCNUA
@jonasBoss are tests from test_gui super laggy for you out of nowhere as well?
python3 tests/test.py integration.test_gui
even on the main branch
Might have been because of a broken/bloated ssd, or maybe because of an update to dependencies in the meantime. They are not laggy anymore for me.
uinput_write_history
and only usinguinput_write_history_pipe
cleanup
instead ofquick_cleanup
. Makes tests take longer, but maybe there can be optimizations"/dev/input/event30"
) in some constructor. Instead, some constant would be good. LikeGAMEPAD = "/dev/input/event30"
or something similar, or maybe preparing an InputDevice that is ready to use for all tests for each fixture, which is reset inquick_cleanup