2017-04-28 01:06:58 +08:00
|
|
|
GOOD_TESTS = $(wildcard test/good/*.json)
|
|
|
|
BAD_TESTS = $(wildcard test/bad/*.json)
|
2016-01-20 00:27:47 +08:00
|
|
|
|
2017-03-30 11:20:42 +08:00
|
|
|
default: validate
|
2016-01-20 00:27:47 +08:00
|
|
|
|
|
|
|
help:
|
2017-03-30 11:20:42 +08:00
|
|
|
@echo "Usage: make [target]"
|
2016-01-20 00:27:47 +08:00
|
|
|
@echo
|
|
|
|
@echo " * 'fmt' - format the json with indentation"
|
2017-03-30 11:20:42 +08:00
|
|
|
@echo " * 'help' - show this help information"
|
2016-01-20 00:27:47 +08:00
|
|
|
@echo " * 'validate' - build the validation tool"
|
|
|
|
|
|
|
|
fmt:
|
2017-04-28 01:06:58 +08:00
|
|
|
find . -name '*.json' -exec bash -c 'jq --indent 4 -M . {} > xx && mv xx {} || echo "skipping invalid {}"' \;
|
2016-01-20 00:27:47 +08:00
|
|
|
|
2017-03-30 11:10:58 +08:00
|
|
|
.PHONY: validate
|
2016-01-20 00:27:47 +08:00
|
|
|
validate: validate.go
|
2016-04-14 12:33:17 +08:00
|
|
|
go get -d ./...
|
2016-01-20 00:27:47 +08:00
|
|
|
go build ./validate.go
|
|
|
|
|
2017-04-28 01:06:58 +08:00
|
|
|
test: validate $(TESTS)
|
|
|
|
for TYPE in $$(ls test); \
|
|
|
|
do \
|
|
|
|
echo "testing $${TYPE}"; \
|
|
|
|
for FILE in $$(ls "test/$${TYPE}/good"); \
|
|
|
|
do \
|
|
|
|
echo " testing test/$${TYPE}/good/$${FILE}"; \
|
|
|
|
if ./validate "$${TYPE}-schema.json" "test/$${TYPE}/good/$${FILE}" ; \
|
|
|
|
then \
|
|
|
|
echo " received expected validation success" ; \
|
|
|
|
else \
|
|
|
|
echo " received unexpected validation failure" ; \
|
|
|
|
exit 1; \
|
|
|
|
fi \
|
|
|
|
done; \
|
|
|
|
for FILE in $$(ls "test/$${TYPE}/bad"); \
|
|
|
|
do \
|
|
|
|
echo " testing test/$${TYPE}/bad/$${FILE}"; \
|
|
|
|
if ./validate "$${TYPE}-schema.json" "test/$${TYPE}/good/$${FILE}" ; \
|
|
|
|
then \
|
|
|
|
echo " received unexpected validation success" ; \
|
|
|
|
exit 1; \
|
|
|
|
else \
|
|
|
|
echo " received expected validation failure" ; \
|
|
|
|
fi \
|
|
|
|
done; \
|
|
|
|
done
|
|
|
|
|
2017-04-18 17:51:15 +08:00
|
|
|
clean:
|
|
|
|
rm -f validate
|