Fork me on GitHub
#kaocha
<
2019-01-30
>
plexus03:01:45

@christian767 not sure what's happening there, those patterns seem to work for me

plexus03:01:17

e.g. I do touch 'test/unit/.#foo.clj' or touch 'test/unit/#foo.clj' and no re-run gets triggered

plexus03:01:21

I would run with --no-capture-output, and put some print statements in glob? and wait-and-rescan? to better see what's happening

cjohansen07:01:04

turns out the exclude works fine, but I still get duplicate runs because of directory-level events on OSX: https://github.com/lambdaisland/kaocha/pull/63

borkdude13:01:42

:kaocha/tests describes different groups of tests aka test suites. is it possible to enable a plugin only for specific test suites (e.g. I’m writing a plugin that instruments specific fdefs), or should I as a plugin writer do extra work for people to use it that way?

borkdude13:01:37

I haven’t seen such an example in the docs

borkdude13:01:24

If this is not possible, how do I go about implementing this? I want the user to specify in their test suite: do not instrument these functions.

plexus13:01:06

@borkdude that would be up to you as the plugin author to work on the test suite level

borkdude13:01:24

my plugin currently looks like this:

(ns speculative.plugin
  (:require [kaocha.plugin :refer [defplugin]]
            [speculative.instrument :refer [instrument unstrument]]))

(defplugin speculative.plugin/instrument
  (pre-run [test-plan]
           (prn "TEST PLAN" test-plan)
           (instrument)
           test-plan)
  (post-run [result]
            (unstrument)
            result))

plexus13:01:09

and what would the configuration look like?

borkdude13:01:16

I have no idea yet 🙂

plexus13:01:20

pre-run and post-run always run before or after the complete run, i.e. all suites that are set to run. There's also pre-test and post-test, which will work before/after any "testable"

plexus13:01:33

a test suite is a testable, a test ns is a testable, and a test var is a testable

plexus13:01:57

(and analoguous for other test types, e.g. for cucumber the nesting is suite > feature > scenario)

borkdude13:01:04

ah, I thought pre-test worked on each individual test, but the level is test-suite?

plexus13:01:27

it's recursive

borkdude13:01:37

a’ight, I’ll try this

plexus13:01:04

pre-test suite / pre-test ns / pre-test var / test var / post-test var / pre-test var 2 / test var 2 / post-test var 2 / post-test ns / post-test suite

plexus13:01:32

by checking the :kaocha.testable/type you can see which one you're dealing with

plexus13:01:16

you can compare those with the ones you find in the test plan to make sure you're only dealing with the top level ones. We really should add some stuff to kaocha.hierarchy as well for this, so far there's only the opposite, checking if a type is a "leaf" testable, i.e. representing an actual test var.

plexus13:01:26

because test suites could be of type :kaocha.type/clojure.test, :kaocha.type/cucumber, :kaocha.type/cljs. You should be able to say (kaocha.hierarchy/isa? type :kaocha.type/test-suite) but that's not there yet

plexus13:01:34

but like I said you can work around that by checking that the type (or the :kaocha.testable/id) is used at the top level of :kaocha.test-plan/tests in the test-plan

borkdude15:01:31

how can I wrap the running of a test(-suite)? it seems when I do something in pre/post-test, it happens before these tests are executed. these hooks are probably only for altering the config or something?

borkdude15:01:16

it’s hard to see, because the output is only printed when I have a failure.

cjohansen15:01:13

There is a flag to disable output capturing

borkdude15:01:53

ah, good to know.

borkdude15:01:31

I already read that, but I misinterpreted it, sorry 🙂

borkdude15:01:27

> You should be able to say (kaocha.hierarchy/isa? type :kaocha.type/test-suite) Yes, now I get what you mean by this. You could also just add a key :kaocha.test-suite? true which plugins could pick up on.

borkdude16:01:49

is there a way to run .cljc tests in both clojure and cljs mode?

borkdude16:01:53

if not, I’ll have to duplicate my test suite configs

borkdude16:01:35

FYI, I’m getting an error while running a CLJS test:

Exception in thread "main" clojure.lang.ExceptionInfo: ClojureScript Exception {:via [{:type clojure.lang.ExceptionInfo, :message "No such namespace: speculative-kaocha.no-instrument, could not locate speculative_kaocha/no_instrument.cljs, speculative_kaocha/no_instrument.cljc

borkdude16:01:03

it’s probably early days for koacha CLJS

borkdude16:01:59

I think I have mistyped kaocha as koacha a million times now