...

Text file src/github.com/opencontainers/runtime-spec/schema/Makefile

Documentation: github.com/opencontainers/runtime-spec/schema

     1GOOD_TESTS = $(wildcard test/good/*.json)
     2BAD_TESTS = $(wildcard test/bad/*.json)
     3
     4default: validate
     5
     6help:
     7	@echo "Usage: make [target]"
     8	@echo
     9	@echo " * 'fmt' - format the json with indentation"
    10	@echo " * 'help' - show this help information"
    11	@echo " * 'validate' - build the validation tool"
    12
    13fmt:
    14	find . -name '*.json' -exec bash -c 'jq --indent 4 -M . {} > xx && mv xx {} || echo "skipping invalid {}"' \;
    15
    16.PHONY: validate
    17validate: validate.go
    18	GO111MODULE=auto go get github.com/xeipuuv/gojsonschema
    19	GO111MODULE=auto go build ./validate.go
    20
    21test: validate $(TESTS)
    22	for TYPE in $$(ls test); \
    23	do \
    24		echo "testing $${TYPE}"; \
    25		for FILE in $$(ls "test/$${TYPE}/good"); \
    26		do \
    27			echo "  testing test/$${TYPE}/good/$${FILE}"; \
    28			if ./validate "$${TYPE}-schema.json" "test/$${TYPE}/good/$${FILE}" ; \
    29			then \
    30				echo "    received expected validation success" ; \
    31			else \
    32				echo "    received unexpected validation failure" ; \
    33				exit 1; \
    34			fi \
    35		done; \
    36		for FILE in $$(ls "test/$${TYPE}/bad"); \
    37		do \
    38			echo "  testing test/$${TYPE}/bad/$${FILE}"; \
    39			if ./validate "$${TYPE}-schema.json" "test/$${TYPE}/bad/$${FILE}" ; \
    40			then \
    41				echo "    received unexpected validation success" ; \
    42				exit 1; \
    43			else \
    44				echo "    received expected validation failure" ; \
    45			fi \
    46		done; \
    47	done
    48
    49clean:
    50	rm -f validate

View as plain text