1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (test-status)
20 #:use-module (guix status)
21 #:use-module (srfi srfi-1)
22 #:use-module (srfi srfi-11)
23 #:use-module (srfi srfi-64))
27 (test-equal "compute-status, no-op"
29 (let-values (((port get-status)
30 (build-event-output-port compute-status)))
31 (display "foo\nbar\n\baz\n" port)
34 (test-equal "compute-status, builds + substitutes"
36 (building '("foo.drv"))
37 (downloading (list (download "bar" "http://example.org/bar"
41 (building '("foo.drv"))
42 (downloading (list (download "bar" "http://example.org/bar"
47 (builds-completed '("foo.drv"))
48 (downloads-completed (list (download "bar" "http://example.org/bar"
53 (let-values (((port get-status)
54 (build-event-output-port (lambda (event status)
55 (compute-status event status
58 (display "@ build-started foo.drv\n" port)
59 (display "@ substituter-started bar\n" port)
60 (display "@ download-started bar http://example.org/bar 500\n" port)
61 (display "various\nthings\nget\nwritten\n" port)
62 (let ((first (get-status)))
63 (display "@ download-progress bar http://example.org/bar 500 42\n"
65 (let ((second (get-status)))
66 (display "@ download-progress bar http://example.org/bar 500 84\n"
68 (display "@ build-succeeded foo.drv\n" port)
69 (display "@ download-succeeded bar http://example.org/bar 500\n" port)
70 (display "Almost done!\n" port)
71 (display "@ substituter-succeeded bar\n" port)
72 (list first second (get-status))))))
74 (test-equal "compute-status, missing events"
76 (building '("foo.drv"))
77 (downloading (list (download "baz" "http://example.org/baz"
81 (download "bar" "http://example.org/bar"
86 (builds-completed '("foo.drv"))
87 (downloads-completed (list (download "baz" "http://example.org/baz"
92 (download "bar" "http://example.org/bar"
97 ;; Below we omit 'substituter-started' events and the like.
98 (let-values (((port get-status)
99 (build-event-output-port (lambda (event status)
100 (compute-status event status
103 (display "@ build-started foo.drv\n" port)
104 (display "@ download-started bar http://example.org/bar 999\n" port)
105 (display "various\nthings\nget\nwritten\n" port)
106 (display "@ download-progress baz http://example.org/baz 500 42\n"
108 (let ((first (get-status)))
109 (display "@ build-succeeded foo.drv\n" port)
110 (display "@ download-succeeded bar http://example.org/bar 999\n" port)
111 (display "Almost done!\n" port)
112 (display "@ substituter-succeeded baz\n" port)
113 (list first (get-status)))))