EXAMPLE_FILES ?= $(wildcard examples/*.json)
JSON_FILES ?= $(wildcard *json)

# for single test run do
# EXAMPLE_FILES=examples/editor.commits_approve_response.json JSON_FILES= make test
test:
	@for json_file in $(JSON_FILES); do \
		/usr/bin/jsonlint-php $$json_file || echo -e $$json_file "\033[01;31mFAILED\033[0m"; \
	done; \
	for json_file in $(EXAMPLE_FILES); do \
		/usr/bin/jsonlint-php $$json_file || echo -e $$json_file "\033[01;31mFAILED\033[0m"; \
	done; \
	cd ../../../../../tools/json-validator && ya make -r && cd -; \
	for file in $(EXAMPLE_FILES); do \
		schema=`basename $$file .json`.schema.json; \
		if [ -f $$schema ]; then \
			../../../../../tools/json-validator/json-validator -i $$file -s $$schema || echo -e $$file "\033[01;31mFAILED\033[0m"; \
		else echo -e schema for $$file "\033[01;31mNOT FOUND\033[0m"; \
		fi; \
	done
