autobib / autobib

A command-line tool for managing bibliographic records
GNU Affero General Public License v3.0
5 stars 0 forks source link

Improve testing setup #134

Open alexrutar opened 1 day ago

alexrutar commented 1 day ago

The testing setup is a bit verbose and requires a lot of copy-pasting. Also, I am somewhat worried about tests overlapping since in some of the cases there are multiple tests which overlap and run on the same 'testing instance'.

I guess it would be nice to have a convenient 'meta-command' which executes a list of arguments, with expected success / failure and with associated stdout / stderr assertions, and handles the TestState::init and TestState::close boilerplate automatically. Also we should import predicate::str::contains..

I guess internally there could be a TestCommand struct which contains the arguments, whether it should succeed or fail, and then possibly some predicates to execute on stdout or stderr. The annoyance is that we cannot store predicates internally inside such a struct since predicates all have different types / signatures, so perhaps correct way to do this would be to have a macro.

wupr commented 1 day ago

Let's have a macro!