From e8d11e8321fe32494b5a6339b5ee96866b3b0ec2 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 20 May 2015 13:17:51 +0100 Subject: [PATCH] Add check.sh to automatically run z-schema over all schema files and test against examples. --- event-schemas/check.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 event-schemas/check.sh diff --git a/event-schemas/check.sh b/event-schemas/check.sh new file mode 100755 index 00000000..58604640 --- /dev/null +++ b/event-schemas/check.sh @@ -0,0 +1,19 @@ +#!/bin/bash -e +# Runs z-schema over all of the schema files (looking for matching examples) +find schema/v1/m.* | while read line +do + split_path=(${line///// }) + event_type=(${split_path[2]}) + echo "Checking $event_type" + echo "--------------------" + # match exact name or exact name with a # + find examples/v1 -name $event_type -o -name "$event_type#*" | while read exline + do + echo " against $exline" + # run z-schema and dump stdout/err to the terminal (good for Jenkin's Console Output) and grep for fail messages + if [[ -n $(z-schema schema/v1/$event_type $exline 2>&1 | tee /dev/tty | grep -Ei "error|failed") ]]; then + echo " Failed." + exit 1 + fi + done +done