From 3640bea548826e1c1ec9b766da1fdfe4791d7452 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 17 Nov 2019 06:01:00 +0900 Subject: [PATCH 1/8] gnu: tests: Reduce the time required to run the system tests. When setting the GUIX_DEV_HACKS environment variable, the Guix package used inside the instrumented VMs recycles the binaries already found in the Guix checkout of the developer instead of rebuilding Guix from scratch. This brings the time required for this component from 20+ minutes down to 2-3 minutes on an X200 machine. * gnu/packages/package-management.scm (current-guix/pre-built): New procedure. * build-aux/run-system-tests.scm (tests-for-channel-instance): Use it, when GUIX_DEV_HACKS is defined. --- build-aux/run-system-tests.scm | 11 ++++- gnu/packages/package-management.scm | 66 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/build-aux/run-system-tests.scm b/build-aux/run-system-tests.scm index b0cb3bd2bf..04b6fa29c3 100644 --- a/build-aux/run-system-tests.scm +++ b/build-aux/run-system-tests.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2018, 2019 Ludovic Courtès +;;; Copyright © 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -58,8 +59,16 @@ instance." ;; of tests to run in the usual way: ;; ;; make check-system TESTS=installed-os + + ;; When the GUIX_DEV_HACKS environment variable is defined, override the + ;; package returned by `current-guix' with a flavor that saves recompiling + ;; Guix from scratch and reuse the developer's checkout binaries. The + ;; override "builds" about 20 times faster than the regular `current-guix' + ;; package, which can help speed iterative development. (parameterize ((current-guix-package - (channel-instance->package instance))) + (if (getenv "GUIX_DEV_HACKS") + (current-guix/pre-built) + (channel-instance->package instance)))) (match (getenv "TESTS") (#f (all-system-tests)) diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm index 422d4f1959..bd2ed85189 100644 --- a/gnu/packages/package-management.scm +++ b/gnu/packages/package-management.scm @@ -468,6 +468,72 @@ out) and returning a package that uses that as its 'source'." #:recursive? #t #:select? (force select?)))))))) +(define-public (current-guix/pre-built) + "Similar to `current-guix', but with a modified build procedure that +reuses the existing byte compiled artifacts to save recompilation time." + + (let* ( ;; The `current-source-directory' macro doesn't work from the REPL. + ;; For testing, you can replace it with a static string pointing to + ;; your Guix checkout directory. + (repository-root (delay (canonicalize-path + (string-append (current-source-directory) + "/../..")))) + (select? (lambda (file stat) + (match (basename file) + ((or ".git" + "configure" "autom4te.cache" + "config.log" "config.status" + "stamp-1" "stamp-2" "stamp-3" "stamp-4" "stamp-5" + "stamp-h1" "stamp-vti" + "Makefile" "Makefile.in" ".libs" + ".deps" ".dirstamp" + "test-tmp" + ) #f) + (_ #t))))) + (package + (inherit guix) + (version (string-append (package-version guix) "+")) + (source (local-file (force repository-root) "guix-current" + #:recursive? #t + #:select? select?)) + (arguments + (substitute-keyword-arguments (package-arguments guix) + ((#:phases phases) + `(modify-phases ,phases + ;; XXX: References to tools such as 'mkdir' and 'install' are + ;; captured in Makefile.in when 'autoconf' is run. It'd be nicer + ;; to find those at configuration time. + (delete 'copy-bootstrap-guile) + (delete 'check) + (delete 'disable-failing-tests) + (delete 'strip) ;can't strip .go files anyway + (replace 'build + (lambda _ + ;; Set the write permission bit on some files that need to be + ;; touched. + (chmod "nix" #o777) + (for-each (lambda (f) + (chmod f #o666)) + (cons* "guix-daemon" + (find-files "." ".*\\.(a|o)$"))) + + ;; The following prevent 'make install' from rebuilding the + ;; daemon and the documentation. + (invoke "make" "--touch" "info" + ;; TODO: Currently we must rebuild the daemon as it + ;; was linked against external dependencies that + ;; depend on the provenance of the profile (or + ;; environment) that was used to build it. + + ;; If we could query the provenance of any profile, + ;; we could make this package inherit from the guix + ;; inferior that was used to provide such + ;; dependencies. The most reliable way would + ;; probably be to record that provenance at build + ;; time (as a make target). + ;"guix-daemon" + )))))))))) + ;;; ;;; Other tools. -- 2.25.0