Review bundle and regression test facilities.

Some path computation didn't work when trying to regression test the
produced bundle.

Also, the bundle building steps would use the pgloader system definition and
dependencies from what's currently available in Quicklisp rather than from
the local pgloader.asd being built.
This commit is contained in:
Dimitri Fontaine 2018-05-17 10:39:32 +02:00
parent 1fe835d31b
commit f30f596eca
3 changed files with 42 additions and 16 deletions

View File

@ -171,8 +171,9 @@ $(BUNDLETESTD):
$(BUNDLEDIR): $(BUNDLEDIR):
mkdir -p $@ mkdir -p $@
$(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \ $(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \
--eval '(defvar *bundle-dir* "$@")' \ --eval '(defvar *bundle-dir* "$@")' \
--eval '(defvar *pwd* "$(PWD)/")' \
--eval '(defvar *ql-dist* "$(BUNDLEDIST)")' \ --eval '(defvar *ql-dist* "$(BUNDLEDIST)")' \
--load bundle/ql.lisp --load bundle/ql.lisp

View File

@ -12,7 +12,12 @@
(defvar *ql-dist-url-format* (defvar *ql-dist-url-format*
"http://beta.quicklisp.org/dist/quicklisp/~a/distinfo.txt") "http://beta.quicklisp.org/dist/quicklisp/~a/distinfo.txt")
(let ((dist (if (or (eq :latest *ql-dist*) (let ((pkgs (append '("pgloader" "buildapp")
(getf (read-from-string
(uiop:read-file-string
(uiop:merge-pathnames* "pgloader.asd" *pwd*)))
:depends-on)))
(dist (if (or (eq :latest *ql-dist*)
(string= "latest" *ql-dist*)) (string= "latest" *ql-dist*))
(cdr (cdr
;; available-versions is an alist of (date . url), and the ;; available-versions is an alist of (date . url), and the
@ -21,5 +26,5 @@
(ql-dist:available-versions (ql-dist:dist "quicklisp")))) (ql-dist:available-versions (ql-dist:dist "quicklisp"))))
(format nil *ql-dist-url-format* *ql-dist*)))) (format nil *ql-dist-url-format* *ql-dist*))))
(ql-dist:install-dist dist :prompt nil :replace t) (ql-dist:install-dist dist :prompt nil :replace t)
(ql:bundle-systems '("pgloader" "buildapp") :to *bundle-dir*)) (ql:bundle-systems pkgs :to *bundle-dir*))
(quit) (quit)

View File

@ -28,21 +28,16 @@
;; once we are done running the load-file, compare the loaded data with ;; once we are done running the load-file, compare the loaded data with
;; our expected data file ;; our expected data file
(bind ((expected-subdir (directory-namestring (bind ((expected-data-source
(asdf:system-relative-pathname (regression-test-expected-data-source load-file))
:pgloader "test/regress/expected/")))
(expected-data-file (make-pathname :defaults load-file ((target-conn target-table-name gucs)
:type "out" (parse-target-pg-db-uri load-file))
:directory expected-subdir))
((target-conn target-table-name gucs) (parse-target-pg-db-uri load-file))
(target-table (create-table target-table-name)) (target-table (create-table target-table-name))
(*pg-settings* (pgloader.pgsql:sanitize-user-gucs gucs)) (*pg-settings* (pgloader.pgsql:sanitize-user-gucs gucs))
(*pgsql-reserved-keywords* (list-reserved-keywords target-conn)) (*pgsql-reserved-keywords* (list-reserved-keywords target-conn))
(expected-data-source
(parse-source-string-for-type
:copy (uiop:native-namestring expected-data-file)))
;; change target table-name schema ;; change target table-name schema
(expected-data-target (expected-data-target
(let ((e-d-t (clone-connection target-conn))) (let ((e-d-t (clone-connection target-conn)))
@ -58,7 +53,8 @@
(expected-target-table (expected-target-table
(create-table (cons "expected" (table-name target-table))))) (create-table (cons "expected" (table-name target-table)))))
(log-message :log "Comparing loaded data against ~s" expected-data-file) (log-message :log "Comparing loaded data against ~s"
(cdr (pgloader.sources::md-spec expected-data-source)))
;; prepare expected table in "expected" schema ;; prepare expected table in "expected" schema
(with-pgsql-connection (target-conn) (with-pgsql-connection (target-conn)
@ -130,3 +126,27 @@
join pg_type t on t.oid = a.atttypid join pg_type t on t.oid = a.atttypid
where c.oid = '~:[~*~a~;~a.~a~]'::regclass and attnum > 0 where c.oid = '~:[~*~a~;~a.~a~]'::regclass and attnum > 0
order by attnum" schema schema table-name))) order by attnum" schema schema table-name)))
;;;
;;; Helper functions
;;;
(defun regression-test-expected-data-source (load-file)
"Returns the source specification where to read the expected result for
the given LOAD-FILE."
(let* ((load-file-dir (uiop:pathname-directory-pathname
(if (uiop:absolute-pathname-p load-file)
load-file
(uiop:merge-pathnames* load-file
(uiop:getcwd)))))
(expected-subdir (uiop:native-namestring
(uiop:merge-pathnames* "regress/expected/"
load-file-dir)))
(expected-data-file (make-pathname :defaults load-file
:type "out"
:directory expected-subdir))
(expected-data-source (uiop:native-namestring expected-data-file)))
(parse-source-string-for-type :copy expected-data-source)))