@@ -8,10 +8,13 @@ ;; PURPOSE. ;; (include "common.scm") ;; (include "megatest-version.scm") +;; fakeout readline +(define (toplevel-command . a) #f) + (use sqlite3 srfi-1 posix regex regex-case srfi-69 base64 readline apropos json http-client directory-utils rpc ;; (srfi 18) extras) http-client srfi-18 extras format) ;; zmq extras) ;; Added for csv stuff - will be removed ;; @@ -62,10 +65,11 @@ (make-hash-table) ;; denoise #f ;; client signature #f ;; remote connections )) +(define *runremote* #f) ;; BUG: Remove this ASAP and update common:*remote* to not refer to *runremote* ;; Disabled help items ;; -rollup : (currently disabled) fill run (set by :runname) with latest test(s) ;; from prior runs with same keys @@ -852,18 +856,20 @@ (if (args:get-arg "-remove-runs") (general-run-call "-remove-runs" "remove runs" (lambda (target runname keys keyvals) - (operate-on 'remove-runs)))) + (operate-on 'remove-runs)) + *area-dat*)) (if (args:get-arg "-set-state-status") (general-run-call "-set-state-status" "set state and status" (lambda (target runname keys keyvals) - (operate-on 'set-state-status)))) + (operate-on 'set-state-status)) + *area-dat*)) (if (or (args:get-arg "-set-run-status") (args:get-arg "-get-run-status")) (general-run-call "-set-run-status" @@ -881,11 +887,12 @@ (let* ((row (car (vector-ref runsdat 1))) (run-id (db:get-value-by-header row header "id"))) (if (args:get-arg "-set-run-status") (rmt:set-run-status run-id (args:get-arg "-set-run-status") msg: (args:get-arg "-m")) (print (rmt:get-run-status run-id)) - ))))))) + ))))) + *area-dat*)) ;;====================================================================== ;; Query runs ;;====================================================================== @@ -1018,11 +1025,13 @@ (lambda (target runname keys keyvals) (runs:run-tests target runname (args:get-arg "-testpatt") user - args:arg-hash)))) + args:arg-hash + *area-dat*)) + *area-dat*)) ;;====================================================================== ;; run one test ;;====================================================================== @@ -1057,11 +1066,13 @@ ;; #f)))) (runs:run-tests target runname (args:get-arg "-runtests") user - args:arg-hash)))) + args:arg-hash + *area-dat*)) + *area-dat*)) ;;====================================================================== ;; Rollup into a run ;;====================================================================== @@ -1071,11 +1082,12 @@ "rollup tests" (lambda (target runname keys keyvals) (runs:rollup-run keys keyvals (or (args:get-arg "-runname")(args:get-arg ":runname") ) - user)))) + user)) + *area-dat*)) ;;====================================================================== ;; Lock or unlock a run ;;====================================================================== @@ -1088,11 +1100,12 @@ target keys (or (args:get-arg "-runname")(args:get-arg ":runname") ) (args:get-arg "-lock") (args:get-arg "-unlock") - user)))) + user)) + *area-dat*)) ;;====================================================================== ;; Get paths to tests ;;====================================================================== ;; Get test paths matching target, runname, and testpatt @@ -1136,11 +1149,12 @@ (let* ((db #f) ;; DO NOT run remote (paths (tests:test-get-paths-matching keys target (args:get-arg "-test-files")))) (for-each (lambda (path) (print path)) - paths)))))) + paths))) + *area-dat*))) ;;====================================================================== ;; Archive tests ;;====================================================================== ;; Archive tests matching target, runname, and testpatt @@ -1148,11 +1162,12 @@ ;; else do a general-run-call (general-run-call "-archive" "Archive" (lambda (target runname keys keyvals) - (operate-on 'archive)))) + (operate-on 'archive)) + *area-dat*)) ;;====================================================================== ;; Extract a spreadsheet from the runs database ;;====================================================================== @@ -1167,11 +1182,12 @@ (pathmod (args:get-arg "-pathmod"))) ;; (keyvalalist (keys->alist keys "%"))) (debug:print 2 "Extract ods, outputfile: " outputfile " runspatt: " runspatt " keyvals: " keyvals) (db:extract-ods-file dbstruct outputfile keyvals (if runspatt runspatt "%") pathmod) (db:close-all dbstruct) - (set! *didsomething* #t))))) + (set! *didsomething* #t))) + *area-dat*)) ;;====================================================================== ;; execute the test ;; - gets called on remote host ;; - receives info from the -execute param @@ -1442,13 +1458,10 @@ ;;====================================================================== ;; Start a repl ;;====================================================================== -;; fakeout readline -(define (toplevel-command . a) #f) - (if (or (args:get-arg "-repl") (args:get-arg "-load")) (let* ((toppath (launch:setup-for-run *area-dat*)) (dbstruct (if toppath (make-dbr:dbstruct path: toppath local: #t) #f))) (if dbstruct @@ -1456,15 +1469,19 @@ (set! *db* dbstruct) (set! *client-non-blocking-mode* #t) (import extras) ;; might not be needed ;; (import csi) (import readline) + (use-legacy-bindings) (import apropos) ;; (import (prefix sqlite3 sqlite3:)) ;; doesn't work ... (gnu-history-install-file-manager - (string-append - (or (get-environment-variable "HOME") ".") "/.megatest_history")) + (let ((d (string-append + (or (get-environment-variable "HOME") ".") "/.megatest"))) + (if (not (file-exists? d)) + (create-directory d #t)) + d)) (current-input-port (make-gnu-readline-port "megatest> ")) (if (args:get-arg "-repl") (repl) (load (args:get-arg "-load"))) (db:close-all dbstruct)) @@ -1539,11 +1556,12 @@ ;;====================================================================== ;; if *runremote* is defined, close connections, otherwise - trust that it was ;; taken care of. ;; -(if (common:get-remote #f #f)(close-all-connections!)) +(if (common:get-remote (megatest:area-remote *area-dat*) #f) + (close-all-connections!)) (if (not *didsomething*) (debug:print 0 help)) (set! *time-to-exit* #t)