1#!/usr/bin/env bash
2
3set -e
4
5if [[ $# -gt 0 ]]; then
6  ids=("$@")
7else
8  ids=($(cut -d: -f1 < test/libyaml-parser.list))
9fi
10
11count=0
12for id in "${ids[@]}"; do
13  dir="data/$id"
14  label="$id: $(< $dir/===)"
15  [[ -e "$dir/in.yaml" ]] || continue
16  ./src/libyaml-parser "$dir/in.yaml" > /tmp/test.out || {
17    (
18      cat "$dir/in.yaml"
19      cat "$dir/test.event"
20    ) | sed 's/^/# /'
21  }
22  ok=true
23  output="$(${DIFF:-diff} -u $dir/test.event /tmp/test.out)" || ok=false
24  if $ok; then
25    echo "ok $((++count)) $label"
26  else
27    echo "not ok $((++count)) $label"
28    echo "$output" | sed 's/^/# /'
29  fi
30done
31
32echo "1..$count"
33