diff options
author | Clément Lassieur <clement@lassieur.org> | 2018-09-02 09:45:48 +0200 |
---|---|---|
committer | Clément Lassieur <clement@lassieur.org> | 2018-09-29 22:29:06 +0200 |
commit | 4e661552c3a0bebd9b584dcf72b9e949fb5582ef (patch) | |
tree | 83fa7b387ee0a5db7f902c6324c92d8dbc3287f2 /tests | |
parent | 8d40c49170971ad7bbf8b97336934dbb3d949fc1 (diff) | |
download | cuirass-4e661552c3a0bebd9b584dcf72b9e949fb5582ef.tar cuirass-4e661552c3a0bebd9b584dcf72b9e949fb5582ef.tar.gz |
database: Add builds only if one of their outputs is new.
* Makefile.am (dist_sql_DATA): Add 'src/sql/upgrade-4.sql'.
* src/cuirass/database.scm (db-add-output): New procedure.
(db-add-build): Call DB-ADD-OUTPUT, rollback the transaction and return #f if
DB-ADD-OUTPUT returned an empty list.
* src/schema.sql (Outputs): Set 'path' as primary key, instead of 'derivation,
name'.
* src/sql/upgrade-4.sql: New file with SQL queries to upgrade the database.
* tests/database.scm (make-dummy-build): Use the #:OUTPUTS key. Get default
OUTPUTS to depend on DRV.
("db-add-build-with-fixed-output"): New test.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/database.scm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/database.scm b/tests/database.scm index 21a12f4..d9dfe13 100644 --- a/tests/database.scm +++ b/tests/database.scm @@ -57,14 +57,15 @@ (define* (make-dummy-build drv #:optional (eval-id 42) - #:key (outputs '(("foo" . "/foo")))) + #:key (outputs + `(("foo" . ,(format #f "~a.output" drv))))) `((#:derivation . ,drv) (#:eval-id . ,eval-id) (#:job-name . "job") (#:system . "x86_64-linux") (#:nix-name . "foo") (#:log . "log") - (#:outputs . (("foo" . "/foo"))))) + (#:outputs . ,outputs))) (define-syntax-rule (with-temporary-database body ...) (call-with-temporary-output-file @@ -114,6 +115,17 @@ INSERT INTO Evaluations (specification, in_progress) VALUES (3, false);") ;; there, see <https://bugs.gnu.org/28094>. (db-add-build build))) + (test-equal "db-add-build-with-fixed-output" + #f + (let ((build1 (make-dummy-build "/fixed1.drv" + #:outputs '(("out" . "/fixed-output")))) + (build2 (make-dummy-build "/fixed2.drv" + #:outputs '(("out" . "/fixed-output"))))) + (db-add-build build1) + + ;; Should return #f because the outputs are the same. + (db-add-build build2))) + (test-equal "db-update-build-status!" (list (build-status scheduled) (build-status started) |