From e96d06893c9d9cf0eb26999398cd8b3c31e80eb5 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 25 Oct 2020 12:43:36 -0700 Subject: [PATCH] Make it possible to only run a subset of the simulator tests using the TEST_PATH variable Suggested by @gendankenexperimenter --- Makefile | 2 +- docs/development/testing.md | 32 ++++++++++++++++++++++++++++++++ tests/Makefile | 4 +++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 docs/development/testing.md diff --git a/Makefile b/Makefile index 3415d2b1..a2574eb8 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ simulator-tests: prepare-virtual $(MAKE) -C tests all docker-simulator-tests: - BOARD_HARDWARE_PATH="$(BOARD_HARDWARE_PATH)" ./bin/run-docker "make simulator-tests" + BOARD_HARDWARE_PATH="$(BOARD_HARDWARE_PATH)" ./bin/run-docker "make simulator-tests TEST_PATH=\"${TEST_PATH}\"" run-tests: prepare-virtual build-gtest-gmock $(MAKE) -c tests diff --git a/docs/development/testing.md b/docs/development/testing.md new file mode 100644 index 00000000..2a22edc7 --- /dev/null +++ b/docs/development/testing.md @@ -0,0 +1,32 @@ +This is not yet proper documentation about running or writing tests, just some rough notes. + +Kaleidoscope includes a simulator that can pretend (to a certain extent) to be a keyboard for the purpose of testing. + +On most UNIX-like systems, you can run Kaleidoscope's simulator tests by running + +``` +make simulator-tests +``` + +Our simulator currently has some weird linking issues on macOS, so the easiest way to run tests on macOS is using Docker. + + +``` +make docker-simulator-tests +``` + +During development, when you may be running your tests very frequently, it's sometimes useful to run a subset of tests. + +You can control the directory that Kaleidoscope searches for test suites with the 'TEST_PATH' variable. + +To only run tests in subdirectories of the 'tests/hid' directory, you'd write: + +``` +make simulator-tests TEST_PATH=tests/hid +``` +or + +``` +make docker-simulator-tests TEST_PATH=tests/hid +``` + diff --git a/tests/Makefile b/tests/Makefile index 705304d2..4afe2f1f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,7 +4,9 @@ LIB_DIR := ${build_dir}/lib libcommon_a := ${top_dir}/_build/lib/libcommon.a -TESTS ?= $(shell find . -name 'sketch.ino' -exec dirname {} \;) +TEST_PATH ?= tests/ + +TESTS ?= $(shell find ${top_dir}/${TEST_PATH} -name 'sketch.ino' -exec dirname {} \;) .PHONY: clean cmake-clean all googletest all: ${TESTS}