Multiple test runners
artemyarulin opened this issue · 0 comments
It's easy to notice that for CLJC we have test runners that basically is a copy of CLJ and CLJS test runners merged together. Such duplication is not good.
Another issue - right now I want to integrate CLJ/CLJS code linters. The only way to accomplish it right now by changing all test runners, which far away from being a good thing to do.
What we should be able to do is to define test runners (linter is just one kind of tests) and be able to compose it together.
Main issue comes from the way how we run test runners:
if tester: # Actual test task - simply run tester in the right folder
sh_test(name = name + '-test',
test = tester,
args = ['$(location :{0})'.format('__' + name)] + tester_args,
deps = [':__' + name])
As you can see Buck expects test runner to be an executable, so that's why we have all those tester*.sh
in the project.
We cannot do anything, but dynamically create new test runners.
Essentially we could implement something like that:
# config.py
test_runner_clj = 'LEIN_ROOT=1 lein test`
test_runner_cljs_doo = """
echo "(ns test.runner (:require [doo.runner :refer-macros [doo-all-tests]] \
[module.core])) (doo-all-tests)" > test/runner.cljs
LEIN_ROOT=1 lein doo phantom debug once
"""
test_runner_cljs_planck = """
planck --classpath="test:src" \
--eval="(ns test.test (:require [module.core] [cljs.test] [planck.core]))" \
--eval="(defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m] (when-not (cljs.test/successful? m) (planck.core/exit 1)))" \
--eval="(cljs.test/run-all-tests)"
"""
linter = "lein kibit"
# Will create //RULES/clj-cljs-config:test-runner-clj
test_runner(name='test-runner-clj',
commands = [linter,test_runner_clj])
# Will create //RULES/clj-cljs-config:test-runner-cljs-planck
test_runner(name='test-runner-cljs_planck'
commands = [linter,test_runner_cljs_planck])
# Will create //RULES/clj-cljs-config:test-runner-cljc-planck
test_runner(name='test-runner-cljc_planck',
commands = [linter,test_runner_clj,test_runner_cljs_planck])
clj_cljs_module(...,test_runner = ':test-runner-cljc-planck',....)