build: meson: Replace the 'test-target' argument by 'test-options'.

This change is motivated by the need to disable the default 30 seconds timeout
that Meson uses (see: https://gitlab.gnome.org/GNOME/glib/-/issues/2522), and
also by desire to specify extra options to run the check phase without having
to override it.

* guix/build-system/meson.scm (meson-build) <test-target>: Replace argument
with...
<test-options>: ... this one.
* guix/build/meson-build-system.scm (check): Invoke 'meson test' instead of
'ninja test-target', as the former is configurable via options.
* doc/guix.texi (Build Systems) <meson-build-system>: Update doc.
This commit is contained in:
Maxim Cournoyer 2021-11-03 12:07:22 -04:00
parent 3e026fc2b1
commit dfcc96d8f4
No known key found for this signature in database
GPG key ID: 1260E46482E63562
3 changed files with 20 additions and 16 deletions

View file

@ -8746,8 +8746,10 @@ The phase runs @code{ninja} to build the package in parallel by default, but
this can be changed with @code{#:parallel-build?}. this can be changed with @code{#:parallel-build?}.
@item check @item check
The phase runs @code{ninja} with the target specified in @code{#:test-target}, The phase runs @samp{meson test} with a base set of options that cannot
which is @code{"test"} by default. be overridden. This base set of options can be extended via the
@code{#:test-options} argument, for example to select or skip a specific
test suite.
@item install @item install
The phase runs @code{ninja install} and can not be changed. The phase runs @code{ninja install} and can not be changed.

View file

@ -169,7 +169,7 @@ (define* (meson-build name inputs
(search-paths '()) (search-paths '())
(build-type "debugoptimized") (build-type "debugoptimized")
(tests? #t) (tests? #t)
(test-target "test") (test-options ''())
(glib-or-gtk? #f) (glib-or-gtk? #f)
(parallel-build? #t) (parallel-build? #t)
(parallel-tests? #f) (parallel-tests? #f)
@ -218,7 +218,7 @@ (define build-phases
configure-flags) configure-flags)
#:build-type #$build-type #:build-type #$build-type
#:tests? #$tests? #:tests? #$tests?
#:test-target #$test-target #:test-options #$(sexp->gexp test-options)
#:parallel-build? #$parallel-build? #:parallel-build? #$parallel-build?
#:parallel-tests? #$parallel-tests? #:parallel-tests? #$parallel-tests?
#:validate-runpath? #$validate-runpath? #:validate-runpath? #$validate-runpath?
@ -251,7 +251,7 @@ (define* (meson-cross-build name
(build-type "debugoptimized") (build-type "debugoptimized")
(tests? #f) (tests? #f)
(test-target "test") (test-options ''())
(glib-or-gtk? #f) (glib-or-gtk? #f)
(parallel-build? #t) (parallel-build? #t)
(parallel-tests? #f) (parallel-tests? #f)
@ -281,7 +281,7 @@ (define inputs
(if (null? target-inputs) (if (null? target-inputs)
(input-tuples->gexp host-inputs) (input-tuples->gexp host-inputs)
#~(append #$(input-tuples->gexp host-inputs) #~(append #$(input-tuples->gexp host-inputs)
#+(input-tuples->gexp target-inputs)))) #+(input-tuples->gexp target-inputs))))
(define builder (define builder
(with-imported-modules imported-modules (with-imported-modules imported-modules
#~(begin #~(begin
@ -306,7 +306,7 @@ (define build-phases
#:native-inputs #+(input-tuples->gexp build-inputs) #:native-inputs #+(input-tuples->gexp build-inputs)
#:search-paths '#$(sexp->gexp #:search-paths '#$(sexp->gexp
(map search-path-specification->sexp (map search-path-specification->sexp
search-paths)) search-paths))
#:native-search-paths '#$(sexp->gexp #:native-search-paths '#$(sexp->gexp
(map search-path-specification->sexp (map search-path-specification->sexp
native-search-paths)) native-search-paths))
@ -318,7 +318,7 @@ (define build-phases
configure-flags)) configure-flags))
#:build-type #$build-type #:build-type #$build-type
#:tests? #$tests? #:tests? #$tests?
#:test-target #$test-target #:test-options #$(sexp->gexp test-options)
#:parallel-build? #$parallel-build? #:parallel-build? #$parallel-build?
#:parallel-tests? #$parallel-tests? #:parallel-tests? #$parallel-tests?
#:validate-runpath? #$validate-runpath? #:validate-runpath? #$validate-runpath?

View file

@ -2,6 +2,7 @@
;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com> ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com> ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -63,16 +64,17 @@ (define* (build #:key parallel-build?
(number->string (parallel-job-count)) (number->string (parallel-job-count))
"1"))) "1")))
(define* (check #:key test-target parallel-tests? tests? (define* (check #:key tests? test-options parallel-tests?
#:allow-other-keys) #:allow-other-keys)
(setenv "MESON_TESTTHREADS"
(if parallel-tests?
(number->string (parallel-job-count))
"1"))
(if tests? (if tests?
(invoke "ninja" test-target) (begin
(format #t "test suite not run~%")) (setenv "MESON_TESTTHREADS"
#t) (if parallel-tests?
(number->string (parallel-job-count))
"1"))
;; Always provide "-t 0" to disable the 30 s default timeout.
(apply invoke "meson" "test" "--print-errorlogs" "-t" "0" test-options))
(format #t "test suite not run~%")))
(define* (install #:rest args) (define* (install #:rest args)
(invoke "ninja" "install")) (invoke "ninja" "install"))