1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-26 21:36:21 +00:00

Unit test improvements (#26993)

- Reset config.ini in restore_configs
- Allow running a single configuration of unit tests locally
This commit is contained in:
Jason Smith 2024-04-20 23:40:26 -07:00 committed by GitHub
parent f433b2c433
commit 9e19a6efe1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 17 deletions

View File

@ -2,6 +2,7 @@ SCRIPTS_DIR := buildroot/share/scripts
CONTAINER_RT_BIN := docker
CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio
CONTAINER_IMAGE := marlin-dev
UNIT_TEST_CONFIG ?= default
help:
@echo "Tasks for local development:"
@ -12,12 +13,11 @@ help:
@echo "make tests-single-local-docker : Run a single test locally, using docker"
@echo "make tests-all-local : Run all tests locally"
@echo "make tests-all-local-docker : Run all tests locally, using docker"
# @echo "make unit-test-single-ci : Run a single code test from inside the CI"
# @echo "make unit-test-single-local : Run a single code test locally"
# @echo "make unit-test-single-local-docker : Run a single code test locally, using docker-compose"
@echo "make unit-test-single-local : Run unit tests for a single config locally"
@echo "make unit-test-single-local-docker : Run unit tests for a single config locally, using docker"
@echo "make unit-test-all-local : Run all code tests locally"
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker-compose"
@echo "make setup-local-docker : Setup local docker-compose"
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker"
@echo "make setup-local-docker : Setup local docker using buildx"
@echo ""
@echo "Options for testing:"
@echo " TEST_TARGET Set when running tests-single-*, to select the"
@ -27,6 +27,9 @@ help:
@echo " run on GitHub CI"
@echo " ONLY_TEST Limit tests to only those that contain this, or"
@echo " the index of the test (1-based)"
@echo " UNIT_TEST_CONFIG Set the name of the config from the test folder, without"
@echo " the leading number. Default is 'default'". Used with the
@echo " unit-test-single-* tasks"
@echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
@echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
@echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
@ -59,19 +62,12 @@ tests-all-local-docker:
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
#unit-test-single-ci:
# export GIT_RESET_HARD=true
# $(MAKE) unit-test-single-local TEST_TARGET=$(TEST_TARGET)
unit-test-single-local:
platformio run -t marlin_$(UNIT_TEST_CONFIG) -e linux_native_test
# TODO: How can we limit tests with ONLY_TEST with platformio?
#unit-test-single-local:
# @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local" ; return 1; fi
# platformio run -t marlin_$(TEST_TARGET)
#unit-test-single-local-docker:
# @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local-docker" ; return 1; fi
# @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
# $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-single-local TEST_TARGET=$(TEST_TARGET) ONLY_TEST="$(ONLY_TEST)"
unit-test-single-local-docker:
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-single-local UNIT_TEST_CONFIG=$(UNIT_TEST_CONFIG)
unit-test-all-local:
platformio run -t test-marlin -e linux_native_test

View File

@ -7,5 +7,6 @@ if [[ $1 == '-d' || $1 == '--default' ]]; then
else
git checkout Marlin/Configuration.h 2>/dev/null
git checkout Marlin/Configuration_adv.h 2>/dev/null
git checkout Marlin/config.ini 2>/dev/null
git checkout Marlin/src/pins/*/pins_*.h 2>/dev/null
fi