These are chat archives for etorreborre/specs2

30th
Oct 2017
Igal Tabachnik
@hmemcpy
Oct 30 2017 12:12
Hello :)
We're implementing support for running specs2 tests from Bazel (Google's build system)
I'm trying to make it run a single test... having some trouble convincing specs2 to run just that
(also, this is specs2 being run with junit runner)
The way this works is that I can get a hold of org.specs2.runner.JUnitRunner, and override its runWithEnv method, modifying the environment
unfortunately, trying to set e.g. include=mytest doesn't seem to work
I'm most definitely holding it wrong, any tips? :)
Eric Torreborre
@etorreborre
Oct 30 2017 12:16
can you try to implement a custom notifier for Bazel?
see the Notifier trait and NotifierRunner
Igal Tabachnik
@hmemcpy
Oct 30 2017 12:17
Hmm, let me see
(I've just started digging around in the bazel-plugin/rule-scala code, so it may take a bit :))
ok, I just found how it's implemented in intellij's scala plugin... thanks for the hint, let me see :)
Eric Torreborre
@etorreborre
Oct 30 2017 12:21
great I hope it will work fine for you
Igal Tabachnik
@hmemcpy
Oct 30 2017 12:24
oh wow, reading what intellij is doing is... scary :)
unless I misread it, they grab a NotifierRunner by reflection and call it :scream:
Eric Torreborre
@etorreborre
Oct 30 2017 12:26
I think they do this for compatibility reasons
Igal Tabachnik
@hmemcpy
Oct 30 2017 12:29
Hmm... I still need to look deeply into this.. it seems that with bazel their entry point to test filtering is junit's RunnerBuilder, which expects to get a Runner back
they already support specs2 (but without any filtering), so they just return the JUnitRunner instance that specs2 creates
Igal Tabachnik
@hmemcpy
Oct 30 2017 12:44
ok, I've got news!
I was successfully run a single test, unfortunately not using a NotifierRunner
I want to clear the terminology, though... what is 'example' exactly?
Because I was just able to do it by setting ex to "mytest.*", but this feels... hacky
Clears it up :)
Eric Torreborre
@etorreborre
Oct 30 2017 14:37
specs2 tried to adopt the BDD terminology where a "test class" is a "specification" and a "test" is an "example"
Igal Tabachnik
@hmemcpy
Oct 30 2017 14:42
Yeah... in any event, I was able to plug into Bazel's already existing runner infra by getting a hold of specs2 JUnit runner, and overriding it with:
    override def runWithEnv(n: RunNotifier, env: Env): Action[Stats] = {
      val newArgs = Arguments(select = Select(_ex = Some(testName)))
      val newEnv = env.copy(arguments overrideWith newArgs)
      super.runWithEnv(n, newEnv)
    }
hope that's not too horrible :)
testName is something I get externally passed into the bazel runner
Eric Torreborre
@etorreborre
Oct 30 2017 14:44
at first glance it looks correct to me
Igal Tabachnik
@hmemcpy
Oct 30 2017 14:44
seems to work :)
I'll add a bunch of tests for this, but it's a good first step :)
Eric Torreborre
@etorreborre
Oct 30 2017 14:45
:+1: