1#!/bin/sh
2
3# Run every puzzle in benchmarking mode, and generate a file of raw
4# data that benchmark.pl will format into a web page.
5#
6# Expects to be run in the cmake build directory, where it can find
7# both the game binaries themselves and the file gamelist.txt that
8# lists them.
9
10# If any arguments are provided, use those as the list of games to
11# benchmark. Otherwise, read the full list from gamelist.txt.
12if test $# = 0; then
13    set -- $(cat gamelist.txt)
14fi
15
16failures=false
17
18for game in "$@"; do
19    # Use 'env -i' to suppress any environment variables that might
20    # change the preset list for a puzzle (e.g. user-defined extras)
21    presets=$(env -i ./$game --list-presets | cut -f1 -d' ')
22    for preset in $presets; do
23	if ! env -i ./$game --test-solve --time-generation \
24                            --generate 100 $preset;
25        then
26            echo "${game} ${preset} failed to generate" >&2
27        fi
28    done
29done
30
31if $failures; then exit 1; fi
32