diff options
| author | Hugo Buddelmeijer <hugo@buddelmeijer.nl> | 2026-06-30 17:42:10 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2026-07-01 09:08:53 +0200 |
| commit | 85571d27d2e830fd7f6e96dc4df7f92a30ff3c2e (patch) | |
| tree | df97f972f2342e387b0f7ae738f13ed92d1bf7ff /tests | |
| parent | 636a104836fe00fca5844e15e3c40c9cf5cd1427 (diff) | |
daemon: Don't delete files from the store with guix build -K --rounds=3 --check.
Specifying all three of -K, --check, --rounds=3 caused valid packages to be
deleted from the store.
When `buildMode == bmCheck`, the built package is not renamed from
`actualPath` to `i.second.path. Then later, when `settings.keepFailed` and
`curRound < nrRounds`, `i.second.path` was renamed to `i.second.path + "-check"`
anyway.
* nix/libstore/build.cc (DerivationGoal::registerOutputs): Add check for bmCheck
before renaming store path.
* tests/store.scm ("build-things, check mode"): Ensure file is a valid path.
("build-things, check mode + keep-failed"): New test.
Fixes: #9631.
Change-Id: I31d24b2349f563867b8101a1b5ce3c10896ce165
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #9632
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/store.scm | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/store.scm b/tests/store.scm index a3e67ac7ea4..87773bf0c36 100644 --- a/tests/store.scm +++ b/tests/store.scm | |||
| @@ -1702,7 +1702,8 @@ System: x86_64-linux~%" | |||
| 1702 | (begin | 1702 | (begin |
| 1703 | (guard (c ((store-protocol-error? c) | 1703 | (guard (c ((store-protocol-error? c) |
| 1704 | (pk 'determinism-exception c) | 1704 | (pk 'determinism-exception c) |
| 1705 | (and (not (zero? (store-protocol-error-status c))) | 1705 | (and (valid-path? store file) ;must still be valid |
| 1706 | (not (zero? (store-protocol-error-status c))) | ||
| 1706 | (string-contains (store-protocol-error-message c) | 1707 | (string-contains (store-protocol-error-message c) |
| 1707 | "deterministic")))) | 1708 | "deterministic")))) |
| 1708 | ;; This one will produce a different result. Since we're in | 1709 | ;; This one will produce a different result. Since we're in |
| @@ -1711,6 +1712,34 @@ System: x86_64-linux~%" | |||
| 1711 | (build-mode check)) | 1712 | (build-mode check)) |
| 1712 | #f)))))) | 1713 | #f)))))) |
| 1713 | 1714 | ||
| 1715 | (test-equal "build-things, check mode + keep-failed" | ||
| 1716 | '(#t #t) | ||
| 1717 | (with-store store | ||
| 1718 | (let* ((drv (build-expression->derivation | ||
| 1719 | store "deterministic-thing-to-check" | ||
| 1720 | `(let ((out (assoc-ref %outputs "out"))) | ||
| 1721 | (call-with-output-file out | ||
| 1722 | (lambda (port) | ||
| 1723 | (display ,(let ((now (gettimeofday))) | ||
| 1724 | (+ (car now) (cdr now))) | ||
| 1725 | port)))) | ||
| 1726 | #:guile-for-build | ||
| 1727 | (package-derivation | ||
| 1728 | store %bootstrap-guile (%current-system)))) | ||
| 1729 | (file (derivation->output-path drv))) | ||
| 1730 | (and (build-things store (list (derivation-file-name drv))) | ||
| 1731 | (valid-path? store file) | ||
| 1732 | (begin | ||
| 1733 | ;; This would trigger accidental deletion of FILE. | ||
| 1734 | (set-build-options store | ||
| 1735 | #:keep-failed? #t | ||
| 1736 | #:keep-going? #t | ||
| 1737 | #:rounds 3) | ||
| 1738 | (build-things store (list (derivation-file-name drv)) | ||
| 1739 | (build-mode check)) | ||
| 1740 | (list (valid-path? store file) | ||
| 1741 | (file-exists? file))))))) | ||
| 1742 | |||
| 1714 | (test-assert "build-succeeded trace in check mode" | 1743 | (test-assert "build-succeeded trace in check mode" |
| 1715 | (string-contains | 1744 | (string-contains |
| 1716 | (call-with-output-string | 1745 | (call-with-output-string |
