From f30f596eca344fd9c4bbb53e16b605be3afa46ba Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Thu, 17 May 2018 10:39:32 +0200 Subject: [PATCH] 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. --- Makefile | 5 +++-- bundle/ql.lisp | 9 ++++++-- src/regress/regress.lisp | 44 +++++++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 9f9917b4..1d0a32d5 100644 --- a/Makefile +++ b/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 diff --git a/bundle/ql.lisp b/bundle/ql.lisp index 26e0138d..dbaee731 100644 --- a/bundle/ql.lisp +++ b/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) diff --git a/src/regress/regress.lisp b/src/regress/regress.lisp index 30a94708..5f0a3f8f 100644 --- a/src/regress/regress.lisp +++ b/src/regress/regress.lisp @@ -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))) +