Makefile: unit-tests target improvements
Currently Makefile assumes all dirs (drivers or not) either have unit tests, or will at least run under go test A manual list ($(NOTESTS)) variable is used to exclude anything problematic (usually code that imports machine which doesn't compile under 'vanilla go' used for running go test)
This is rather inflexible and has a few problems:
- It requires manually updating for each new driver that uses the 'machine` package (or non-driver content)
- It's impossible to nest packages, in particular say
parent/childwherechildmay have unit tests. - The output of
make unit-testcontains many superfluous lines like:? tinygo.org/x/drivers/adxl345 [no test files]where the package doesn't have any tests but doesn't fail either.
I propose an improvement to recursively identify which dirs contain files with names matching *_test.go and only run go test on those dirs. A manual exclusion list can be retained for convenience.
I've submitted #427 as a candidate to resolve this.
In case you wonder "Why?" - my motivation for this stems from fixing #422 and adding support for #421. Whilst the devices are GPIO based (requiring importing machine package) there are some protocol packet assembly/disassembly logic functions indpendent of that, which I'd like to include unit tests for.
Currently this isn't possible if the tests are included in the same package (irremote in my case) as any code that imports machine, even in separate .go files. So I decided to split the protocol specifics out into a separate package. The choices then are:
- Another top level package, e.g.
irprotocolas a sibling ofirremote(and all other drivers) - A nested package, e.g.
irremote/irprotocol
I think the second option is preferable from an organization viewpoint. This necessitates the change to Makefile to allow testing of irremote/irprotocol whilst excluding irremote
Closing since merged in v0.22.0