From e059c77a4705d8ff6341d190ec9b3652e59b3ec6 Mon Sep 17 00:00:00 2001 From: Chad Metcalf Date: Sun, 9 Aug 2020 15:05:14 -0700 Subject: [PATCH] Allow testing for just examples with changed files. The full test suite takes a long time to test. Generally changes in this repo only will change one project. So lets find the directories with changes and only test those. By default we will compare against origin/master which should cover testing PRs. If you're doing development and want to test your current changes you could do: BASE_REF=HEAD make test-changed Or if you're testing against your fork: BASE_REF=myremote/branch make test-changed Signed-off-by: Chad Metcalf --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f9b50a2..ce8af42 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,14 @@ -.phony: test +.phony: test-all test-changed update-tests -test: - @bats -T -r . +BASE_REF ?= origin/master + +all: test-changed + +test-all: + @bats -T $(shell find . -name test.bats| sort ) + +test-changed: + @bats -T $(shell git diff --name-status ${BASE_REF} | awk '{print $2}' | xargs dirname | uniq | grep -v -E '^(\.|lib)' | xargs -I% echo -n " %/test.bats" ) update-tests: @find . -maxdepth 1 -type d -not -path '*/\.*' -not -path '.' -not -path './lib' -exec cp ./lib/test.bats.example {}/test.bats \;