diff options
author | Marius Bakke <mbakke@fastmail.com> | 2018-10-17 20:47:11 +0200 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2018-10-17 20:47:11 +0200 |
commit | d02bb02f7d833ad371c53c346b6cb77f01377cf4 (patch) | |
tree | 9506f04a7fde2f3b264ba1d2a9012085e1f72b72 /tests/status.scm | |
parent | fb3ff265cd8c6b4c6160f94240dc8932097e637b (diff) | |
parent | acce0a474c1493ab18912bc46285248e4ccb0314 (diff) | |
download | patches-d02bb02f7d833ad371c53c346b6cb77f01377cf4.tar patches-d02bb02f7d833ad371c53c346b6cb77f01377cf4.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'tests/status.scm')
-rw-r--r-- | tests/status.scm | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/tests/status.scm b/tests/status.scm index 04dedb702c..99abb41c8b 100644 --- a/tests/status.scm +++ b/tests/status.scm @@ -20,7 +20,10 @@ #:use-module (guix status) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) - #:use-module (srfi srfi-64)) + #:use-module (srfi srfi-64) + #:use-module (rnrs bytevectors) + #:use-module (rnrs io ports) + #:use-module (ice-9 match)) (test-begin "status") @@ -112,4 +115,69 @@ (display "@ substituter-succeeded baz\n" port) (list first (get-status))))) +(test-equal "build-output-port, UTF-8" + '((build-log #f "lambda is λ!\n")) + (let-values (((port get-status) (build-event-output-port cons '())) + ((bv) (string->utf8 "lambda is λ!\n"))) + (put-bytevector port bv) + (force-output port) + (get-status))) + +(test-equal "current-build-output-port, UTF-8 + garbage" + ;; What about a mixture of UTF-8 + garbage? + (let ((replacement (cond-expand + ((and guile-2 (not guile-2.2)) "?") + (else "�")))) + `((build-log #f ,(string-append "garbage: " replacement "lambda: λ\n")))) + (let-values (((port get-status) (build-event-output-port cons '()))) + (display "garbage: " port) + (put-bytevector port #vu8(128)) + (put-bytevector port (string->utf8 "lambda: λ\n")) + (force-output port) + (get-status))) + +(test-equal "compute-status, multiplexed build output" + (list (build-status + (building '("foo.drv")) + (downloading (list (download "bar" "http://example.org/bar" + #:size 999 + #:start 'now)))) + (build-status + (building '("foo.drv")) + (downloading (list (download "bar" "http://example.org/bar" + #:size 999 + #:transferred 42 + #:start 'now)))) + (build-status + ;; XXX: Should "bar.drv" be present twice? + (builds-completed '("bar.drv" "foo.drv")) + (downloads-completed (list (download "bar" "http://example.org/bar" + #:size 999 + #:transferred 999 + #:start 'now + #:end 'now))))) + (let-values (((port get-status) + (build-event-output-port (lambda (event status) + (compute-status event status + #:current-time + (const 'now) + #:derivation-path->output-path + (match-lambda + ("bar.drv" "bar"))))))) + (display "@ build-started foo.drv 121\n" port) + (display "@ build-started bar.drv 144\n" port) + (display "@ build-log 121 6\nHello!" port) + (display "@ build-log 144 50 +@ download-started bar http://example.org/bar 999\n" port) + (let ((first (get-status))) + (display "@ build-log 121 30\n@ build-started FAKE!.drv 555\n") + (display "@ build-log 144 54 +@ download-progress bar http://example.org/bar 999 42\n" + port) + (let ((second (get-status))) + (display "@ download-succeeded bar http://example.org/bar 999\n" port) + (display "@ build-succeeded foo.drv\n" port) + (display "@ build-succeeded bar.drv\n" port) + (list first second (get-status)))))) + (test-end "status") |