Makefile 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. SCRIPTS_DIR := buildroot/share/scripts
  2. CONTAINER_RT_BIN := docker
  3. CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio
  4. CONTAINER_IMAGE := marlin-dev
  5. help:
  6. @echo "Tasks for local development:"
  7. @echo "* tests-single-ci: Run a single test from inside the CI"
  8. @echo "* tests-single-local: Run a single test locally"
  9. @echo "* tests-single-local-docker: Run a single test locally, using docker"
  10. @echo "* tests-all-local: Run all tests locally"
  11. @echo "* tests-all-local-docker: Run all tests locally, using docker"
  12. @echo "* setup-local-docker: Build the local docker image"
  13. @echo ""
  14. @echo "Options for testing:"
  15. @echo " TEST_TARGET Set when running tests-single-*, to select the"
  16. @echo " test. If you set it to ALL it will run all "
  17. @echo " tests, but some of them are broken: use "
  18. @echo " tests-all-* instead to run only the ones that "
  19. @echo " run on GitHub CI"
  20. @echo " ONLY_TEST Limit tests to only those that contain this, or"
  21. @echo " the index of the test (1-based)"
  22. @echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
  23. @echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
  24. @echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
  25. .PHONY: help
  26. tests-single-ci:
  27. export GIT_RESET_HARD=true
  28. $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET)
  29. .PHONY: tests-single-ci
  30. tests-single-local:
  31. @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local" ; return 1; fi
  32. export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
  33. && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
  34. && run_tests . $(TEST_TARGET) "$(ONLY_TEST)"
  35. .PHONY: tests-single-local
  36. tests-single-local-docker:
  37. @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
  38. @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
  39. $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)"
  40. .PHONY: tests-single-local-docker
  41. tests-all-local:
  42. export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
  43. && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
  44. && for TEST_TARGET in $$($(SCRIPTS_DIR)/get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
  45. .PHONY: tests-all-local
  46. tests-all-local-docker:
  47. @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
  48. $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
  49. .PHONY: tests-all-local-docker
  50. setup-local-docker:
  51. $(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
  52. .PHONY: setup-local-docker