#!/bin/sh
set -eu
umask 077
lane=$1
shift
case "$lane:$(pwd)" in
 B:/tmp/cdx-weight-B.OCutZD) runtime_php=/usr/local/php7.3/bin/php ;;
 C:/tmp/cdx-weight-C.2dCrh9) runtime_php=/www/server/php/73/bin/php ;;
 *) exit 78 ;;
esac
mkdir -p reports
for label in "$@"; do
 "$runtime_php" worker.php "$lane" prepare "$label" >"reports/$label.prepare.log" 2>&1
 if node /tmp/cdx-apifox-cli-2.2.8-cache/package/bin/cli.js run private-suite.json -r json --out-dir reports --out-file "$label" --timeout-request 30000 --silent >"reports/$label.cli.log" 2>&1; then
  printf '%s %s CLI_PASS\n' "$lane" "$label"
 else
  printf '%s %s CLI_FAIL\n' "$lane" "$label"
 fi
done
