summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLiliana Marie Prikler <liliana.prikler@gmail.com>2024-03-27 05:22:31 +0100
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2024-03-27 05:22:31 +0100
commit4c70f5242befb5786cb437559a4d8701e630bd29 (patch)
treedbbff437004184d50c9a53f6c4897a85361aceb1 /tests
parenta9e65e0341d5045e425e3cf8d741a3d13cfa35a1 (diff)
parent929ddec8f4a181be653152c7436581c2adc54eee (diff)
downloadguix-4c70f5242befb5786cb437559a4d8701e630bd29.tar.gz
Merge branch 'master' into emacs-team
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-time-machine.sh4
-rw-r--r--tests/lint.scm20
-rw-r--r--tests/swh.scm74
3 files changed, 96 insertions, 2 deletions
diff --git a/tests/guix-time-machine.sh b/tests/guix-time-machine.sh
index 983f796225..df75c681da 100644
--- a/tests/guix-time-machine.sh
+++ b/tests/guix-time-machine.sh
@@ -1,6 +1,6 @@
 # GNU Guix --- Functional package management for GNU
 # Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
-# Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2023-2024 Ludovic Courtès <ludo@gnu.org>
 #
 # This file is part of GNU Guix.
 #
@@ -39,7 +39,7 @@ else
     EXTRA_OPTIONS=""
 fi
 
-# Visiting a commit older than v1.0.0 must fail (this test is expensive
+# Visiting a commit older than v0.16.0 must fail (this test is expensive
 # because it clones the whole repository).
 guix time-machine -q --commit=v0.15.0 $EXTRA_OPTIONS -- describe && false
 
diff --git a/tests/lint.scm b/tests/lint.scm
index 87213fcc78..95d82d7490 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -1407,6 +1407,26 @@
                        (check-archival (dummy-package "x" (source origin)))))))
     (warning-contains? "scheduled" warnings)))
 
+(test-assert "archival: missing svn revision"
+  (let* ((origin   (origin
+                     (method svn-fetch)
+                     (uri (svn-reference
+                           (url "http://example.org/svn/foo")
+                           (revision "1234")))
+                     (sha256 (make-bytevector 32))))
+         ;; https://archive.softwareheritage.org/api/1/origin/save/
+         (save     "{ \"origin_url\": \"http://example.org/svn/foo\",
+                      \"save_request_date\": \"2014-11-17T22:09:38+01:00\",
+                      \"save_request_status\": \"accepted\",
+                      \"save_task_status\": \"scheduled\" }")
+         (warnings (with-http-server `((404 "No extid.") ;lookup-directory-by-nar-hash
+                                       (404 "No revision.") ;lookup-revision
+                                       (404 "No origin.")   ;lookup-origin
+                                       (200 ,save))         ;save-origin
+                     (parameterize ((%swh-base-url (%local-url)))
+                       (check-archival (dummy-package "x" (source origin)))))))
+    (warning-contains? "scheduled" warnings)))
+
 (test-equal "archival: revision available"
   '()
   (let* ((origin   (origin
diff --git a/tests/swh.scm b/tests/swh.scm
index e7ced6b50c..11dcbdddd8 100644
--- a/tests/swh.scm
+++ b/tests/swh.scm
@@ -109,6 +109,80 @@
                  (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