From c04ffadbed7412545555b8be6b78f23eed150d26 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 5 Jan 2018 00:19:35 +0100 Subject: publish: Publish build logs. * guix/scripts/publish.scm (render-log-file): New procedure. (make-request-handler): Add "log" case. * tests/publish.scm ("/log/NAME") ("/log/NAME not found"): New tests. * doc/guix.texi (Invoking guix publish): Document /log URLs. --- tests/publish.scm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/publish.scm') diff --git a/tests/publish.scm b/tests/publish.scm index 352caf5325..bd1a75cf00 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 David Thompson +;;; Copyright © 2016, 2017, 2018 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -439,4 +440,31 @@ FileSize: ~a~%" (assoc-ref narinfo "FileSize")) (response-code compressed)))))))))) +(test-equal "/log/NAME" + `(200 #t application/x-bzip2) + (let ((drv (run-with-store %store + (gexp->derivation "with-log" + #~(call-with-output-file #$output + (lambda (port) + (display "Hello, build log!" + (current-error-port)) + (display "" port))))))) + (build-derivations %store (list drv)) + (let* ((response (http-get + (publish-uri (string-append "/log/" + (basename (derivation->output-path drv)))) + #:decode-body? #f)) + (base (basename (derivation-file-name drv))) + (log (string-append (dirname %state-directory) + "/log/guix/drvs/" (string-take base 2) + "/" (string-drop base 2) ".bz2"))) + (list (response-code response) + (= (response-content-length response) (stat:size (stat log))) + (first (response-content-type response)))))) + +(test-equal "/log/NAME not found" + 404 + (let ((uri (publish-uri "/log/does-not-exist"))) + (response-code (http-get uri)))) + (test-end "publish") -- cgit v1.2.3