summaryrefslogtreecommitdiff
path: root/chess-test.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-09-01 00:47:26 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-09-01 00:47:26 -0400
commit8ec9434a1a5e345077d6980e784d47f36483a224 (patch)
treece5db677e393546f27717e0009743d827234268d /chess-test.el
parenta2f1f41f720c5a78f4c76201da4e7fc9319d9bae (diff)
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.
Diffstat (limited to 'chess-test.el')
-rw-r--r--chess-test.el27
1 files changed, 20 insertions, 7 deletions
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.