Skip to content

Commit 5149809

Browse files
sjasonsmithRPGFabi
authored andcommitted
✅ Unit test improvements (MarlinFirmware#26993)
- Reset config.ini in restore_configs - Allow running a single configuration of unit tests locally
1 parent 89cd4c4 commit 5149809

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

Makefile

+13-17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ SCRIPTS_DIR := buildroot/share/scripts
22
CONTAINER_RT_BIN := docker
33
CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio
44
CONTAINER_IMAGE := marlin-dev
5+
UNIT_TEST_CONFIG ?= default
56

67
help:
78
@echo "Tasks for local development:"
@@ -12,12 +13,11 @@ help:
1213
@echo "make tests-single-local-docker : Run a single test locally, using docker"
1314
@echo "make tests-all-local : Run all tests locally"
1415
@echo "make tests-all-local-docker : Run all tests locally, using docker"
15-
# @echo "make unit-test-single-ci : Run a single code test from inside the CI"
16-
# @echo "make unit-test-single-local : Run a single code test locally"
17-
# @echo "make unit-test-single-local-docker : Run a single code test locally, using docker-compose"
16+
@echo "make unit-test-single-local : Run unit tests for a single config locally"
17+
@echo "make unit-test-single-local-docker : Run unit tests for a single config locally, using docker"
1818
@echo "make unit-test-all-local : Run all code tests locally"
19-
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker-compose"
20-
@echo "make setup-local-docker : Setup local docker-compose"
19+
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker"
20+
@echo "make setup-local-docker : Setup local docker using buildx"
2121
@echo ""
2222
@echo "Options for testing:"
2323
@echo " TEST_TARGET Set when running tests-single-*, to select the"
@@ -27,6 +27,9 @@ help:
2727
@echo " run on GitHub CI"
2828
@echo " ONLY_TEST Limit tests to only those that contain this, or"
2929
@echo " the index of the test (1-based)"
30+
@echo " UNIT_TEST_CONFIG Set the name of the config from the test folder, without"
31+
@echo " the leading number. Default is 'default'". Used with the
32+
@echo " unit-test-single-* tasks"
3033
@echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
3134
@echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
3235
@echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
@@ -59,19 +62,12 @@ tests-all-local-docker:
5962
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
6063
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
6164

62-
#unit-test-single-ci:
63-
# export GIT_RESET_HARD=true
64-
# $(MAKE) unit-test-single-local TEST_TARGET=$(TEST_TARGET)
65+
unit-test-single-local:
66+
platformio run -t marlin_$(UNIT_TEST_CONFIG) -e linux_native_test
6567

66-
# TODO: How can we limit tests with ONLY_TEST with platformio?
67-
#unit-test-single-local:
68-
# @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local" ; return 1; fi
69-
# platformio run -t marlin_$(TEST_TARGET)
70-
71-
#unit-test-single-local-docker:
72-
# @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local-docker" ; return 1; fi
73-
# @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
74-
# $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-single-local TEST_TARGET=$(TEST_TARGET) ONLY_TEST="$(ONLY_TEST)"
68+
unit-test-single-local-docker:
69+
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
70+
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-single-local UNIT_TEST_CONFIG=$(UNIT_TEST_CONFIG)
7571

7672
unit-test-all-local:
7773
platformio run -t test-marlin -e linux_native_test

buildroot/bin/restore_configs

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ if [[ $1 == '-d' || $1 == '--default' ]]; then
77
else
88
git checkout Marlin/Configuration.h 2>/dev/null
99
git checkout Marlin/Configuration_adv.h 2>/dev/null
10+
git checkout Marlin/config.ini 2>/dev/null
1011
git checkout Marlin/src/pins/*/pins_*.h 2>/dev/null
1112
fi

0 commit comments

Comments
 (0)