From 6f6714596aa07557a2c997f63776a35e14a9b313 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 2 Jan 2024 15:55:08 -0800 Subject: [PATCH] add board size tests These fail in a way that I think is unique to the curses app, so I'm not fixing them right away. --- xwords4/linux/scripts/netGamesTest.py | 17 +++++++---- xwords4/linux/scripts/use_relay.sh | 44 --------------------------- 2 files changed, 11 insertions(+), 50 deletions(-) delete mode 100755 xwords4/linux/scripts/use_relay.sh diff --git a/xwords4/linux/scripts/netGamesTest.py b/xwords4/linux/scripts/netGamesTest.py index eec0530b6..1fcd39a05 100755 --- a/xwords4/linux/scripts/netGamesTest.py +++ b/xwords4/linux/scripts/netGamesTest.py @@ -297,8 +297,7 @@ class Device(): nPlayers = 1 + len(remote.guestNames) hostPosn = random.randint(0, nPlayers-1) traySize = 0 == args.TRAY_SIZE and random.randint(7, 9) or args.TRAY_SIZE - boardSize = args.BOARD_SIZE and args.BOARD_SIZE \ - or 1 + (2 * (random.randint(11, 21)//2)) + boardSize = random.choice(range(args.BOARD_SIZE_MIN, args.BOARD_SIZE_MAX+1, 2)) response = self._sendWaitReply('makeGame', nPlayers=nPlayers, hostPosn=hostPosn, dict=args.DICTS[0], boardSize=boardSize, @@ -739,8 +738,10 @@ def mkParser(): parser.add_argument('--force-tray', dest = 'TRAY_SIZE', default = 0, type = int, help = 'Always this many tiles per tray') - parser.add_argument('--board-size', dest = 'BOARD_SIZE', type = int, default = 0, - help = 'Use x size board') + parser.add_argument('--board-size-min', dest = 'BOARD_SIZE_MIN', type = int, default = 11, + help = 'give boards at least this many rows and columns') + parser.add_argument('--board-size-max', dest = 'BOARD_SIZE_MAX', type = int, default = 23, + help = 'give boards no more than this many rows and columns') parser.add_argument('--rematch-level', dest = 'REMATCH_LEVEL', type = int, default = 0, help = 'rematch games down to this ancestry/depth') @@ -771,6 +772,11 @@ def parseArgs(): def assignDefaults(args): if len(args.DICTS) == 0: args.DICTS.append('CollegeEng_2to8.xwd') + assert 1 == (args.BOARD_SIZE_MAX % 2) + assert 1 == (args.BOARD_SIZE_MIN % 2) + assert args.BOARD_SIZE_MAX >= args.BOARD_SIZE_MIN + assert args.BOARD_SIZE_MIN >= 11 + assert args.BOARD_SIZE_MAX <= 23 def termHandler(signum, frame): global gDone @@ -783,8 +789,7 @@ def initLogs(): scriptName = os.path.splitext(os.path.basename(sys.argv[0]))[0] logdir = scriptName + '_logs' if os.path.exists(logdir): - shutil.rmtree(logdir) - # shutil.move(logdir, '/tmp/' + logdir + '_' + str(random.randint(0, 100000))) + shutil.move(logdir, '/tmp/{}_{}'.format(logdir, os.getpid())) os.mkdir(logdir) logfilepath = '{}/{}_log.txt'.format(logdir, scriptName) diff --git a/xwords4/linux/scripts/use_relay.sh b/xwords4/linux/scripts/use_relay.sh deleted file mode 100755 index 75e3175f0..000000000 --- a/xwords4/linux/scripts/use_relay.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -COOKIE=$$ -GUEST_COUNT=1 - -usage() { - echo "usage: $0: \\" - echo " [-q] # quit after done \\" - echo " [-g <1..3>] # num guest devices; default: 1 \\" - exit 0 -} - -while [ -n "$1" ]; do - case $1 in - -q) - QUIT="-q 2" - ;; - -g) - GUEST_COUNT=$2 - if [ $GUEST_COUNT -lt 1 -o $GUEST_COUNT -gt 3 ]; then - usage - fi - shift - ;; - *) - usage - ;; - esac - shift -done - -NUM=0 # not strictly needed.... -for NAME in Kati Brynn Ariela; do - ./obj_linux_memdbg/xwords -d dict.xwd -r $NAME -a localhost -p 10999 -C $COOKIE $QUIT & - - REMOTES="$REMOTES -N" - NUM=$((NUM+1)) - [ $NUM -ge $GUEST_COUNT ] && break -done - -./obj_linux_memdbg/xwords -d dict.xwd -r Eric -s $REMOTES -a localhost -p 10999 -C $COOKIE $QUIT & - -wait -