Skip to content

Commit

Permalink
Merge pull request #38 from masonpachner-lucid/lucid-master
Browse files Browse the repository at this point in the history
Enable -s arg for selenium test running
  • Loading branch information
jjudd authored Sep 8, 2023
2 parents 92b3616 + 632a8f6 commit 09e30f2
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ object TestRunner {
.addArgument("--framework_args")
.help("Additional arguments for testing framework")
parser
.addArgument("-s")
.help("Test class selector flag")
parser
}

private[this] val testArgParser = {
Expand Down Expand Up @@ -142,7 +145,10 @@ object TestRunner {
val frameworks = testNamespace.getList[String]("frameworks").asScala.flatMap(loader.load)

val testFilter = sys.env.get("TESTBRIDGE_TEST_ONLY").map(_.split("#", 2))
val testClass = testFilter.map(_.head).map(Pattern.compile)
val testClass = testFilter
.map(_.head)
.orElse(Option(namespace.getString("s")))
.map(Pattern.compile)
val testScopeAndName = testFilter.flatMap(_.lift(1))

var count = 0
Expand Down
21 changes: 21 additions & 0 deletions tests/test-frameworks/testrunner/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@rules_scala_annex//rules:scala.bzl", "scala_library", "scala_test")

scala_test(
name = "testrunnertest",
srcs = glob(["*.scala"]),
deps = [
"@annex_test//:org_specs2_specs2_common_2_13",
"@annex_test//:org_specs2_specs2_core_2_13",
"@annex_test//:org_specs2_specs2_matcher_2_13",
],
)

scala_library(
name = "aatestrunner",
srcs = glob(["*.scala"]),
deps = [
"@annex_test//:org_specs2_specs2_common_2_13",
"@annex_test//:org_specs2_specs2_core_2_13",
"@annex_test//:org_specs2_specs2_matcher_2_13",
],
)
13 changes: 13 additions & 0 deletions tests/test-frameworks/testrunner/BadTestThatIsFilteredOut.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package annex.specs2

import org.specs2.mutable.Specification

object BadTestThatIsFilteredOut extends Specification {

"this" should {
"will not pass" in {
true must_== false
}
}

}
13 changes: 13 additions & 0 deletions tests/test-frameworks/testrunner/TestRunnerSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package annex.specs2

import org.specs2.mutable.Specification

object TestRunnerSpec extends Specification {

"args" should {
"be parsed" in {
true must_== true
}
}

}
9 changes: 9 additions & 0 deletions tests/test-frameworks/testrunner/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -e
. "$(dirname "$0")"/../../common.sh

# `bazel test :testrunnertest`` will fail because BadTestThatIsFilteredOut fails
# This test makes sure that we can filter a target to just a specific test

bazel test --test_arg=-s --test_arg=TestRunnerSpec -- :testrunnertest


0 comments on commit 09e30f2

Please sign in to comment.