diff options
| -rw-r--r-- | Makefile.am | 9 | ||||
| -rw-r--r-- | 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. |
