;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix iseijb" #:downloads 888) '(#:name "mesecons" #:author "Jeija" #:downloads 999))) ;; Determining the home page (test-package "minetest->guix-package, website is used as home page" #:home-page "web://site" #:website "web://site") (test-package "minetest->guix-package, if absent, the forum is used" #:home-page '(minetest-topic 628) #:forums 628 #:website 'null) (test-package "minetest->guix-package, if absent, the git repo is used" #:home-page "https://github.com/minetest-mods/mesecons" #:forums 'null #:website 'null #:repo "https://github.com/minetest-mods/mesecons") (test-package "minetest->guix-package, all home page information absent" #:home-page #f #:forums 'null #:website 'null #:repo 'null) ;; Determining the version number (test-package "conventional version number" #:version "1.2.3" #:title "1.2.3") ;; See e.g. orwell/basic_trains (test-package "v-prefixed version number" #:version "1.2.3" #:title "v1.2.3") ;; Many mods on ContentDB use dates as release titles. In that case, the date ;; will have to do. (test-package "dates as version number" #:version "2021-01-01" #:title "2021-01-01") ;; Dependencies (test-package* "minetest->guix-package, unambiguous dependency" (list #:requirements '(("mesecons" #f ("Jeija/mesecons" "some-modpack/containing-mese"))) #:inputs '("minetest-mesecons")) (list #:author "Jeija" #:name "mesecons") (list #:author "some-modpack" #:name "containing-mese" #:type "modpack")) (test-package* "minetest->guix-package, ambiguous dependency (highest score)" (list #:name "frobnicate" #:guix-name "minetest-frobnicate" #:upstream-name "Author/frobnicate" #:requirements '(("frob" #f ("Author/foo" "Author/bar"))) ;; #:sort "score" is the default #:inputs '("minetest-bar")) (list #:author "Author" #:name "foo" #:score 0) (list #:author "Author" #:name "bar" #:score 9999)) (test-package* "minetest->guix-package, ambiguous dependency (most downloads)" (list #:name "frobnicate" #:guix-name "minetest-frobnicate" #:upstream-name "Author/frobnicate" #:requirements '(("frob" #f ("Author/foo" "Author/bar"))) #:inputs '("minetest-bar") #:sort "downloads") (list #:author "Author" #:name "foo" #:downloads 0) (list #:author "Author" #:name "bar" #:downloads 9999)) (test-package "minetest->guix-package, optional dependency" #:requirements '(("mesecons" #t ("Jeija/mesecons" "some-modpack/containing-mese"))) #:inputs '()) ;; See e.g. 'orwell/basic_trains' (test-package* "minetest->guix-package, multiple dependencies implemented by one mod" (list #:name "frobnicate" #:guix-name "minetest-frobnicate" #:upstream-name "Author/frobnicate" #:requirements '(("frob" #f ("Author/frob")) ("frob_x" #f ("Author/frob"))) #:inputs '("minetest-frob")) (list #:author "Author" #:name "frob")) ;; License (test-package "minetest->guix-package, identical licenses" #:guix-license 'license:lgpl3+ #:license "LGPL-3.0-or-later" #:media-license "LGPL-3.0-or-later") ;; Sorting (let* ((make-package (lambda arguments (json->package (apply make-package-json arguments)))) (x (make-package #:score 0)) (y (make-package #:score 1)) (z (make-package #:score 2))) (test-equal "sort-packages, already sorted" (list z y x) (sort-packages (list z y x))) (test-equal "sort-packages, reverse" (list z y x) (sort-packages (list x y z)))) ;; Update detection (define (upstream-source->sexp upstream-source) (define url (upstream-source-urls upstream-source)) (unless (git-reference? url) (error "a <git-reference> is expected")) `(,(upstream-source-package upstream-source) ,(upstream-source-version upstream-source) ,(git-reference-url url) ,(git-reference-commit url))) (define* (expected-sexp #:key (repo "https://example.org/foo.git") (guix-name "minetest-foo") (new-version "0.8") (commit "44941798d222901b8f381b3210957d880b90a2fc") #:allow-other-keys) `(,guix-name ,new-version ,repo ,commit)) (define* (example-package #:key (source 'auto) (repo "https://example.org/foo.git") (old-version "0.8") (commit "44941798d222901b8f381b3210957d880b90a2fc") #:allow-other-keys) (package (name "minetest-foo") (version old-version) (source (if (eq? source 'auto) (origin (method git-fetch) (uri (git-reference (url repo) (commit commit #;"808f9ffbd3106da4c92d2367b118b98196c9e81e"))) (sha256 #f) ; not important for the following tests (file-name (git-file-name name version))) source)) (build-system minetest-mod-build-system) (license #f) (synopsis #f) (description #f) (home-page #f) (properties '((upstream-name . "Author/foo"))))) (define-syntax-rule (test-release test-case . arguments) (test-equal test-case (expected-sexp . arguments) (and=> (call-with-packages (cut latest-minetest-release (example-package . arguments)) (list . arguments)) upstream-source->sexp))) (define-syntax-rule (test-no-release test-case . arguments) (test-equal test-case #f (call-with-packages (cut latest-minetest-release (example-package . arguments)) (list . arguments)))) (test-release "same version" #:old-version "0.8" #:title "0.8" #:new-version "0.8" #:commit "44941798d222901b8f381b3210957d880b90a2fc") (test-release "new version (dotted)" #:old-version "0.8" #:title "0.9.0" #:new-version "0.9.0" #:commit "c8855b991880897b2658dc90164e29c96e2aeb3a") (test-release "new version (date)" #:old-version "2014-11-17" #:title "2015-11-04" #:new-version "2015-11-04" #:commit "c8855b991880897b2658dc90164e29c96e2aeb3a") (test-release "new version (git -> dotted)" #:old-version (git-version "0.8" "1" "90422555f114d3af35e7cc4b5b6d59a5c226adc4") #:title "0.9.0" #:new-version "0.9.0" #:commit "90422555f114d3af35e7cc4b5b6d59a5c226adc4") ;; There might actually be a new release, but guix cannot compare dates ;; with regular version numbers. (test-no-release "dotted -> date" #:old-version "0.8" #:title "2015-11-04" #:commit "c8855b991880897b2658dc90164e29c96e2aeb3a") (test-no-release "date -> dotted" #:old-version "2014-11-07" #:title "0.8" #:commit "c8855b991880897b2658dc90164e29c96e2aeb3a") ;; Don't let "guix refresh -t minetest" tell there are new versions ;; if Guix has insufficient information to actually perform the update, ;; when using --with-latest or "guix refresh -u". (test-no-release "no commit information, no new release" #:old-version "0.8" #:title "0.9.0" #:new-version "0.9.0" #:commit #false) (test-assert "minetest is not a minetest mod" (not (minetest-package? minetest))) (test-assert "GNU hello is not a minetest mod" (not (minetest-package? hello))) (test-assert "technic is a minetest mod" (minetest-package? minetest-technic)) (test-assert "upstream-name is required" (not (minetest-package? (package (inherit minetest-technic) (properties '()))))) (test-end "minetest") ;;; Local Variables: ;;; eval: (put 'test-package* 'scheme-indent-function 1) ;;; eval: (put 'test-release 'scheme-indent-function 1) ;;; eval: (put 'test-no-release 'scheme-indent-function 1) ;;; End: