Skip to content

Commit

Permalink
Review bundle and regression test facilities.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dimitri committed May 17, 2018
1 parent 1fe835d commit f30f596
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions bundle/ql.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
44 changes: 32 additions & 12 deletions src/regress/regress.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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)
Expand Down Expand Up @@ -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)))

0 comments on commit f30f596

Please sign in to comment.