sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.69k stars 153 forks source link

Improve tests #246

Open sezanzeb opened 2 years ago

sezanzeb commented 2 years ago
jonasBoss commented 2 years ago

I heave a few thoughts on this:

LunNova commented 2 years ago

It'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:

https://github.com/NixOS/nixpkgs/pull/155290/files#diff-abc835f871a20a77507a0632a2791efaa1d0498ce56ca7b3c88f38a64b36b990R83

sezanzeb commented 2 years ago

It then probably makes sense to split them into two directories, "integration" and "unit". Can do

sezanzeb commented 2 years ago

@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

sezanzeb commented 2 years ago

the commit hash that introduces the lags is 47bcefa, no lags on 76c3cadcfaa3f244d62bd911aa6642a86233ffa0. ffs

jonasBoss commented 2 years ago

Seems fine to me. python3 tests/test.py integration.test_gui runs in 25s

sezanzeb commented 2 years ago

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

sezanzeb commented 2 years ago

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.

jonasBoss commented 2 years ago

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

sezanzeb commented 2 years ago

@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.