|
244 | 244 | (defn- zprint-patch [lib]
|
245 | 245 | ;; zprint has a project.clj and a deps.edn, patch 'em both
|
246 | 246 | (deps-edn-v1-patch lib)
|
247 |
| - (project-clj-v1-patch lib)) |
| 247 | + (project-clj-v1-patch lib) |
| 248 | + (show-patch-diff lib)) |
248 | 249 |
|
249 | 250 | (defn- zprint-prep [{:keys [home-dir]}]
|
250 | 251 | (status/line :detail "=> Building uberjar for uberjar tests")
|
251 | 252 | (shcmd {:dir home-dir} "lein uberjar")
|
252 |
| - |
253 |
| - ;; not sure if this is still necessary, but probably does not hurt(?) |
| 253 | + ;; not sure if this is still necessary... |
254 | 254 | (status/line :detail "=> Installing zprint locally for ClojureScript tests")
|
255 | 255 | (shcmd {:dir home-dir} "lein install"))
|
256 | 256 |
|
| 257 | +(defn- zprint-cleanup [_lib] |
| 258 | + (status/line :detail "=> Deleting jar installed to local maven repo for tests") |
| 259 | + ;; currently an over-clobber but official zprint libs will re-install as needed |
| 260 | + (fs/delete-tree (fs/file (fs/home) ".m2/repository/zprint"))) |
| 261 | + |
257 | 262 | ;;
|
258 | 263 | ;; lib defs
|
259 | 264 | ;;
|
|
427 | 432 | (cli-deps-tree lib))
|
428 | 433 | :test-cmds ["lein with-profile expectations test"
|
429 | 434 | ;; disable zprint cljs tests for now, see https://github.com/planck-repl/planck/issues/1088
|
430 |
| - #_"clojure -M:cljs-runner"]}]) |
| 435 | + #_"clojure -M:cljs-runner"] |
| 436 | + :cleanup-fn zprint-cleanup}]) |
431 | 437 |
|
432 | 438 | (defn- header [text]
|
433 | 439 | (let [dashes (apply str (repeat 80 "-"))]
|
434 | 440 | (status/line :head (str dashes "\n"
|
435 | 441 | text "\n"
|
436 | 442 | dashes))))
|
437 | 443 |
|
438 |
| -(defn- test-lib [{:keys [name root patch-fn prep-fn show-deps-fn test-cmds] :as lib}] |
| 444 | +(defn- test-lib [{:keys [name root patch-fn prep-fn show-deps-fn test-cmds cleanup-fn] :as lib}] |
439 | 445 | (header name)
|
440 | 446 | (let [home-dir (do
|
441 | 447 | (status/line :head "%s: Fetching" name)
|
|
450 | 456 | (when patch-fn
|
451 | 457 | (status/line :head "%s: Patching" name)
|
452 | 458 | (patch-fn lib))
|
453 |
| - (when prep-fn |
454 |
| - (status/line :head "%s: Preparing" name) |
455 |
| - (prep-fn lib)) |
456 |
| - (when (not show-deps-fn) |
457 |
| - (throw (ex-info (format "missing show-deps-fn for %s" name) {}))) |
458 |
| - (status/line :head "%s: Effect of our patches" name) |
459 |
| - (show-patch-diff lib) |
460 |
| - (status/line :head "%s: Deps report" name) |
461 |
| - (show-deps-fn lib) |
462 |
| - (when-not test-cmds |
463 |
| - (throw (ex-info (format "missing test-cmds for %s" name) {}))) |
464 |
| - (status/line :head "%s: Running tests" name) |
465 |
| - (let [exit-codes (into [] (map-indexed (fn [ndx cmd] |
466 |
| - (let [{:keys [exit]} (shcmd {:dir home-dir :continue true} cmd)] |
467 |
| - (if (zero? exit) |
468 |
| - (status/line :detail "=> %s: TESTS %d of %d PASSED\n" name (inc ndx) (count test-cmds)) |
469 |
| - (status/line :warn "=> %s: TESTS %d of %d FAILED" name (inc ndx) (count test-cmds))) |
470 |
| - exit)) |
471 |
| - test-cmds))] |
472 |
| - (assoc lib :exit-codes exit-codes)))) |
| 459 | + (try |
| 460 | + (when prep-fn |
| 461 | + (status/line :head "%s: Preparing" name) |
| 462 | + (prep-fn lib)) |
| 463 | + (when (not show-deps-fn) |
| 464 | + (throw (ex-info (format "missing show-deps-fn for %s" name) {}))) |
| 465 | + (status/line :head "%s: Effect of our patches" name) |
| 466 | + (show-patch-diff lib) |
| 467 | + (status/line :head "%s: Deps report" name) |
| 468 | + (show-deps-fn lib) |
| 469 | + (when-not test-cmds |
| 470 | + (throw (ex-info (format "missing test-cmds for %s" name) {}))) |
| 471 | + (status/line :head "%s: Running tests" name) |
| 472 | + (let [exit-codes (into [] (map-indexed (fn [ndx cmd] |
| 473 | + (let [{:keys [exit]} (shcmd {:dir home-dir :continue true} cmd)] |
| 474 | + (if (zero? exit) |
| 475 | + (status/line :detail "=> %s: TESTS %d of %d PASSED\n" name (inc ndx) (count test-cmds)) |
| 476 | + (status/line :warn "=> %s: TESTS %d of %d FAILED" name (inc ndx) (count test-cmds))) |
| 477 | + exit)) |
| 478 | + test-cmds))] |
| 479 | + (assoc lib :exit-codes exit-codes)) |
| 480 | + (finally |
| 481 | + (when cleanup-fn |
| 482 | + (status/line :head "%s: Cleanup" name) |
| 483 | + (cleanup-fn lib)))))) |
473 | 484 |
|
474 | 485 | (defn- prep-target [target-root-dir]
|
475 | 486 | (status/line :head "Prep target")
|
|
0 commit comments