Skip to content

Instantly share code, notes, and snippets.

@Kungi
Created August 22, 2014 16:00
Show Gist options
  • Save Kungi/28cde40596bc72f4e7a3 to your computer and use it in GitHub Desktop.
Save Kungi/28cde40596bc72f4e7a3 to your computer and use it in GitHub Desktop.
fntest 2
(defmacro build-test-call [nses format to-file output-file]
(let [format-fn (cond (= format "tap")
'clojure.test.tap/with-tap-output
(= format "junit")
'clojure.test.junit/with-junit-output
:else 'identity)]
(if to-file
`(quote (with-open [results#
(java.io.FileWriter. ~output-file)]
(binding [clojure.test/*test-out* results#]
('~format-fn (apply clojure.test/run-tests '~nses)))))
`(quote ('~format-fn (apply clojure.test/run-tests ~nses))))))
(defn clojure-test-tests
"Invokes the clojure.test test suite in the remote Clojure."
[nses {:keys [format to-file output-file]}]
(println "Running clojure.test tests...")
(println "Testing namespaces in container:" nses)
(if to-file
(println "Writing to file " output-file))
(println (str (cond (= format "tap")
"Producing TAP output"
(= format "junit")
"Producing junit output")))
(execute (pr-str (backtick/template (apply require '~nses))))
(let [call (build-test-call nses format to-file output-file)]
(println "Executing:" call)
(execute (pr-str (backtick/template
(clojure.test/successful?
@Kungi
Copy link
Author

Kungi commented Aug 22, 2014

Executing:
{code}
(clojure.core/with-open [results__4601__auto__ (java.io.FileWriter. output-file)](clojure.core/binding [clojure.test/test-out results__4601__auto__] %28%28quote identity%29 %28clojure.core/apply clojure.test/run-tests %28quote nses%29%29%29))
{code}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment