1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

makefiles/tests: Add test-input-hash-changed target

This target allows one to check if a test-input-hash is there and if it differs from
a new one, adding basic support to skip tests if nothing needs to be run.
This commit is contained in:
MrKevinWeiss 2023-05-04 12:10:42 +02:00
parent 8a77807e57
commit 66d75f191c
No known key found for this signature in database
GPG Key ID: C26684F1C0767FFF

View File

@ -102,3 +102,26 @@ else
test-input-hash: .SECONDARY
$(file >$(RIOT_TEST_HASH_DIR)/test-input-hash.sha1,no binary generated due to RIOTNOLINK=1)
endif
# Helper function to compare two strings
define compare_strings
$(and $(filter $1,$2),$(filter $2,$1))
endef
# Target to test only if the input hash has changed
.PHONY: test-input-hash-changed
test-input-hash-changed:
@if [ ! -f "$(RIOT_TEST_HASH_DIR)/test-input-hash.sha1" ]; then \
echo "Old hash file doesn't exist. Generating hash and running tests..."; \
mkdir -p $(RIOT_TEST_HASH_DIR); \
$(MAKE) test-input-hash; \
else \
OLD_HASH=$$(cat $(RIOT_TEST_HASH_DIR)/test-input-hash.sha1); \
$(MAKE) test-input-hash; \
NEW_HASH=$$(cat $(RIOT_TEST_HASH_DIR)/test-input-hash.sha1); \
if [ "$${OLD_HASH}" != "$${NEW_HASH}" ]; then \
echo "Hashes do not match."; \
else \
echo "Hashes match."; \
fi; \
fi