Skip to content

Commit 732e8ed

Browse files
author
matt
committed
Cleaned up after bug squishing. Several minor bugs found. Added all-rmt unit test and made it the default sole unit flow to run
1 parent caaeeb5 commit 732e8ed

28 files changed

+224
-99
lines changed

api.scm

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
((kill-server) (set! *server-run* #f))
153153

154154
;; TESTS
155-
((test-set-state-status-by-id) (apply db:test-set-state-status-by-id dbstruct params))
155+
((test-set-state-status-by-id) (apply mt:test-set-state-status-by-id dbstruct params))
156156
((delete-test-records) (apply db:delete-test-records dbstruct params))
157157
((delete-old-deleted-test-records) (apply db:delete-old-deleted-test-records dbstruct params))
158158
((test-set-state-status) (apply db:test-set-state-status dbstruct params))

client.scm

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
((http)(rmt:login-no-auto-client-setup start-res)))))
9898
(if (and start-res
9999
ping-res)
100-
(begin
100+
(let ((runremote (or area-dat *runremote*))) ;; it might have been generated only a few statements ago
101101
(remote-conndat-set! runremote start-res) ;; (hash-table-set! runremote run-id start-res)
102102
(debug:print-info 2 *default-log-port* "connected to " (http-transport:server-dat-make-url start-res))
103103
start-res)

common.scm

+9-9
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
(if (not (directory-exists? "logs"))(create-directory "logs"))
251251
(directory-fold
252252
(lambda (file rem)
253-
(common:debug-handle-exceptions #t
253+
(handle-exceptions
254254
exn
255255
(debug:print-info 0 *default-log-port* "failed to rotate log " file ", probably handled by another process.")
256256
(let* ((fullname (conc "logs/" file))
@@ -293,7 +293,7 @@
293293
((and (file-exists? mtconf) (file-exists? dbfile) (not read-only)
294294
(eq? (current-user-id)(file-owner mtconf))) ;; safe to run -cleanup-db
295295
(debug:print 0 *default-log-port* " I see you are the owner of megatest.config, attempting to cleanup and reset to new version")
296-
(common:debug-handle-exceptions #t
296+
(handle-exceptions
297297
exn
298298
(begin
299299
(debug:print 0 *default-log-port* "Failed to switch versions.")
@@ -399,9 +399,9 @@
399399
(or (getenv "MT_MEGATEST") "megatest"))
400400

401401
(define (common:read-encoded-string instr)
402-
(common:debug-handle-exceptions #t
402+
(handle-exceptions
403403
exn
404-
(common:debug-handle-exceptions #t
404+
(handle-exceptions
405405
exn
406406
(begin
407407
(debug:print-error 0 *default-log-port* "received bad encoded string \"" instr "\", message: " ((condition-property-accessor 'exn 'message) exn))
@@ -842,7 +842,7 @@
842842
(define (common:get-install-area)
843843
(let ((exe-path (car (argv))))
844844
(if (file-exists? exe-path)
845-
(common:debug-handle-exceptions #t
845+
(handle-exceptions
846846
exn
847847
#f
848848
(pathname-directory
@@ -860,7 +860,7 @@
860860
(let ((res (or (and (directory? hed)
861861
(file-write-access? hed)
862862
hed)
863-
(common:debug-handle-exceptions #t
863+
(handle-exceptions
864864
exn
865865
#f
866866
(create-directory hed #t)))))
@@ -876,14 +876,14 @@
876876
(define (common:get-youngest glob-list)
877877
(let ((all-files (apply append
878878
(map (lambda (patt)
879-
(common:debug-handle-exceptions #t
879+
(handle-exceptions
880880
exn
881881
'()
882882
(glob patt)))
883883
glob-list))))
884884
(fold (lambda (fname res)
885885
(let ((last-mod (car res))
886-
(curmod (common:debug-handle-exceptions #t
886+
(curmod (handle-exceptions
887887
exn
888888
0
889889
(file-modification-time fname))))
@@ -1235,7 +1235,7 @@
12351235
(define nice-path common:nice-path)
12361236

12371237
(define (common:read-link-f path)
1238-
(common:debug-handle-exceptions #t
1238+
(handle-exceptions
12391239
exn
12401240
(begin
12411241
(debug:print-error 0 *default-log-port* "command \"/bin/readlink -f " path "\" failed.")

common_records.scm

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
;; (define-syntax common:handle-exceptions
3232
;; (syntax-rules ()
33-
;; ((_ exn-in errstmt ...)(common:debug-handle-exceptions #t exn-in errstmt ...))))
33+
;; ((_ exn-in errstmt ...)(handle-exceptions exn-in errstmt ...))))
3434

3535
(define-syntax common:debug-handle-exceptions
3636
(syntax-rules ()

configf.scm

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
var value metadata: metadata)))
5252

5353
(define (config:eval-string-in-environment str)
54-
(common:debug-handle-exceptions #t
54+
(handle-exceptions
5555
exn
5656
(begin
5757
(debug:print-error 0 *default-log-port* "problem evaluating \"" str "\" in the shell environment")
@@ -111,7 +111,7 @@
111111
;; ((rget) (conc "(lambda (ht)(runconfigs-get ht \"" cmd "\"))"))
112112
(else "(lambda (ht)(print \"ERROR\") \"ERROR\")"))))
113113
;; (print "fullcmd=" fullcmd)
114-
(common:debug-handle-exceptions #t
114+
(handle-exceptions
115115
exn
116116
(begin
117117
(debug:print 0 *default-log-port* "WARNING: failed to process config input \"" l "\"")

dashboard-tests.scm

+3-3
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,15 @@
467467
;; needed. Revisit this.
468468
(runconfig (let ((runconfigf (conc *toppath* "/runconfigs.config"))) ;; no rush but it would be good to convert this call to use runconfig:read
469469
(if (file-exists? runconfigf)
470-
(common:debug-handle-exceptions #t
470+
(handle-exceptions
471471
exn
472472
#f ;; do nothing, just keep on trucking ....
473473
(setup-env-defaults runconfigf run-id (make-hash-table) keydat environ-patt: keystring))
474474
(make-hash-table))))
475475
(testconfig (begin
476476
;; (runs:set-megatest-env-vars run-id inrunname: runname testname: test-name itempath: item-path)
477477
(runs:set-megatest-env-vars run-id inkeyvals: keydat inrunname: runname intarget: keystring testname: testname itempath: item-path) ;; these may be needed by the launching process
478-
(common:debug-handle-exceptions #t
478+
(handle-exceptions
479479
exn ;; NOTE: I've no idea why this was written this way. Research, study and fix needed!
480480
(tests:get-testconfig (db:test-get-testname testdat) (db:test-get-item-path testdat) test-registry #f)
481481
(tests:get-testconfig (db:test-get-testname testdat) item-path test-registry #t))))
@@ -515,7 +515,7 @@
515515
request-update))
516516
(newtestdat (if need-update
517517
;; NOTE: BUG HIDER, try to eliminate this exception handler
518-
(common:debug-handle-exceptions #t
518+
(handle-exceptions
519519
exn
520520
(debug:print-info 0 *default-log-port* "test db access issue in examine test for run-id " run-id ", test-id " test-id ": " ((condition-property-accessor 'exn 'message) exn))
521521
(rmt:get-test-info-by-id run-id test-id )))))

dashboard.scm

+5-5
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ Misc
19011901
(result-child #f))
19021902
(if (and (file-exists? source)
19031903
(file-read-access? source))
1904-
(common:debug-handle-exceptions #t
1904+
(handle-exceptions
19051905
exn
19061906
(begin
19071907
(print-call-chain)
@@ -1913,7 +1913,7 @@ Misc
19131913
(debug:print 0 *default-log-port* "ERROR: cannot find file to load: \"" source "\" for user view " view-name)))
19141914
;; now run the user supplied definition for the tab view
19151915
(if success
1916-
(common:debug-handle-exceptions #t
1916+
(handle-exceptions
19171917
exn
19181918
(begin
19191919
(print-call-chain)
@@ -1930,7 +1930,7 @@ Misc
19301930
(if success
19311931
(dboard:commondat-add-updater commondat
19321932
(lambda ()
1933-
(common:debug-handle-exceptions #t
1933+
(handle-exceptions
19341934
exn
19351935
(begin
19361936
(print-call-chain)
@@ -2717,7 +2717,7 @@ Misc
27172717
;; (tasks:open-db)
27182718

27192719
(define (dashboard:get-youngest-run-db-mod-time dbdir)
2720-
(common:debug-handle-exceptions #t
2720+
(handle-exceptions
27212721
exn
27222722
(begin
27232723
(debug:print 0 *default-log-port* "WARNING: error in accessing databases in get-youngest-run-db-mod-time: " ((condition-property-accessor 'exn 'message) exn) " db-dir="dbdir)
@@ -3015,7 +3015,7 @@ Misc
30153015
(lambda (res t var val)
30163016
(cons (vector t var val) res))
30173017
'() db all-dat-qrystr)))
3018-
(let ((zeropt (common:debug-handle-exceptions #t
3018+
(let ((zeropt (handle-exceptions
30193019
exn
30203020
#f
30213021
(sqlite3:first-row db all-dat-qrystr))))

datashare.scm

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Version: " megatest-fossil-hash)) ;; "
230230
(writeable (file-write-access? dbpath))
231231
(dbexists (file-exists? dbpath))
232232
(handler (make-busy-timeout 136000)))
233-
(common:debug-handle-exceptions #t
233+
(handle-exceptions
234234
exn
235235
(begin
236236
(debug:print 2 *default-log-port* "ERROR: problem accessing db " dbpath
@@ -245,7 +245,7 @@ Version: " megatest-fossil-hash)) ;; "
245245
(print "ERROR: invalid path for storing database: " path))))
246246

247247
(define (open-run-close-exception-handling proc idb . params)
248-
(common:debug-handle-exceptions #t
248+
(handle-exceptions
249249
exn
250250
(let ((sleep-time (random 30))
251251
(err-status ((condition-property-accessor 'sqlite3 'status #f) exn)))

db.scm

+8-8
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
;; convert to -inline
7777
;;
7878
(define (db:first-result-default db stmt default . params)
79-
(common:debug-handle-exceptions #t
79+
(handle-exceptions
8080
exn
8181
(let ((err-status ((condition-property-accessor 'sqlite3 'status #f) exn)))
8282
;; check for (exn sqlite3) ((condition-property-accessor 'exn 'message) exn)
@@ -147,7 +147,7 @@
147147
(debug:print-info 0 *default-log-port* *api-process-request-count* " parallel api requests being processed in process " (current-process-id) ", throttling access"))
148148
(if (common:low-noise-print 600 (conc "parallel-api-requests" *max-api-process-requests*))
149149
(debug:print-info 2 *default-log-port* "Parallel api request count: " *api-process-request-count* " max parallel requests: " *max-api-process-requests*))
150-
(common:debug-handle-exceptions #t
150+
(handle-exceptions
151151
exn
152152
(begin
153153
(print-call-chain (current-error-port))
@@ -192,7 +192,7 @@
192192
;;
193193
(define (db:dbfile-path . junk) ;; run-id)
194194
(let* ((dbdir (common:get-db-tmp-area)))
195-
(common:debug-handle-exceptions #t
195+
(handle-exceptions
196196
exn
197197
(begin
198198
(debug:print-error 0 *default-log-port* "Couldn't create path to " dbdir)
@@ -261,7 +261,7 @@
261261
;; (let* ((dbfile (db:dbfile-path run-id)) ;; (conc toppath "/db/" run-id ".db"))
262262
;; (dbexists (file-exists? dbfile))
263263
;; (db (db:lock-create-open dbfile (lambda (db)
264-
;; (common:debug-handle-exceptions #t
264+
;; (handle-exceptions
265265
;; exn
266266
;; (begin
267267
;; ;; (release-dot-lock dbpath)
@@ -542,7 +542,7 @@
542542
;; NOPE: apply this same approach to all db files
543543
;;
544544
(else ;; ((equal? fname "megatest.db") ;; this file can be regenerated if needed
545-
(common:debug-handle-exceptions #t
545+
(handle-exceptions
546546
exn
547547
(begin
548548
;; (db:move-and-recreate-db dbdat)
@@ -586,7 +586,7 @@
586586
;; IFF field-name exists
587587
;;
588588
(define (db:sync-tables tbls last-update fromdb todb . slave-dbs)
589-
(common:debug-handle-exceptions #t
589+
(handle-exceptions
590590
exn
591591
(begin
592592
(debug:print 0 *default-log-port* "EXCEPTION: database probably overloaded or unreadable in db:sync-tables.")
@@ -1053,7 +1053,7 @@
10531053
#f))
10541054

10551055
(define (open-run-close-exception-handling proc idb . params)
1056-
(common:debug-handle-exceptions #t
1056+
(handle-exceptions
10571057
exn
10581058
(let ((sleep-time (random 30))
10591059
(err-status ((condition-property-accessor 'sqlite3 'status #f) exn)))
@@ -3678,7 +3678,7 @@
36783678
(let* ((dbpath (db:dbdat-get-path dbdat))
36793679
(db (db:dbdat-get-db dbdat)) ;; we'll return this so (db:delay--if-busy can be called inline
36803680
(dbfj (conc dbpath "-journal")))
3681-
(if (common:debug-handle-exceptions #t
3681+
(if (handle-exceptions
36823682
exn
36833683
(begin
36843684
(debug:print-info 0 *default-log-port* "WARNING: failed to test for existance of " dbfj)

launch.scm

+11-11
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
(begin
366366
(for-each
367367
(lambda (pid)
368-
(common:debug-handle-exceptions #t
368+
(handle-exceptions
369369
exn
370370
(begin
371371
(debug:print-info 0 *default-log-port* "Unable to kill process with pid " pid ", possibly already killed.")
@@ -380,7 +380,7 @@
380380
(thread-sleep! 5)
381381
;; (if (process:process-alive? pid)
382382
(map (lambda (pid-num)
383-
(common:debug-handle-exceptions #t
383+
(handle-exceptions
384384
exn
385385
#f
386386
(process-signal pid-num signal/kill)))
@@ -848,14 +848,14 @@
848848
(begin
849849
(if (not (file-exists? linktree))
850850
(begin
851-
(common:debug-handle-exceptions #t
851+
(handle-exceptions
852852
exn
853853
(begin
854854
(debug:print-error 0 *default-log-port* "Something went wrong when trying to create linktree dir at " linktree)
855855
(debug:print 0 *default-log-port* " message: " ((condition-property-accessor 'exn 'message) exn))
856856
(exit 1))
857857
(create-directory linktree #t))))
858-
(common:debug-handle-exceptions #t
858+
(handle-exceptions
859859
exn
860860
(begin
861861
(debug:print-error 0 *default-log-port* "Something went wrong when trying to create link to linktree at " *toppath*)
@@ -954,7 +954,7 @@
954954
;; create the directory for the tests dir links, this is needed no matter what...
955955
(if (and (not (directory-exists? lnkbase))
956956
(not (file-exists? lnkbase)))
957-
(common:debug-handle-exceptions #t
957+
(handle-exceptions
958958
exn
959959
(begin
960960
(debug:print-error 0 *default-log-port* "Problem creating linktree base at " lnkbase)
@@ -973,15 +973,15 @@
973973
(if (not not-iterated) ;; i.e. iterated
974974
(let ((iterated-parent (pathname-directory (conc lnkpath "/" item-path))))
975975
(debug:print-info 2 *default-log-port* "Creating iterated parent " iterated-parent)
976-
(common:debug-handle-exceptions #t
976+
(handle-exceptions
977977
exn
978978
(begin
979979
(debug:print-error 0 *default-log-port* " Failed to create directory " iterated-parent ((condition-property-accessor 'exn 'message) exn) ", exiting")
980980
(exit 1))
981981
(create-directory iterated-parent #t))))
982982

983983
(if (symbolic-link? lnkpath)
984-
(common:debug-handle-exceptions #t
984+
(handle-exceptions
985985
exn
986986
(begin
987987
(debug:print-error 0 *default-log-port* " Failed to remove symlink " lnkpath ((condition-property-accessor 'exn 'message) exn) ", exiting")
@@ -990,7 +990,7 @@
990990

991991
(if (not (or (file-exists? lnkpath)
992992
(symbolic-link? lnkpath)))
993-
(common:debug-handle-exceptions #t
993+
(handle-exceptions
994994
exn
995995
(begin
996996
(debug:print-error 0 *default-log-port* " Failed to create symlink " lnkpath ((condition-property-accessor 'exn 'message) exn) ", exiting")
@@ -1023,7 +1023,7 @@
10231023
(not (directory-exists? toptest-path)))
10241024
(begin
10251025
(debug:print-info 2 *default-log-port* "Creating " toptest-path " and link " lnkpath)
1026-
(common:debug-handle-exceptions #t
1026+
(handle-exceptions
10271027
exn
10281028
#f ;; don't care to catch and deal with errors here for now.
10291029
(create-directory toptest-path #t))
@@ -1035,7 +1035,7 @@
10351035
(begin ;; (let ((lnktarget (conc lnkpath "/" item-path)))
10361036
(debug:print 2 *default-log-port* "Setting up sub test run area")
10371037
(debug:print 2 *default-log-port* " - creating run area in " test-path)
1038-
(common:debug-handle-exceptions #t
1038+
(handle-exceptions
10391039
exn
10401040
(begin
10411041
(debug:print-error 0 *default-log-port* " Failed to create directory " test-path ((condition-property-accessor 'exn 'message) exn) ", exiting")
@@ -1046,7 +1046,7 @@
10461046
" to: " lnktarget)
10471047

10481048
;; If there is already a symlink delete it and recreate it.
1049-
(common:debug-handle-exceptions #t
1049+
(handle-exceptions
10501050
exn
10511051
(begin
10521052
(debug:print-error 0 *default-log-port* " Failed to re-create link " lnktarget ((condition-property-accessor 'exn 'message) exn) ", exiting")

0 commit comments

Comments
 (0)