| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (use-modules (gnu tests)
|
| 20 | (gnu packages package-management)
|
| 21 | (guix monads)
|
| 22 | (guix store)
|
| 23 | ((guix git-download) #:select (git-predicate))
|
| 24 | ((guix utils) #:select (current-source-directory))
|
| 25 | (git)
|
| 26 | (ice-9 match))
|
| 27 |
|
| 28 | (define (source-commit directory)
|
| 29 | "Return the commit of the head of DIRECTORY or #f if it could not be
|
| 30 | determined."
|
| 31 | (let ((repository #f))
|
| 32 | (catch 'git-error
|
| 33 | (lambda ()
|
| 34 | (set! repository (repository-open directory))
|
| 35 | (let* ((head (repository-head repository))
|
| 36 | (target (reference-target head))
|
| 37 | (commit (oid->string target)))
|
| 38 | (repository-close! repository)
|
| 39 | commit))
|
| 40 | (lambda _
|
| 41 | (when repository
|
| 42 | (repository-close! repository))
|
| 43 | #f))))
|
| 44 |
|
| 45 | (define (tests-for-current-guix source commit)
|
| 46 | "Return a list of tests for perform, using Guix built from SOURCE, a channel
|
| 47 | instance."
|
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | (let ((guix (channel-source->package source #:commit commit)))
|
| 53 | (map (lambda (test)
|
| 54 | (system-test
|
| 55 | (inherit test)
|
| 56 | (value (store-parameterize ((current-guix-package guix))
|
| 57 | (system-test-value test)))))
|
| 58 | (match (getenv "TESTS")
|
| 59 | (#f
|
| 60 | (all-system-tests))
|
| 61 | ((= string-tokenize (tests ...))
|
| 62 | (filter (lambda (test)
|
| 63 | (member (system-test-name test) tests))
|
| 64 | (all-system-tests)))))))
|
| 65 |
|
| 66 | (define (system-test->manifest-entry test)
|
| 67 | "Return a manifest entry for TEST, a system test."
|
| 68 | (manifest-entry
|
| 69 | (name (string-append "test." (system-test-name test)))
|
| 70 | (version "0")
|
| 71 | (item test)))
|
| 72 |
|
| 73 | (define (system-test-manifest)
|
| 74 | "Return a manifest containing all the system tests, or all those selected by
|
| 75 | the 'TESTS' environment variable."
|
| 76 | (define source
|
| 77 | (string-append (current-source-directory) "/../.."))
|
| 78 |
|
| 79 | (define commit
|
| 80 | |
| 81 | |
| 82 | (source-commit source))
|
| 83 |
|
| 84 | |
| 85 | |
| 86 | |
| 87 | (let* ((source (local-file source
|
| 88 | (if commit
|
| 89 | (string-append "guix-"
|
| 90 | (string-take commit 7))
|
| 91 | "guix-source")
|
| 92 | #:recursive? #t
|
| 93 | #:select?
|
| 94 | (or (git-predicate source)
|
| 95 | (const #t))))
|
| 96 | (tests (tests-for-current-guix source commit)))
|
| 97 | (format (current-error-port) "Selected ~a system tests...~%"
|
| 98 | (length tests))
|
| 99 |
|
| 100 | (manifest (map system-test->manifest-entry tests))))
|
| 101 |
|
| 102 | |
| 103 | (system-test-manifest)
|