summaryrefslogtreecommitdiff
path: root/chess-test.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-09-01 03:47:23 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-09-01 05:05:20 -0400
commit733d0c3163a0438c06f0c902734f0bb439e9def6 (patch)
treebc861e78d0f439e163ac2799953da9cf91a4dcf0 /chess-test.el
parente02e36b9e62af44091cdf98c1ab4e153b5d55c82 (diff)
When a testing error occurs, mention the exact test that failed along with
the cause. Also, make it so that a failing test does not stop all the tests from running.
Diffstat (limited to 'chess-test.el')
-rw-r--r--chess-test.el76
1 files changed, 41 insertions, 35 deletions
diff --git a/chess-test.el b/chess-test.el
index 2446982..c54b91b 100644
--- a/chess-test.el
+++ b/chess-test.el
@@ -18,30 +18,31 @@
(message "Opening chess database '%s'" file)
- (let ((database (chess-database-open file)))
+ (let ((database (chess-database-open file))
+ error-occurred)
(if database
(progn
(message "Running validation suite...")
- (condition-case err
- (let* ((db-count (chess-database-count database))
- (ply-count 0)
- (index (if start
- (max start 1)
- 1))
- (last-index (if (and count (> count 0))
- (min db-count (+ index count))
- db-count))
- (begin (current-time))
- (read-count 0))
- (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.
- ;;
- ;; jww (2008-08-31): We should add some extra checks here, if we
- ;; want to verify the final position and such.
+ (let* ((db-count (chess-database-count database))
+ (ply-count 0)
+ (index (if start
+ (max start 1)
+ 1))
+ (last-index (if (and count (> count 0))
+ (min db-count (+ index count))
+ db-count))
+ (begin (current-time))
+ (read-count 0))
+ (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.
+ ;;
+ ;; jww (2008-08-31): We should add some extra checks here, if we
+ ;; want to verify the final position and such.
+ (condition-case err
(let ((game (chess-database-read database index)))
(when game
(setq read-count (1+ read-count)
@@ -55,19 +56,24 @@
(time-to-seconds
(subtract-time (current-time)
begin))))))))
- (setq index (1+ index)))
- (message "Read %d games (up to game %d): %d plies (%.2f ply/sec, %.2f seconds)"
- read-count index ply-count
- (/ (float ply-count)
- (float
- (time-to-seconds
- (subtract-time (current-time)
- begin))))
- (time-to-seconds (subtract-time (current-time)
- begin)))
- (message "Running validation suite...done"))
- (t
- (error "Failed to open chess database '%s'" file)))
- (chess-database-close database)))))
+ (error
+ (setq error-occurred t)
+ (message "Error reading game %d: %s"
+ index (error-message-string err))))
+ (setq index (1+ index)))
+ (message "Read %d games (up to game %d): %d plies (%.2f ply/sec, %.2f seconds)"
+ read-count index ply-count
+ (/ (float ply-count)
+ (float
+ (time-to-seconds
+ (subtract-time (current-time)
+ begin))))
+ (time-to-seconds (subtract-time (current-time)
+ begin)))
+ (message "Running validation suite...done")
+ (chess-database-close database)))
+ (error "Failed to open chess database '%s'" file))
+ (if error-occurred
+ (error "Some of the tests failed"))))
;;; chess-test.el ends here