summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaxime Devos <maximedevos@telenet.be>2021-05-24 21:07:15 +0200
committerLudovic Courtès <ludo@gnu.org>2021-05-28 11:36:03 +0200
commit45a96b3f03e1876e4172d4408cdb53fa904bd274 (patch)
tree4376be3895368f33784bb5991c7c8cc23525314d
parent3f5bc6cbb34e1b57829ce3bf482310c49f03d3c3 (diff)
downloadguix-45a96b3f03e1876e4172d4408cdb53fa904bd274.tar.gz
gnu: tryton: Factor out custom ‘check’ phase.
* gnu/packages/tryton.scm
  (tryton-phases): New procedure.
  (tryton-arguments): New procedure.
  (python-trytond-account)[arguments]: Use 'tryton-phases'.
  (python-trytond-account-invoice)[arguments]: Likewise.
  (python-trytond-account-invoice-stock)[arguments]: Likewise.
  (python-trytond-account-product)[arguments]: Likewise.
  (python-trytond-analytic-account)[arguments]: Likewise.
  (python-trytond-company)[arguments]: Likewise.
  (python-trytond-country)[arguments]: Likewise.
  (python-trytond-currency)[arguments]: Likewise.
  (python-trytond-party)[arguments]: Likewise.
  (python-trytond-product)[arguments]: Likewise.
  (python-trytond-purchase)[arguments]: Likewise.
  (python-trytond-purchase-request)[arguments]: Likewise.
  (python-trytond-stock)[arguments]: Likewise.
  (python-trytond-stock-lot)[arguments]: Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--gnu/packages/tryton.scm238
1 files changed, 39 insertions, 199 deletions
diff --git a/gnu/packages/tryton.scm b/gnu/packages/tryton.scm
index e9484aa487..800e19d827 100644
--- a/gnu/packages/tryton.scm
+++ b/gnu/packages/tryton.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Adriano Peluso <catonano@gmail.com>
 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -144,6 +145,26 @@ and security.")
      "This package provides a library to access Tryton server as a client.")
     (license license:lgpl3+)))
 
+(define (tryton-phases module . extra-arguments)
+  "Return the phases for building and testing a Tryton module named MODULE.
+If present, pass EXTRA-ARGUMENTS to runtest as well."
+  `(modify-phases %standard-phases
+     (replace 'check
+       (let ((runtest
+              (string-append
+               (assoc-ref %build-inputs "trytond")
+               "/lib/python"
+               ,(version-major+minor (package-version python))
+               "/site-packages/trytond/tests/run-tests.py")))
+         (lambda* (#:key inputs outputs #:allow-other-keys)
+           (add-installed-pythonpath inputs outputs)
+           (invoke "python" runtest "-m" ,module ,@extra-arguments))))))
+
+(define (tryton-arguments module . extra-arguments)
+  "Like ’tryton-phases’, but directly return all arguments for
+the build system."
+  `(#:phases ,(apply tryton-phases module extra-arguments)))
+
 ;;;
 ;;;  Tryton modules - please sort alphabetically
 ;;;
@@ -159,19 +180,7 @@ and security.")
        (sha256
         (base32 "16ny67vcnxk9ngcxd56cfixm441vs9jxv3apmb16xsi47yk2xd7w"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "account")))))))
+    (arguments (tryton-arguments "account"))
     (native-inputs
      `(("python-genshi" ,python-genshi)
        ("python-lxml" ,python-lxml)
@@ -210,19 +219,7 @@ most of accounting needs.")
        (sha256
         (base32 "0drccambg6855p7ai8654c7f9v85jzwicwpxmagyrr09qz6qzgcz"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "account_invoice")))))))
+    (arguments (tryton-arguments "account_invoice"))
     (native-inputs
      `(("python-genshi" ,python-genshi)
        ("python-lxml" ,python-lxml)
@@ -268,19 +265,7 @@ term.")
        (sha256
         (base32 "02m6ikcc38ac41ddzg5xp5l9jz0k6j7j1g2xa62ki4v093yn4z5v"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "account_invoice_stock")))))))
+    (arguments (tryton-arguments "account_invoice_stock"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -319,19 +304,7 @@ average price of the posted invoice lines that are linked to it.")
        (sha256
         (base32 "10bpbkkmllbh9lm5ajydmc5nvqm9bbdn9rmm03jqgik23s5kyx2z"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "account_product")))))))
+    (arguments (tryton-arguments "account_product"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -372,19 +345,7 @@ and category.")
        (sha256
         (base32 "10rn2rf1ji7d1gxmgca368yvabql1ahklqg7p8sh5bl79vn5qx5x"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "analytic_account")))))))
+    (arguments (tryton-arguments "analytic_account"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -424,19 +385,7 @@ required to analyse accounting using multiple different axes.")
        (sha256
         (base32 "1bwy2rkgfw32cwhq5fh3rpy7bx425h44ap10i9kjx5ak86bfnpz9"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "company")))))))
+    (arguments (tryton-arguments "company"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -472,20 +421,8 @@ company and employee and extend the user model.")
        (sha256
         (base32 "1lkspk5w5pb0gg2h27zb7vwcj993gkm1f84qdxmqlpkc8raqvicj"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               ;; Doctest contains one test that requires internet access.
-               (invoke "python" runtest "-m" "country" "--no-doctest")))))))
+    ;; Doctest contains one test that requires internet access.
+    (arguments (tryton-arguments "country" "--no-doctest"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -518,19 +455,7 @@ company and employee and extend the user model.")
        (sha256
         (base32 "0b5p7ibil7nlsv7f31j69rka4xj5za798262algx7xa88a6h7mmx"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "currency")))))))
+    (arguments (tryton-arguments "currency"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -565,20 +490,8 @@ currency and rate.")
        (sha256
         (base32 "1hapfq7ip99s4qp9xra1m40q4n379p9pmfnz2x4ggd79ss76bghc"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               ;; Doctest 'scenario_party_phone_number.rst' fails.
-               (invoke "python" runtest "-m" "party" "--no-doctest")))))))
+    ;; Doctest 'scenario_party_phone_number.rst' fails.
+    (arguments (tryton-arguments "party" "--no-doctest"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -613,19 +526,7 @@ addresses.")
        (sha256
         (base32 "0x18ngpjyrdwjwg17bz98jph4jv5gcv0qc0p2kxpam4lqsy34ic2"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "product")))))))
+    (arguments (tryton-arguments "product"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -661,19 +562,7 @@ Template and Product.")
        (sha256
         (base32 "0na74zijj46b12gypy9si3las02a96rh5ygl503c7razha61g1b0"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "purchase")))))))
+    (arguments (tryton-arguments "purchase"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -721,21 +610,8 @@ Template and Product.")
        (sha256
         (base32 "1m92snnvgisnv083nml6cz5qgnfdg539rd5bwg3lqrknm7343w16"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               ;; Doctest 'scenario_purchase_request.rst' fails.
-               (invoke "python" runtest
-                       "-m" "purchase_request" "--no-doctest")))))))
+    ;; Doctest 'scenario_purchase_request.rst' fails.
+    (arguments (tryton-arguments "purchase_request" "--no-doctest"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -773,19 +649,7 @@ generated by other process from Tryton.")
        (sha256
         (base32 "0yb8kd3alwqkivrlpx0ni4jxv3x14i37lmwism9yi81xwchyrcjk"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "stock")))))))
+    (arguments (tryton-arguments "stock"))
     (native-inputs
      `(("python-genshi" ,python-genshi)
        ("python-lxml" ,python-lxml)
@@ -827,19 +691,7 @@ inventory to control and update stock levels.")
        (sha256
         (base32 "0w2f62cfzm7j8wnw8igmjslpxc1a8s82dkdizyvim5qhjg6mrsym"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "stock_lot")))))))
+    (arguments (tryton-arguments "stock_lot"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)
@@ -874,19 +726,7 @@ inventory to control and update stock levels.")
        (sha256
         (base32 "01cgpxlznldrba79a3xmj4d0csyfc3ccgs66c490j8v8rdnqpbww"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (let ((runtest
-                  (string-append
-                   (assoc-ref %build-inputs "trytond")
-                   "/lib/python"
-                   ,(version-major+minor (package-version python))
-                   "/site-packages/trytond/tests/run-tests.py")))
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (add-installed-pythonpath inputs outputs)
-               (invoke "python" runtest "-m" "stock_supply")))))))
+    (arguments (tryton-arguments "stock_supply"))
     (native-inputs
      `(("python-dateutil" ,python-dateutil)
        ("python-genshi" ,python-genshi)