Commit | Line | Data |
---|---|---|
dc0f74e5 LC |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
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. | |
10 | ;;; | |
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. | |
15 | ;;; | |
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/>. | |
18 | ||
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)) | |
24 | ||
25 | (test-begin "status") | |
26 | ||
27 | (test-equal "compute-status, no-op" | |
28 | (build-status) | |
29 | (let-values (((port get-status) | |
30 | (build-event-output-port compute-status))) | |
31 | (display "foo\nbar\n\baz\n" port) | |
32 | (get-status))) | |
33 | ||
34 | (test-equal "compute-status, builds + substitutes" | |
35 | (list (build-status | |
36 | (building '("foo.drv")) | |
37 | (downloading (list (download "bar" "http://example.org/bar" | |
38 | #:size 500 | |
39 | #:start 'now)))) | |
40 | (build-status | |
41 | (building '("foo.drv")) | |
42 | (downloading (list (download "bar" "http://example.org/bar" | |
43 | #:size 500 | |
44 | #:transferred 42 | |
45 | #:start 'now)))) | |
46 | (build-status | |
47 | (builds-completed '("foo.drv")) | |
48 | (downloads-completed (list (download "bar" "http://example.org/bar" | |
49 | #:size 500 | |
50 | #:transferred 500 | |
51 | #:start 'now | |
52 | #:end 'now))))) | |
53 | (let-values (((port get-status) | |
54 | (build-event-output-port (lambda (event status) | |
55 | (compute-status event status | |
56 | #:current-time | |
57 | (const 'now)))))) | |
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" | |
64 | port) | |
65 | (let ((second (get-status))) | |
66 | (display "@ download-progress bar http://example.org/bar 500 84\n" | |
67 | port) | |
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)))))) | |
73 | ||
74 | (test-equal "compute-status, missing events" | |
75 | (list (build-status | |
76 | (building '("foo.drv")) | |
77 | (downloading (list (download "baz" "http://example.org/baz" | |
78 | #:size 500 | |
79 | #:transferred 42 | |
80 | #:start 'now) | |
81 | (download "bar" "http://example.org/bar" | |
82 | #:size 999 | |
83 | #:transferred 0 | |
84 | #:start 'now)))) | |
85 | (build-status | |
86 | (builds-completed '("foo.drv")) | |
87 | (downloads-completed (list (download "baz" "http://example.org/baz" | |
88 | #:size 500 | |
89 | #:transferred 500 | |
90 | #:start 'now | |
91 | #:end 'now) | |
92 | (download "bar" "http://example.org/bar" | |
93 | #:size 999 | |
94 | #:transferred 999 | |
95 | #:start 'now | |
96 | #:end 'now))))) | |
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 | |
101 | #:current-time | |
102 | (const 'now)))))) | |
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" | |
107 | port) | |
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))))) | |
114 | ||
115 | (test-end "status") |