mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-07 14:56:59 +02:00
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:
parent
1fe835d31b
commit
f30f596eca
5
Makefile
5
Makefile
@ -171,8 +171,9 @@ $(BUNDLETESTD):
|
||||
|
||||
$(BUNDLEDIR):
|
||||
mkdir -p $@
|
||||
$(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \
|
||||
--eval '(defvar *bundle-dir* "$@")' \
|
||||
$(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \
|
||||
--eval '(defvar *bundle-dir* "$@")' \
|
||||
--eval '(defvar *pwd* "$(PWD)/")' \
|
||||
--eval '(defvar *ql-dist* "$(BUNDLEDIST)")' \
|
||||
--load bundle/ql.lisp
|
||||
|
||||
|
@ -12,7 +12,12 @@
|
||||
(defvar *ql-dist-url-format*
|
||||
"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*))
|
||||
(cdr
|
||||
;; available-versions is an alist of (date . url), and the
|
||||
@ -21,5 +26,5 @@
|
||||
(ql-dist:available-versions (ql-dist:dist "quicklisp"))))
|
||||
(format nil *ql-dist-url-format* *ql-dist*))))
|
||||
(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)
|
||||
|
@ -28,21 +28,16 @@
|
||||
|
||||
;; once we are done running the load-file, compare the loaded data with
|
||||
;; our expected data file
|
||||
(bind ((expected-subdir (directory-namestring
|
||||
(asdf:system-relative-pathname
|
||||
:pgloader "test/regress/expected/")))
|
||||
(expected-data-file (make-pathname :defaults load-file
|
||||
:type "out"
|
||||
:directory expected-subdir))
|
||||
((target-conn target-table-name gucs) (parse-target-pg-db-uri load-file))
|
||||
(bind ((expected-data-source
|
||||
(regression-test-expected-data-source load-file))
|
||||
|
||||
((target-conn target-table-name gucs)
|
||||
(parse-target-pg-db-uri load-file))
|
||||
|
||||
(target-table (create-table target-table-name))
|
||||
(*pg-settings* (pgloader.pgsql:sanitize-user-gucs gucs))
|
||||
(*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
|
||||
(expected-data-target
|
||||
(let ((e-d-t (clone-connection target-conn)))
|
||||
@ -58,7 +53,8 @@
|
||||
(expected-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
|
||||
(with-pgsql-connection (target-conn)
|
||||
@ -130,3 +126,27 @@
|
||||
join pg_type t on t.oid = a.atttypid
|
||||
where c.oid = '~:[~*~a~;~a.~a~]'::regclass and attnum > 0
|
||||
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)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user