aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (test-workers)
  #:use-module (guix workers)
  #:use-module (ice-9 threads)
  #:use-module (srfi srfi-64))

(test-begin "workers")

(test-equal "enqueue"
  4242
  (let* ((pool   (make-pool))
         (result 0)
         (1+!    (let ((lock (make-mutex)))
                   (lambda ()
                     (with-mutex lock
                       (set! result (+ result 1)))))))
    (let loop ((i 4242))
      (unless (zero? i)
        (pool-enqueue! pool 1+!)
        (loop (- i 1))))
    (let poll ()
      (unless (pool-idle? pool)
        (pk 'busy result)
        (sleep 1)
        (poll)))
    result))

;; Same as above, but throw exceptions within the workers and make sure they
;; remain alive.
(test-equal "exceptions"
  4242
  (let* ((pool   (make-pool 10))
         (result 0)
         (1+!    (let ((lock (make-mutex)))
                   (lambda ()
                     (with-mutex lock
                       (set! result (+ result 1)))))))
    (let loop ((i 10))
      (unless (zero? i)
        (pool-enqueue! pool (lambda ()
                              (throw 'whatever)))
        (loop (- i 1))))
    (let loop ((i 4242))
      (unless (zero? i)
        (pool-enqueue! pool 1+!)
        (loop (- i 1))))
    (let poll ()
      (unless (pool-idle? pool)
        (pk 'busy result)
        (sleep 1)
        (poll)))
    result))

(test-end)
-xyz.scm (ghc-wordexp): New variable. Signed-off-by: Léo Le Bouter <lle-bout@zaclys.net> Stefan Reichör 2021-02-24gnu: ghc-protolude: Update to 0.3.0....* gnu/packages/haskell-xyz.scm (ghc-protolude): Update to 0.3.0. Signed-off-by: Léo Le Bouter <lle-bout@zaclys.net> Stefan Reichör 2021-02-24gnu: Add ghc-protolude-0.2....* gnu/packages/haskell-xyz.scm (ghc-protolude-0.2): New variable. Léo Le Bouter 2021-02-22gnu: Rename ghc-nixfmt into nixfmt...* gnu/packages/haskell-xyz.scm (ghc-nixfmt): Move to... * gnu/packages/haskell-apps.scm (nixfmt): ... here. This is a followup to 703ccd583611b6efa689b7a2d1daf35d6cd83c35. Nicolas Goaziou 2021-02-21gnu: Add ghc-nixfmt....* gnu/packages/haskell-xyz.scm (ghc-nixfmt): New variable. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> EuAndreh via Guix-patches via 2020-12-01gnu: pandoc-citeproc: Separate outputs....This removes unnecessary references to Haskell packages for the statically built executable. * gnu/packages/haskell-xyz.scm (pandoc-citeproc)[outputs]: Add "lib" and "doc" outputs. Ricardo Wurmus 2020-12-01gnu: ghc-libyaml: Use libyaml+static....This is necessary to build static libraries that are used in the static build of pandoc-citeproc. * gnu/packages/haskell-xyz.scm (ghc-libyaml)[inputs]: Replace libyaml with libyaml+static. [arguments]: Adjust directory name. Ricardo Wurmus 2020-11-25gnu: ghc-cassava-megaparsec: Downgrade to 2.0.1....* gnu/packages/haskell-xyz.scm (ghc-cassava-megaparsec): Downgrade to 2.0.1. Signed-off-by: Leo Famulari <leo@famulari.name> Carlo Holl 2020-11-25gnu: ghc-hledger-lib: Downgrade to 0.14.1....* gnu/packages/haskell-xyz.scm (ghc-hledger-lib): Downgrade to 0.14.1. [inputs]: Replace with what is generated by guix import. Signed-off-by: Leo Famulari <leo@famulari.name> Carlo Holl 2020-11-25gnu: ghc-doctest: Downgrade to 0.16.2....* gnu/packages/haskell-xyz.scm (ghc-doctest): Downgrade to 0.16.2. [inputs]: Replace with what is generated by guix import. Signed-off-by: Leo Famulari <leo@famulari.name> Carlo Holl 2020-11-25gnu: ghc-tabular: Downgrade to 0.2.2.7....* gnu/packages/haskell-xyz.scm (ghc-tabular): Downgrade to 0.2.2.7. Signed-off-by: Leo Famulari <leo@famulari.name> Carlo Holl 2020-11-25gnu: ghc-filepath-bytestring: Update to 1.4.2.1.6....The minimum version of ghc-filepath-bytestring is now 1.4.2.1.4 in the latest release of git-annex, the only Guix package that has this library as an input. * gnu/packages/haskell-xyz.scm (ghc-filepath-bytestring): Update to 1.4.2.1.6. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Kyle Meyer 2020-11-25gnu: Add ghc-torrent....* gnu/packages/haskell-xyz.scm (ghc-torrent): New variable. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Kyle Meyer 2020-11-25gnu: Add ghc-bencode....* gnu/packages/haskell-xyz.scm (ghc-bencode): New variable. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Kyle Meyer 2020-11-23gnu: ghc-text-short: Fix spelling....* gnu/packages/haskell-xyz (ghc-text-short): Fix spelling of "similar". Vagrant Cascadian 2020-11-04gnu: Add ghc-network-multicast....* gnu/packages/haskell-xyz.scm (ghc-network-multicast): New variable. Christopher Lemmer Webber 2020-11-04gnu: Add ghc-mountpoints....* gnu/packages/haskell-xyz.scm (ghc-mountpoints): New variable. Christopher Lemmer Webber 2020-11-01gnu: Add ghc-hledger-lib....* gnu/packages/haskell-xyz.scm (ghc-hledger-lib): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-cassava-megaparsec....* gnu/packages/haskell-xyz.scm (ghc-cassava-megaparsec): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-cassava....* gnu/packages/haskell-xyz.scm (ghc-cassava): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-wizards....* gnu/packages/haskell-xyz.scm (ghc-wizards): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-uglymemo....* gnu/packages/haskell-xyz.scm (ghc-uglymemo): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-tabular....* gnu/packages/haskell-xyz.scm (ghc-tabular): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-text-short....* gnu/packages/haskell-xyz.scm (ghc-text-short): New variable. Carlo Holl 2020-11-01gnu: Add ghc-only....* gnu/packages/haskell-xyz.scm (ghc-only): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-lucid....* gnu/packages/haskell-xyz.scm (ghc-lucid): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-hspec-megaparsec....* gnu/packages/haskell-xyz.scm (ghc-hspec-megaparsec): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: ghc-doctest: Update to 0.16.3....* gnu/packages/haskell-xyz.scm (ghc-doctest): Update to 0.16.3. [inputs,native-inputs]: Replace with what is generated by guix import. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-decimal....* gnu/packages/haskell-xyz.scm (ghc-decimal): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-csv....* gnu/packages/haskell-xyz.scm (ghc-csv): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl 2020-11-01gnu: Add ghc-control-monad-free....* gnu/packages/haskell-xyz.scm (ghc-control-monad-free): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Carlo Holl