Skip to content
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

Use Xephyr in automated tests #37

Merged
merged 23 commits into from
Dec 5, 2024
Merged

Use Xephyr in automated tests #37

merged 23 commits into from
Dec 5, 2024

Conversation

ntBre
Copy link
Owner

@ntBre ntBre commented Dec 5, 2024

This is currently a rough proof-of-concept for running actual tests of the window manager using Xephyr. The example test here is not particularly interesting (checking that clicking the layout icon changes layouts), but the idea of spawning Xephyr and (effectively) calling main should be very useful for writing tests.

As noted in the code, the sleep call to wait for Xephyr to start isn't great, and both the setup and takedown code should be reused from main rather than being copy-pasted from it. Something that isn't even clear from the code is that the CONFIG will automatically be loaded from the default config path too, so currently this test could behave differently on different users' machines.

It's also obviously not safe to run more than one of these tests at a time because each test would be mutating the global DPY, XCON, etc variables. For now, I think it makes sense to have only a single test of this form and have it run through multiple sets of XEvents and corresponding assertions about the WM state.

@ntBre ntBre merged commit 147d42b into fig Dec 5, 2024
6 checks passed
@ntBre ntBre deleted the xephyr-tests branch December 5, 2024 20:05
ntBre added a commit that referenced this pull request Jan 19, 2025
* replace topbar with bool

* showbar bool

* add a toml config file for a few basic options

* more fields on config and make some bools

* move fonts into config, reset default to 10 like dwm

* take fontcount from fonts.len() directly

* loop over fonts directly

* load tags from config

* switch config from toml to fig

* working on colors

* finish colors

* update to fig with int and float

* document get_colors

* experimenting with dmenucmd and key handling in fig

for dmenucmd, I think I'm just going to drop the dmenumon thing and add that
manually as an argument. I need to go ahead and move spawn to use Rust command
stuff too

I'm going to have to make Arg an enum too, I think. it's just not really clear
how to start passing around termcmd and dmenucmd Args that I get from fig. the
current setup really depends on them being pointers that I can reference in the
key definitions. any Key that takes an Arg.v is potentially a problem, but
hopefully I can handle it by introducing multiple enum variants, one for each
actual type the *void points to

* convert Arg to an enum

* make key_handlers rust fns for unwinding

* log some args

* fix incorrect types for setlayout and view

* add layout index variant for Arg

* replace MODKEY | ShiftMask with S_MOD

* reorder and replace Mod + Ctrl + Shift too

* Arg::V doesn't need to be void anymore

* don't make Arg Copy

* use rust strings and Command::spawn for spawn

* move KEYS to CONFIG

* make keys a vec

* go through get_keys

* work on loading keys from config

* move key module to its own file

* successfully load keys from a Fig file

* add systray config options

* add xembed #defines

* add atoms

* add Systray struct

* add most of the code, minus remaining systray functions

* impl updatesystrayicongeom

* impl updatesystrayiconstate

* impl wintosystrayicon

* impl systraytomon

* const -> static to prevent constant comparison error lint

* impl updatesystray

* handle clippy

* make SYSTRAYONLEFT a bool

* make SHOWSYSTRAY a bool

* make SYSTRAYPINNINGFAILFIRST a bool

* use new try_into impl

* tidy imports

* remove some pubs to see what needs to be loaded still

* add Pertag and allocate one when creating a Monitor

* update focusstack and setlayout

* update togglebar, setmfact, and toggleview

* update view

* actually capture the chained assignment semantics

* realize that I had two separate view functions, clippy for mem::swap

* fix off-by-one for pertag

* make isfullscreen bool

* Implement window swallowing (#24)

* update Rule struct, add st example

* update Client

* make isfloating bool

* impl swallow, add XCON

* impl unswallow

* progress on swallowing with horrifying process management

* finish swallowing?

* delete unused xcon

* add rule to example.fig

* use rules from config

* move other config options to CONFIG

* import CONFIG everywhere instead of config::CONFIG

* break buttons and layouts, last two field for CONFIG

* load buttons and layouts from config

* rename fields for clippy

* simplify float and bool

* simplify str_list and make sure it works

* add fullscreen toggle from my dwm config

* Add scratchpad patch (#25)

* work on scratchpad

* finish scratchpad

* fix width -> height

* try another found approach

currently it always spawns a new scratchpad instead of toggling

* take scratchpadname from config

* allow binding togglescratch

as it turns out, scratchpadcmd doesn't even need to be a field on Config. the
user can just use it directly in their config file, and it gets called like any
other function. the title of the spawned window just needs to match
`scratchpadname` for everything to work properly

* make sure cstring lives long enough

I thought I was being clever keeping it in the match, but after checking the
docs again (and crashing my window manager) I see that it's *my* responsibility
to ensure the string lives long enough for the pointer to be valid

* use normal string comparison

I was getting really weird crashes/freezes with the other code, hopefully this
resolves the issue

* Revert "use normal string comparison"

This reverts commit 459e7fc.

* Revert "make sure cstring lives long enough"

This reverts commit 260bd61.

* really fix scratchpad (I hope)

this seems less hacky and also actually selects the window

* Merge master into `fig` and new lints (#32)

* Implement the pertag patch for dwm (#23)

* add Pertag and allocate one when creating a Monitor

* update focusstack and setlayout

* update togglebar, setmfact, and toggleview

* update view

* actually capture the chained assignment semantics

* realize that I had two separate view functions, clippy for mem::swap

* fix off-by-one

this was clear in the patch, but I just didn't include the +1. symptom was a
crash when trying to access tag 9

* make isfullscreen bool

* Implement window swallowing (#24)

* update Rule struct, add st example

* update Client

* make isfloating bool

* impl swallow, add XCON

* impl unswallow

* progress on swallowing with horrifying process management

* finish swallowing?

* delete unused xcon

* Add scratchpad patch (#25)

* work on scratchpad

* finish scratchpad

* fix width -> height

* try another found approach

currently it always spawns a new scratchpad instead of toggling

* fix duplicate pertag

* fix duplicate scratchtag code

* move fig to git dep for CI

* handle newly-denied references to static mut

https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html

* clean up some unused imports and initial value

* add xcb to fix sxiv window swallowing

* add recipe for testing with xephyr, already catching an underflow

* convert to i32 first to avoid underflow

despite h and usedfont->h being unsigned, C allows the result to be negative

I only caught this by running the debug build in xephyr, in release I guess
something reasonable was happening automatically (probably the same as C)

* fix imports for non-linux code

* try to get clippy to catch this

* Add part of the stacker patch (#33)

* add pushstack

* obey clippy

* add better docs

* add pushstack to example config

* Use Xvfb for automated tests (#37)

* test buttonpress

* wait for xephyr to start

* install xephyr

* start events module

* try starting x

* /usr/bin/X not found

* Only console users are allowed to run the X server

* need sudo

* forgot sudo echo doesn't work

* revert sudo stuff, try -ac

* use xvfb not xephyr for automated tests

* install libxcb

* try a different one

* print xcb connection error

* specify display for xcb too

* delete unused benches

* use a labeled block to avoid clippy

* try_wait after kill to handle clippy

* bring back linux cfg for xcon stuff

* xquartz might have xvfb

* try lowercase xvfb on mac

* more debugging on mac

* both xvfb and Xvfb are shown in which but PATH isn't updating

* move tests to their own file

* clippy on tests too

* Start moving global state into a `State` struct, starting with `Cursor`s (#39)

* move state into State struct TODO fix drop for Cur

* clippy fix

* fix segfault by restoring cur_free

* use drw on Cur, moving back toward Drop

* go back to Drop, segfault is fixed

* delete CURSOR comment

* handle clippy

* plumb State with BH through everything

* move atoms into State

* make sure rwm exits successfully in xephyr

* move DPY into state

* move SW into state and finally have to pass &mut State everywhere

* move all cleanup code into `cleanup`

* missing state for macos

* move DRW into state

* hold a Drw not *mut Drw

* add notes on drw::free

* switch to Vec<Fnt>

* state.SELMON

* lowercase selmon

* delete leftover drw comment

* state.MONS

* lowercase mons

* state.STEXT

* lowercase stext

* use &raw instead of addr_of

* move state to its own module and file

* state.scheme

* use Vecs of colors

* add newtype ClrScheme for nicer indexing

* make Monitor hold Pertag, not *mut Pertag

* mac should also have Xvfb

* make rect take &mut Drw

* make invert bool

* use refs

* allow clippy fix when dirty

* more refs

* font_getexts never used h

* clean up some more unused unsafe

* make charexists bool

* utf8decode was only called with clen = UTF_SIZ

* Delete UTF-8 decoding, switch to String (#40)

* make rect take &mut Drw

* make invert bool

* use refs

* allow clippy fix when dirty

* more refs

* font_getexts never used h

* clean up some more unused unsafe

* make charexists bool

* utf8decode was only called with clen = UTF_SIZ

* mostly working, but title is always `broken` in xephyr

* initialize client name to avoid precondition violation

* remove size argument to gettextprop

* update screen size in xephyr

* debugging missing emojis in xephyr

* fix emojis by actually setting utf8codepoint

* fix some characters in title

* char::from is a little nicer, then give up for now

* state.sh

* state.root and state.screen

* state.lrpad

* clean up some lrpad arithmetic

* move almost all static mut into state

* move xerrorlib where it's used and document its necessity

* own systray

* fix mac xcon issues

* Use Lua for configuration (#42)

* derive deserialize for config, with some intermediates for fn ptrs

* add insta, load a Config from lua

* ok_or

* move CONFIG init to Config::load_home

* allow unused for now

* move config to lib and CONFIG to state

* clippy fix

* lowercase config

* delete fig, use lua, check Key loading

* custom Debug impl for Key for reproducible snapshots

* update dmenucmd and test buttons

* add layouts

* install lua

* ubuntu requires specifying lua5.4

* also install liblua5.4

* rename main_ to core

* start generating tag keys

* finish the default config

* move docs to config.lua

* take defaults entirely from lua

* update config path

* don't load config twice

* use previously-defined scratchpad name

* make way more keys available in the default config

* run clippy with nightly

* fix new operator precedence lint

* include xf86 keys too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant