aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019-2021, 2024 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-swh)
  #:use-module (guix swh)
  #:use-module (guix base32)
  #:use-module (guix tests http)
  #:use-module (web response)
  #:use-module (srfi srfi-19)
  #:use-module (srfi srfi-64)
  #:use-module (ice-9 match))

;; Test the JSON mapping machinery used in (guix swh).

(define %origin
  "{ \"origin_visits_url\": \"/visits/42\",
     \"type\": \"git\",
     \"url\": \"http://example.org/guix.git\" }")

(define %visits
  ;; A single visit where 'snapshot_url' is null.
  ;; See <https://bugs.gnu.org/45615>.
  "[ {
    \"origin\": \"https://github.com/Genivia/ugrep\",
    \"visit\": 1,
    \"date\": \"2020-05-17T21:43:45.422977+00:00\",
    \"status\": \"ongoing\",
    \"snapshot\": null,
    \"metadata\": {},
    \"type\": \"git\",
    \"origin_visit_url\": \"https://archive.softwareheritage.org/api/1/origin/https://github.com/Genivia/ugrep/visit/1/\",
    \"snapshot_url\": null
  } ]")

(define %directory-entries
  "[ { \"name\": \"one\",
       \"type\": \"regular\",
       \"length\": 123,
       \"dir_id\": 1 },
     { \"name\": \"two\",
       \"type\": \"regular\",
       \"length\": 456,
       \"dir_id\": 2 } ]")

(define %external-id
  "{ \"extid_type\": \"nar-sha256\",
     \"extid\":
\"0b56ba94c2b83b8f74e3772887c1109135802eb3e8962b628377987fe97e1e63\",
     \"version\": 0,
     \"target\": \"swh:1:dir:84a8b34591712c0a90bab0af604188bcd1fe3153\",
     \"target_url\":
\"https://archive.softwareheritage.org/swh:1:dir:84a8b34591712c0a90bab0af604188bcd1fe3153\"
   }")

(define-syntax-rule (with-json-result str exp ...)
  (with-http-server `((200 ,str))
    (parameterize ((%swh-base-url (%local-url)))
      exp ...)))

(test-begin "swh")

(test-equal "lookup-origin"
  (list "git" "http://example.org/guix.git")
  (with-json-result %origin
    (let ((origin (lookup-origin "http://example.org/guix.git")))
      (list (origin-type origin)
            (origin-url origin)))))

(test-equal "lookup-origin, not found"
  #f
  (with-http-server `((404 "Nope."))
    (parameterize ((%swh-base-url (%local-url)))
      (lookup-origin "http://example.org/whatever"))))

(test-equal "origin-visit, no snapshots"
  '("https://github.com/Genivia/ugrep"
    "2020-05-17T21:43:45Z"
    #f)                                      ;see <https://bugs.gnu.org/45615>
  (with-http-server `((200 ,%origin)
                      (200 ,%visits))
    (parameterize ((%swh-base-url (%local-url)))
      (let ((origin (lookup-origin "http://example.org/whatever")))
        (match (origin-visits origin)
          ((visit)
           (list (visit-origin visit)
                 (date->string (visit-date visit) "~4")
                 (visit-snapshot-url visit))))))))

(test-equal "lookup-directory"
  '(("one" 123) ("two" 456))
  (with-json-result %directory-entries
    (map (lambda (entry)
           (list (directory-entry-name entry)
                 (directory-entry-length entry)))
         (lookup-directory "123"))))

(test-equal "lookup-origin-revision"
  '("cd86c72084993d9ef26fc9e24b73cea612b8c97b"
    "d173c707ee88e3c89401ad77fafa65fcd9e9f5be")
  (let ()
    ;; Make sure that 'lookup-origin-revision' does the job, and in particular
    ;; that it doesn't stop until it has found an actual revision:
    ;; 'git-checkout visits point to directories instead of revisions.
    ;; See <https://issues.guix.gnu.org/69070>.
    (define visits
      ;; Two visits of differing types: the first visit (type 'git-checkout')
      ;; points to a directory, the second one (type 'git') points to a
      ;; revision.
      "[ {
    \"origin\": \"https://example.org/repo.git\",
    \"visit\": 1,
    \"type\": \"git-checkout\",
    \"date\": \"2020-05-17T21:43:45.422977+00:00\",
    \"status\": \"full\",
    \"metadata\": {},
    \"type\": \"git-checkout\",
    \"origin_visit_url\": \"/visit/42\",
    \"snapshot_url\": \"/snapshot/1\"
  }, {
    \"origin\": \"https://example.org/repo.git\",
    \"visit\": 2,
    \"type\": \"git\",
    \"date\": \"2020-05-17T21:43:49.422977+00:00\",
    \"status\": \"full\",
    \"metadata\": {},
    \"type\": \"git\",
    \"origin_visit_url\": \"/visit/41\",
    \"snapshot_url\": \"/snapshot/2\"
  } ]")
    (define snapshot-for-git-checkout
      "{ \"id\": 42,
         \"branches\": { \"1.3.2\": {
           \"target\": \"e4a4be18fae8d9c6528abff3bc9088feb19a76c7\",
           \"target_type\": \"directory\",
           \"target_url\": \"/directory/e4a4be18fae8d9c6528abff3bc9088feb19a76c7\"
         }}
       }")
    (define snapshot-for-git
      "{ \"id\": 42,
         \"branches\": { \"1.3.2\": {
           \"target\": \"e4a4be18fae8d9c6528abff3bc9088feb19a76c7\",
           \"target_type\": \"revision\",
           \"target_url\": \"/revision/e4a4be18fae8d9c6528abff3bc9088feb19a76c7\"
         }}
       }")
    (define revision
      "{ \"author\": {},
         \"committer\": {},
         \"committer_date\": \"2018-05-17T21:43:49.422977+00:00\",
         \"date\": \"2018-05-17T21:43:49.422977+00:00\",
         \"directory\": \"d173c707ee88e3c89401ad77fafa65fcd9e9f5be\",
         \"directory_url\": \"/directory/d173c707ee88e3c89401ad77fafa65fcd9e9f5be\",
         \"id\": \"cd86c72084993d9ef26fc9e24b73cea612b8c97b\",
         \"merge\": false,
         \"message\": \"Fix.\",
         \"parents\": [],
         \"type\": \"what type?\"
       }")

    (with-http-server `((200 ,%origin)
                        (200 ,visits)
                        (200 ,snapshot-for-git-checkout)
                        (200 ,snapshot-for-git)
                        (200 ,revision))
      (parameterize ((%swh-base-url (%local-url)))
        (let ((revision (lookup-origin-revision "https://example.org/repo.git"
                                                "1.3.2")))
          (list (revision-id revision)
                (revision-directory revision)))))))

(test-equal "lookup-directory-by-nar-hash"
  "swh:1:dir:84a8b34591712c0a90bab0af604188bcd1fe3153"
  (with-json-result %external-id
    (lookup-directory-by-nar-hash
     (nix-base32-string->bytevector
      "0qqygvlpz63phdi2p5p8ncp80dci230qfa3pwds8yfxqqaablmhb")
     'sha256)))

(test-equal "rate limit reached"
  3000000000
  (let ((too-many (build-response
                   #:code 429
                   #:reason-phrase "Too many requests"

                   ;; Pretend we've reached the limit and it'll be reset in
                   ;; June 2065.
                   #:headers '((x-ratelimit-remaining . "0")
                               (x-ratelimit-reset . "3000000000")))))
    (with-http-server `((,too-many "Too bad."))
      (parameterize ((%swh-base-url (%local-url)))
        (catch 'swh-error
          (lambda ()
            (lookup-origin "http://example.org/guix.git"))
          (lambda (key url method response)
            ;; Ensure the reset time was recorded.
            (@@ (guix swh) %general-rate-limit-reset-time)))))))

(test-assert "%allow-request? and request-rate-limit-reached?"
  ;; Here we test two things: that the rate limit set above is in effect and
  ;; that %ALLOW-REQUEST? is called, and that 'request-rate-limit-reached?'
  ;; returns true.
  (let* ((key (gensym "skip-request"))
         (skip-if-limit-reached
          (lambda (url method)
            (or (not (request-rate-limit-reached? url method))
                (throw key #t)))))
    (parameterize ((%allow-request? skip-if-limit-reached))
      (catch key
        (lambda ()
          (lookup-origin "http://example.org/guix.git")
          #f)
        (const #t)))))

(test-end "swh")

;; Local Variables:
;; eval: (put 'with-json-result 'scheme-indent-function 1)
;; eval: (put 'with-http-server 'scheme-indent-function 1)
;; End:

ka-aile, font-iosevka-etoile, font-iosevka-sparkle): New variables. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Simen Endsjø 2020-06-18gnu: Update Iosevka fonts from 2.3.3 to 3.1.1....* gnu/packages/fonts.scm (font-iosevka): (font-iosevka-slab): (font-iosevka-term): (font-iosevka-term-slab): Update to 3.1.1. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Simen Endsjø 2020-06-17gnu: font-sarasa-gothic: Update to 0.12.7...From 5e41fcb899267b6854990e79edca3526e90ebb11 Mon Sep 17 00:00:00 2001 From: Zhu Zihao <all_but_last@163.com> Date: Wed, 17 Jun 2020 21:33:01 +0800 Subject: [PATCH] gnu: font-sarasa-gothic: Update to 0.12.7 Signed-off-by: Leo Famulari <leo@famulari.name> Zhu Zihao 2020-06-08gnu: font-liberation: Update to 2.1.1....* gnu/packages/fonts.scm (font-liberation): Update to 2.1.1. Marius Bakke 2020-05-30gnu: fonts.scm: Add missing '>' in copyright header....* gnu/packages/fonts.scm: Add missing > in email address. Marius Bakke 2020-05-30gnu: font-tamzen: Update to 1.11.5....* gnu/packages/fonts.scm (font-tamzen): Update to 1.11.5. Tobias Geerinckx-Rice 2020-05-30gnu: Add font-sarasa-gothic....* gnu/packages/fonts.scm (font-sarasa-gothic): New variable. Signed-off-by: Marius Bakke <marius@gnu.org> Zhu Zihao 2020-05-29gnu: font-comic-neue: Update to 2.5....* gnu/packages/fonts.scm (font-comic-neue): Update to 2.5. Tobias Geerinckx-Rice 2020-05-25gnu: font-gnu-unifont: Update to 13.0.02....* gnu/packages/fonts.scm (font-gnu-unifont): Update to 13.0.02. Efraim Flashner 2020-05-21gnu: font-abattis-cantarell: Update to 0.201....* gnu/packages/fonts.scm (font-abattis-cantarell): Update to 0.201. [native-inputs]: Remove appstream-glib. Tobias Geerinckx-Rice 2020-05-16gnu: Add font-api-mj-mincho....* gnu/packages/fonts.scm (font-api-mj-mincho): New variable. Julien Lepiller 2020-05-13gnu: font-gnu-freefont: Rename the ‘woff’ subdirectory....* gnu/packages/fonts.scm (font-gnu-freefont)[arguments]: Install WOFFs into ‘share/fonts/webfonts’. Signed-off-by: Tobias Geerinckx-Rice <me@tobias.gr> Michael Rohleder 2020-05-13gnu: font-gnu-freefont: Revert fonts' subdirectory names....* gnu/packages/fonts.scm (font-gnu-freefont)[arguments]<#:phases>: Change ‘share/fonts’ subdirectories from ‘ttf’ and ‘otf’ back to ‘truetype’ and ‘opentype’, respectively. Signed-off-by: Tobias Geerinckx-Rice <me@tobias.gr> Raghav Gururajan 2020-05-13mailmap: Update entries for Nikita....* .mailmap: change email and name for Nikita. * Makefile.am, doc/guix.texi, etc/completion/fish/guix.fish, gnu/packages/accessibility.scm, gnu/packages/admin.scm, gnu/packages/audio.scm, gnu/packages/autotools.scm, gnu/packages/cdrom.scm, gnu/packages/check.scm, gnu/packages/cinnamon.scm, gnu/packages/compression.scm, gnu/packages/crypto.scm, gnu/packages/databases.scm, gnu/packages/django.scm, gnu/packages/dns.scm, gnu/packages/elixir.scm, gnu/packages/emacs-xyz.scm, gnu/packages/emacs.scm, gnu/packages/enlightenment.scm, gnu/packages/erlang.scm, gnu/packages/fonts.scm, gnu/packages/fontutils.scm, gnu/packages/forth.scm, gnu/packages/fvwm.scm, gnu/packages/games.scm, gnu/packages/gl.scm, gnu/packages/gnome.scm, gnu/packages/gnunet.scm, gnu/packages/gnupg.scm, gnu/packages/gtk.scm, gnu/packages/guile-wm.scm, gnu/packages/guile-xyz.scm, gnu/packages/haskell-apps.scm, gnu/packages/haskell-check.scm, gnu/packages/haskell-crypto.scm, gnu/packages/haskell-xyz.scm, gnu/packages/haskell.scm, gnu/packages/image-viewers.scm, gnu/packages/image.scm, gnu/packages/irc.scm, gnu/packages/language.scm, gnu/packages/libcanberra.scm, gnu/packages/linux.scm, gnu/packages/lisp-xyz.scm, gnu/packages/lisp.scm, gnu/packages/lolcode.scm, gnu/packages/lxde.scm, gnu/packages/lxqt.scm, gnu/packages/mail.scm, gnu/packages/markup.scm, gnu/packages/mate.scm, gnu/packages/maths.scm, gnu/packages/mc.scm, gnu/packages/messaging.scm, gnu/packages/music.scm, gnu/packages/ncurses.scm, gnu/packages/networking.scm, gnu/packages/nickle.scm, gnu/packages/openbox.scm, gnu/packages/pdf.scm, gnu/packages/perl-check.scm, gnu/packages/perl.scm, gnu/packages/python-compression.scm, gnu/packages/python-crypto.scm, gnu/packages/python-web.scm, gnu/packages/python-xyz.scm, gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/ruby.scm, gnu/packages/rust.scm, gnu/packages/scheme.scm, gnu/packages/serialization.scm, gnu/packages/shells.scm, gnu/packages/ssh.scm, gnu/packages/suckless.scm, gnu/packages/tbb.scm, gnu/packages/telephony.scm, gnu/packages/text-editors.scm, gnu/packages/textutils.scm, gnu/packages/time.scm, gnu/packages/tls.scm, gnu/packages/tor.scm, gnu/packages/version-control.scm, gnu/packages/video.scm, gnu/packages/vim.scm, gnu/packages/web.scm, gnu/packages/wm.scm, gnu/packages/xdisorg.scm, gnu/packages/xfce.scm, gnu/packages/xml.scm, gnu/packages/xorg.scm, gnu/services/certbot.scm, gnu/services/desktop.scm, gnu/services/version-control.scm, gnu/services/web.scm, guix/import/hackage.scm, guix/licenses.scm: Likewise. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> nikita 2020-04-24gnu: font-gnu-freefont: Build with an older version of FontForge....Fixes <https://bugs.gnu.org/40819>. Reported by Jack Hill <jackhill@jackhill.us>. * gnu/packages/fontutils.scm (fontforge-20190801): New public variable. * gnu/packages/fonts.scm (font-gnu-freefont)[native-inputs]: Change from inherited FontForge variant to FONTFORGE-20190801. Marius Bakke 2020-04-23gnu: GNU FreeFont: Add a deprecated alias for "font-gnu-freefont-ttf"....This is a followup to commit 5483a2d0a913fe533744699e9ef5757c6e3f6983. * gnu/packages/fonts.scm (font-gnu-freefont-ttf): New variable. Leo Famulari 2020-04-22gnu: font-gnu-freefont: Add otf and woff font types....* gnu/packages/fonts.scm (font-gnu-freefont): Add otf and woff font types. * gnu/packages/genealogy.scm (gramps)[inputs]: Replace font-gnu-freefont-tff with font-gnu-freefont. * doc/guix.texi: Adjust a reference to the package. Signed-off-by: Leo Famulari <leo@famulari.name> Raghav Gururajan 2020-04-22gnu: Add font-meera-inimai....* gnu/packages/fonts.scm (font-meera-inimai): New variable. Arun Isaac 2020-04-02gnu: Add font-iosevka-term....* gnu/packages/fonts.scm (font-iosevka-term): New variable. Signed-off-by: Marius Bakke <mbakke@fastmail.com> John Soo 2020-04-02gnu: Add font-iosevka-term-slab....* gnu/packages/fonts.scm (font-iosevka-term-slab): New variable. Signed-off-by: Marius Bakke <mbakke@fastmail.com> John Soo 2020-04-01gnu: font-gnu-unifont: Update to 13.0.01....* ngu/packages/fonts.scm (font-gnu-unifont): Update to 13.0.01. [home-page]: Follow redirect. Efraim Flashner 2020-03-31gnu: font-rachana: Don't use unstable tarball....* gnu/packages/fonts.scm (font-rachana)[source]: Use GIT-FETCH and GIT-FILE-NAME. Tobias Geerinckx-Rice 2020-03-31gnu: font-rachana: Update to 7.0.3....* gnu/packages/fonts.scm (font-rachana): Update to 7.0.3. Tobias Geerinckx-Rice 2020-03-29gnu: font-jetbrains-mono: Update to 1.0.3....* gnu/packages/fonts.scm (font-jetbrains-mono): update to 1.0.3 Signed-off-by: Marius Bakke <mbakke@fastmail.com> Michael Rohleder 2020-03-28Update email address and Savannah handle for Amin Bandali....* .mailmap, gnu/local.mk, gnu/packages/emacs-xyz.scm, gnu/packages/emacs.scm, gnu/packages/fonts.scm, gnu/packages/fpga.scm, gnu/packages/lean.scm, gnu/packages/maths.scm, gnu/packages/pulseaudio.scm: Update my email address. * build-aux/git-authenticate.scm: Update my Savannah handle. Amin Bandali 2020-03-10gnu: font-dosis: Use archive.org'd URIs....* gnu/packages/fonts.scm (font-dosis)[source, home-page]: Use snapshots. Tobias Geerinckx-Rice 2020-03-08gnu: Add font-opendyslexic....* gnu/packages/fonts.scm (font-opendyslexic): New variable. (font-open-dyslexic): Mark as deprecated package. Efraim Flashner 2020-02-25gnu: font-fantasque-sans: Update to 1.8.0....* gnu/packages/fonts.scm (font-fantasque-sans): Update to 1.8.0. [native-inputs]: Remove ttf2eot. [arguments]: Rename the ‘xrange->range’ phase to ‘support-python@3’. Patch another Python twoism. Tobias Geerinckx-Rice 2020-02-23gnu: font-google-material-design-icons: Use HTTPS home page....* gnu/packages/fonts.scm (font-google-material-design-icons)[home-page]: Use HTTPS. Tobias Geerinckx-Rice 2020-02-21gnu: Add font-vazir....* gnu/packages/fonts.scm (font-vazir): New variable. Amin Bandali 2020-02-10gnu: Add copyright line....Add missing copyright line for commit 200514cd8fe1797d7653386a7b1ed1106c61164e. Nicolas Goaziou 2020-02-10gnu: Add font-jetbrains-mono....* gnu/packages/fonts.scm (font-jetbrains-mono): New variable. Damien Cassou