#!/bin/sh

#########################################################################
#                                                                       #
#                                 OCaml                                 #
#                                                                       #
#                Damien Doligez, Jane Street Capital                    #
#                                                                       #
#   Copyright 2014 Institut National de Recherche en Informatique et    #
#   en Automatique.  All rights reserved.  This file is distributed     #
#   under the terms of the Q Public License version 1.0.                #
#                                                                       #
#########################################################################

testflags=
while : ; do
    case $1 in
        -no-byte) testflags="$testflags -no-byte"; shift;;
        -no-opt) testflags="$testflags -no-opt"; shift;;
        *) break;;
    esac
done

for d in "$@"; do
    find "$d" -name '*.t' \
      | LC_ALL=C sort \
      | xargs -L 1 scripts/runtest $testflags 3>&1 >>_full-log 2>&1 \
      | tee -a _log
done

if [ "$1" = "tests" ]; then
    expected=`sed -e 2q num-tests`
else
    expected=
fi

awk -f scripts/summary _log expected="$expected"
