Overview
Comment: | updated ducttape-lib to fix incompatibilities with megatest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.63-xor-report |
Files: | files | file ages | folders |
SHA1: |
ffa2b8e7afb0b1912353e3df9671df1c |
User & Date: | bjbarcla on 2017-02-01 16:01:17 |
Other Links: | branch diff | manifest | tags |
Context
2017-02-01
| ||
16:03 | updated ducttape-lib to fix incompatibilities with megatest check-in: f792807bb9 user: bjbarcla tags: v1.63-xor-report | |
16:01 | updated ducttape-lib to fix incompatibilities with megatest check-in: ffa2b8e7af user: bjbarcla tags: v1.63-xor-report | |
13:49 | enahnced -log so it will create leading directory if specified check-in: e984e41fb4 user: bjbarcla tags: v1.63-xor-report | |
Changes
Modified ducttape/ducttape-lib.scm from [07138d2aca] to [789effec13].
︙ | ︙ | |||
16 17 18 19 20 21 22 | iputs re-match? ; launch-repl keyword-skim skim-cmdline-opts-noarg-by-regex skim-cmdline-opts-withargs-by-regex concat-lists | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | iputs re-match? ; launch-repl keyword-skim skim-cmdline-opts-noarg-by-regex skim-cmdline-opts-withargs-by-regex concat-lists ducttape-process-command-line ducttape-append-logfile ducttape-activate-logfile isys do-or-die counter-maker dir-is-writable? mktemp |
︙ | ︙ | |||
44 45 46 47 48 49 50 | wwdate->isodate current-wwdate current-isodate ) (import scheme chicken extras ports data-structures ) | | > > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | wwdate->isodate current-wwdate current-isodate ) (import scheme chicken extras ports data-structures ) (use posix regex ansi-escape-sequences test srfi-1 irregex slice srfi-13 rfc3339) ;;scsh-process ;; dropping scsh-process, it was clobbering posix's process and process* (use directory-utils uuid-lib filepath srfi-19 ) ; linenoise (include "mimetypes.scm") ; provides ext->mimetype (include "workweekdate.scm") (define ducttape-lib-version 1.00) (define (toplevel-command sym proc) (lambda () #f)) ;;;; utility procedures ;; begin credit: megatest's process.scm |
︙ | ︙ | |||
180 181 182 183 184 185 186 | (define (do-or-die command #!key nodie (foreach-stdout #f) (stdin-proc #f)) (let-values (((exit-code stdout-str stderr-str) (isys command foreach-stdout-thunk: foreach-stdout stdin-proc: stdin-proc ))) (if (equal? 0 exit-code) stdout-str (begin (ierr (conc "Command > " command " " "< failed with " exit-code " because: \n" stderr-str) ) (if nodie #f (exit exit-code)))))) | < < < < < < < < < < < < < | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | (define (do-or-die command #!key nodie (foreach-stdout #f) (stdin-proc #f)) (let-values (((exit-code stdout-str stderr-str) (isys command foreach-stdout-thunk: foreach-stdout stdin-proc: stdin-proc ))) (if (equal? 0 exit-code) stdout-str (begin (ierr (conc "Command > " command " " "< failed with " exit-code " because: \n" stderr-str) ) (if nodie #f (exit exit-code)))))) ;; runs-ok: evaluate expression while suppressing exceptions. ; on caught exception, returns #f ; otherwise, returns expression value (define (runs-ok thunk) (handle-exceptions exn #f (begin (thunk) #t))) |
︙ | ︙ | |||
339 340 341 342 343 344 345 | (host (or (get-environment-variable "HOST") "nohost"))) (if logfile (begin (ducttape-log-file logfile) (setenv "DUCTTAPE_LOG_FILE" (ducttape-log-file)))) (ducttape-append-logfile 'note (format #f "START - pid=~A ppid=~A argv=(~A) pwd=~A user=~A host=~A" pid ppid argv pwd user host) #t))) | < < | < | < | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | (host (or (get-environment-variable "HOST") "nohost"))) (if logfile (begin (ducttape-log-file logfile) (setenv "DUCTTAPE_LOG_FILE" (ducttape-log-file)))) (ducttape-append-logfile 'note (format #f "START - pid=~A ppid=~A argv=(~A) pwd=~A user=~A host=~A" pid ppid argv pwd user host) #t))) ;; log exit code (define (set-ducttape-log-exit-handler) (let ((orig-exit-handler (exit-handler))) (exit-handler (lambda (exitcode) (ducttape-append-logfile 'note (format #f "Exit ~A by sys.exit" exitcode) #t) (orig-exit-handler exitcode))))) (define (idbg first-message . rest-args) (let* ((debug-level-threshold (if (> (length rest-args) 0) (car rest-args) 1)) (message-list (if (> (length rest-args) 1) (cons first-message (cdr rest-args)) |
︙ | ︙ | |||
613 614 615 616 617 618 619 | (next-rest (cdr rest-path-items)) (candidate (conc this-dir "/" exe))) (if (file-execute-access? candidate) candidate (loop next-rest))))))) | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | (next-rest (cdr rest-path-items)) (candidate (conc this-dir "/" exe))) (if (file-execute-access? candidate) candidate (loop next-rest))))))) ;;;; process command line options ;; get command line switches (have no subsequent arg; eg. [-foo]) ;; assumes these are switches without arguments ;; will return list of matches ;; removes matches from command-line-arguments parameter (define (skim-cmdline-opts-noarg-by-regex switch-pattern) |
︙ | ︙ | |||
737 738 739 740 741 742 743 | ;; recognize ducttape-lib command line switches (--quiet, --silent, --color, -d.., -dp.., -logfile) ;; - reset parameters; reset DUCTTAPE_* env vars to match user specified intent ;; - mutate (command-line-arguments) parameter to subtract these recognized and handled switches ;; * beware -- now (argv) and (command-line-arguments) are inconsistent... cannot mutate (argv) alas. Use (command-line-arguments) | > > | | 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | ;; recognize ducttape-lib command line switches (--quiet, --silent, --color, -d.., -dp.., -logfile) ;; - reset parameters; reset DUCTTAPE_* env vars to match user specified intent ;; - mutate (command-line-arguments) parameter to subtract these recognized and handled switches ;; * beware -- now (argv) and (command-line-arguments) are inconsistent... cannot mutate (argv) alas. Use (command-line-arguments) ;; WARNING: this defines command line arguments that may clash with your program. Only call this if you ;; are sure they can coexist. (define (ducttape-process-command-line) ;; --quiet (let ((quiet-opts (skim-cmdline-opts-noarg-by-regex "--?quiet"))) (if (not (null? quiet-opts)) (begin (setenv "DUCTTAPE_QUIET_MODE" "1") (ducttape-quiet-mode "1")))) |
︙ | ︙ | |||
801 802 803 804 805 806 807 808 | ;; -dp <pat> / --debug-pattern <pat> (let ((debugpat-opts (skim-cmdline-opts-withargs-by-regex "--?(debug-pattern|dp)"))) (if (not (null? debugpat-opts)) (begin (ducttape-debug-regex-filter (string-join debugpat-opts "|")) (setenv "DUCTTAPE_DEBUG_PATTERN" (ducttape-debug-regex-filter)))))) ;; handle command line immediately; | > > > > > > > > | | 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | ;; -dp <pat> / --debug-pattern <pat> (let ((debugpat-opts (skim-cmdline-opts-withargs-by-regex "--?(debug-pattern|dp)"))) (if (not (null? debugpat-opts)) (begin (ducttape-debug-regex-filter (string-join debugpat-opts "|")) (setenv "DUCTTAPE_DEBUG_PATTERN" (ducttape-debug-regex-filter)))))) ;;; following code commented out; side effects not wanted on startup ;; immediately activate logfile (will be noop if logfile disabled) ;;(ducttape-activate-logfile) ;;(set-ducttape-log-exit-handler) ;; TODO: hook exception handler so we can log exception before we sign off. ;; handle command line immediately; ;;(process-command-line) ) ; end module |
Modified ducttape/test_ducttape.scm from [be9cb91086] to [5a04bd5130].
︙ | ︙ | |||
28 29 30 31 32 33 34 | (ducttape-color-mode #f) ) (define (reset-ducttape-with-cmdline-list cmdline-list) (reset-ducttape) (command-line-arguments cmdline-list) | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | (ducttape-color-mode #f) ) (define (reset-ducttape-with-cmdline-list cmdline-list) (reset-ducttape) (command-line-arguments cmdline-list) (ducttape-process-command-line) ) (define (direct-iputs-test) (ducttape-color-mode #f) (ierr "I'm an error") (iwarn "I'm a warning") |
︙ | ︙ | |||
132 133 134 135 136 137 138 | (let-values (((ec o e) (isys "/bin/ls /zzzzz"))) (let ((expected-code (if (equal? systype "Darwin") 1 2)) (expected-err (if (equal? systype "Darwin") "ls: /zzzzz: No such file or directory" | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | (let-values (((ec o e) (isys "/bin/ls /zzzzz"))) (let ((expected-code (if (equal? systype "Darwin") 1 2)) (expected-err (if (equal? systype "Darwin") "ls: /zzzzz: No such file or directory" "/bin/ls: .* /zzzzz: No such file or directory")) ) (test "isys: /bin/ls /zzzzz should have exit code 2" expected-code ec) (test "isys: /bin/ls /zzzzz should have empty stdout" "" o) (test "isys: /bin/ls /zzzzz should have stderr" expected-err |
︙ | ︙ |