From a394694d131212f844b8adee8916aff24f5cb9aa Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 11 Feb 2018 00:51:26 -0500 Subject: [PATCH 02/27] emacs-build-system: Add improved check phase, fixes. * guix/build-system/emacs.scm (emacs-build): Remove `test-target' and 'configure-flags' arguments. Add `test-command' argument. * guix/build/emacs-build-system.scm (unpack): Add the unpacked directory to the EMACSLOADPATH. (check): New procedure. (make-autoloads): No need to return #t explicitly since the function now uses `invoke'. (%standard-phases)[set-emacs-load-path]: Move after `unpack'. [check]: Register after the `build' phase. * guix/build/emacs-utils.scm (guix): Use (guix build utils) for `invoke'. (emacs-batch-eval): Replace `system*' usage with `invoke'. (emacs-batch-edit-file): Likewise. (emacs-byte-compile-directory): Make it fail when there are compilation errors. --- guix/build-system/emacs.scm | 6 ++---- guix/build/emacs-build-system.scm | 36 ++++++++++++++++++++++++++++-------- guix/build/emacs-utils.scm | 18 ++++++++++-------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/guix/build-system/emacs.scm b/guix/build-system/emacs.scm index d9f1a8d28..ef6d1b339 100644 --- a/guix/build-system/emacs.scm +++ b/guix/build-system/emacs.scm @@ -84,8 +84,7 @@ #:key source (tests? #f) (parallel-tests? #t) - (test-target "test") - (configure-flags ''()) + (test-command ''("make" "check")) (phases '(@ (guix build emacs-build-system) %standard-phases)) (outputs '("out")) @@ -110,9 +109,8 @@ source) (source source)) - #:configure-flags ,configure-flags #:system ,system - #:test-target ,test-target + #:test-command ,test-command #:tests? ,tests? #:phases ,phases #:outputs %outputs diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-system.scm index ba9ec88e4..44d63b146 100644 --- a/guix/build/emacs-build-system.scm +++ b/guix/build/emacs-build-system.scm @@ -74,12 +74,14 @@ archive, a directory, or an Emacs Lisp file." #t) (gnu:unpack #:source source))) -(define* (set-emacs-load-path #:key inputs #:allow-other-keys) +(define* (set-emacs-load-path #:key source inputs #:allow-other-keys) "Set the EMACSLOADPATH environment variable so that dependencies are found." - (let* ((input-elisp-dirs (inputs->el-directories + (let* ((source-dir (getcwd)) + (input-elisp-dirs (inputs->el-directories (inputs->directories inputs))) (emacs-load-path-value (string-join - input-elisp-dirs ":" 'suffix))) + `(,@input-elisp-dirs + ,source-dir) ":" 'suffix))) (setenv "EMACSLOADPATH" emacs-load-path-value) (format #t "environment variable `EMACSLOADPATH' set to ~a\n" emacs-load-path-value))) @@ -133,6 +135,24 @@ store in '.el' files." (substitute-program-names)))) #t)) +(define* (check #:key target (tests? (not target)) + (test-command '("make" "check")) (parallel-tests? #t) + #:allow-other-keys) + "Like the gnu-build-system check phase, but with a way to pass a custom test +program command line, using TEST-COMMAND." + (let* ((test-program (car test-command)) + (test-args (cdr test-command)) + (using-make? (string=? test-program "make"))) + (if tests? + (apply invoke test-program + `(,@test-args + ,@(if (and using-make? parallel-tests?) + `("-j" ,(number->string (parallel-job-count))) + '()))) + (begin + (format #t "test suite not run~%") + #t)))) + (define* (install #:key outputs (include %default-include) (exclude %default-exclude) @@ -203,8 +223,7 @@ store in '.el' files." (elpa-name (package-name->name+version elpa-name-ver)) (el-dir (string-append out %install-suffix "/" elpa-name-ver))) (parameterize ((%emacs emacs)) - (emacs-generate-autoloads elpa-name el-dir)) - #t)) + (emacs-generate-autoloads elpa-name el-dir)))) (define (emacs-package? name) "Check if NAME correspond to the name of an Emacs package." @@ -246,12 +265,13 @@ second hyphen. This corresponds to 'name-version' as used in ELPA packages." (define %standard-phases (modify-phases gnu:%standard-phases - (add-after 'set-paths 'set-emacs-load-path set-emacs-load-path) (replace 'unpack unpack) + (add-after 'unpack 'set-emacs-load-path set-emacs-load-path) (delete 'configure) - ;; Move the build phase after install: the .el files are byte compiled - ;; directly in the store. + ;; Move the build phase after install: the .el files are byte + ;; compiled directly in the store. (delete 'build) + (replace 'check check) (replace 'install install) (add-after 'install 'build build) (add-after 'install 'make-autoloads make-autoloads) diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm index 8389ca582..eed17667b 100644 --- a/guix/build/emacs-utils.scm +++ b/guix/build/emacs-utils.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 Mark H Weaver ;;; Copyright © 2014 Alex Kost +;;; Copyright © 2018 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,6 +19,7 @@ ;;; along with GNU Guix. If not, see . (define-module (guix build emacs-utils) + #:use-module (guix build utils) #:export (%emacs emacs-batch-eval emacs-batch-edit-file @@ -39,16 +41,14 @@ (define (emacs-batch-eval expr) "Run Emacs in batch mode, and execute the elisp code EXPR." - (unless (zero? (system* (%emacs) "--quick" "--batch" - (format #f "--eval=~S" expr))) - (error "emacs-batch-eval failed!" expr))) + (invoke (%emacs) "--quick" "--batch" + (format #f "--eval=~S" expr))) (define (emacs-batch-edit-file file expr) "Load FILE in Emacs using batch mode, and execute the elisp code EXPR." - (unless (zero? (system* (%emacs) "--quick" "--batch" - (string-append "--visit=" file) - (format #f "--eval=~S" expr))) - (error "emacs-batch-edit-file failed!" file expr))) + (invoke (%emacs) "--quick" "--batch" + (string-append "--visit=" file) + (format #f "--eval=~S" expr))) (define (emacs-generate-autoloads name directory) "Generate autoloads for Emacs package NAME placed in DIRECTORY." @@ -60,7 +60,9 @@ (define* (emacs-byte-compile-directory dir) "Byte compile all files in DIR and its sub-directories." - (let ((expr `(byte-recompile-directory (file-name-as-directory ,dir) 0))) + (let ((expr `(progn + (setq byte-compile-debug t) ;for proper exit status + (byte-recompile-directory (file-name-as-directory ,dir) 0 1)))) (emacs-batch-eval expr))) (define-syntax emacs-substitute-sexps -- 2.16.1