From 8ec9434a1a5e345077d6980e784d47f36483a224 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 1 Sep 2008 00:47:26 -0400 Subject: Allow the stress tests to be run across a specific range: make START=2000 FINISH=5000 check If START is omitted, it begins at game 1. If FINISH is omitted, it ends at the last game in the test database. --- Makefile.am | 9 +++++---- chess-test.el | 27 ++++++++++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index b4cde68..5d0ce08 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,12 +66,13 @@ chess-eco.fen: chess-eco.pos chess-eco.el -L $(srcdir) -l chess-eco -f chess-generate-fen-table \ chess-eco.pos chess-eco.fen -TESTS = chess-test - -database = test/largedb +TESTS = chess-test +DATABASE = test/largedb +START = +FINISH = chess-test: Makefile - echo "$(EMACS) -batch -L $(srcdir) -l chess-test.el -f chess-test '$(database)'" > $@ + echo "$(EMACS) -batch -L $(srcdir) -l chess-test.el -f chess-test '$(DATABASE)' $(START) $(FINISH)" > $@ chmod u+x $@ TAGS: $(dist_lisp_LISP) diff --git a/chess-test.el b/chess-test.el index 1e59566..de008a8 100644 --- a/chess-test.el +++ b/chess-test.el @@ -6,20 +6,33 @@ (require 'chess-database) (require 'chess-game) -(defun chess-test (&optional file) +(defun chess-test (&optional file start finish) (unless file - (setq file (car command-line-args-left))) + (setq file (nth 0 command-line-args-left))) + (unless start + (setq start (string-to-number (nth 1 command-line-args-left)))) + (unless finish + (setq finish (string-to-number (nth 2 command-line-args-left)))) + (message "Opening chess database '%s'" file) + (let ((database (chess-database-open file))) (if database (progn (message "Running chess unit tests...") (condition-case err - (let ((count (chess-database-count database)) - (ply-count 0) - (index 1) - (begin (current-time))) - (while (< index count) + (let* ((count (chess-database-count database)) + (ply-count 0) + (index (if start + (max start 1) + 1)) + (last-index (if finish + (min count finish) + count)) + (begin (current-time))) + (message "Testing legality of games in range [%d, %d):" + index last-index) + (while (< index last-index) ;; Reading in the game will cause it to be converted from PGN ;; (this is true currently) to a chess-game, during which time ;; every move will be tested for legality. -- cgit v1.2.3