From 44d8bc605390d069aec72a79db3579bf0244b246 Mon Sep 17 00:00:00 2001 From: Yukihiko Sohda Date: Tue, 3 Jan 2023 02:05:55 +0900 Subject: [PATCH] spanScaleFactor support --- README.md | 10 +++++++++- .../groovy/com/github/maiflai/ScalaTestAction.groovy | 6 ++++++ .../groovy/com/github/maiflai/ScalaTestPlugin.groovy | 4 ++++ .../com/github/maiflai/ScalaTestActionTest.groovy | 10 +++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c9ff2a..0a200f3 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,14 @@ test { } ``` +Span Scale Factor +---------------- +```groovy +test { + spanScaleFactor 10.0 +} +``` + Other Frameworks ---------------- The default behaviour is to replace all `Test` tasks with a scalatest implementation. @@ -157,4 +165,4 @@ task myTest(dependsOn: testClasses, type: Test, group: 'verification') { include 'com.example.tags.MyTag' } } -``` \ No newline at end of file +``` diff --git a/src/main/groovy/com/github/maiflai/ScalaTestAction.groovy b/src/main/groovy/com/github/maiflai/ScalaTestAction.groovy index b5737b7..2d61845 100644 --- a/src/main/groovy/com/github/maiflai/ScalaTestAction.groovy +++ b/src/main/groovy/com/github/maiflai/ScalaTestAction.groovy @@ -28,6 +28,7 @@ class ScalaTestAction implements Action { static String SUITES = '_suites' static String CONFIG = '_config' static String REPORTERS = '_reporters' + static String SPAN_SCALE_FACTOR = '_spanScaleFactor' @Override void execute(Test t) { @@ -196,6 +197,11 @@ class ScalaTestAction implements Action { args.add('-C') args.add(it) } + def spanScaleFactor = t.extensions.findByName(SPAN_SCALE_FACTOR) as List + spanScaleFactor?.toSet()?.each { + args.add('-F') + args.add(it.toString()) + } assert args.every { it.length() > 0 } return args } diff --git a/src/main/groovy/com/github/maiflai/ScalaTestPlugin.groovy b/src/main/groovy/com/github/maiflai/ScalaTestPlugin.groovy index 5d9902c..c71c6df 100644 --- a/src/main/groovy/com/github/maiflai/ScalaTestPlugin.groovy +++ b/src/main/groovy/com/github/maiflai/ScalaTestPlugin.groovy @@ -75,6 +75,10 @@ class ScalaTestPlugin implements Plugin { test.extensions.add(ScalaTestAction.REPORTERS, reporters) test.extensions.add("reporter", { String name -> reporters.add(name) }) test.extensions.add("reporters", { String... name -> reporters.addAll(name) }) + List spanScaleFactor = [] + test.extensions.add(ScalaTestAction.SPAN_SCALE_FACTOR, spanScaleFactor) + test.extensions.add("spanScaleFactor", { Float factor -> spanScaleFactor.add(factor) }) + test.testLogging.events = TestLogEvent.values() as Set } diff --git a/src/test/groovy/com/github/maiflai/ScalaTestActionTest.groovy b/src/test/groovy/com/github/maiflai/ScalaTestActionTest.groovy index 0e68a1e..a925f0a 100644 --- a/src/test/groovy/com/github/maiflai/ScalaTestActionTest.groovy +++ b/src/test/groovy/com/github/maiflai/ScalaTestActionTest.groovy @@ -315,4 +315,12 @@ class ScalaTestActionTest { def args = commandLine(test) assertThat(args, hasOption('-R', '/serviceuitest-1.1beta4.jar /myjini /target/class\\ files')) } -} \ No newline at end of file + + @Test + void spanScaleFactor() throws Exception { + Task test = testTask() + test.spanScaleFactor 10.5 + def args = commandLine(test) + assertThat(args, hasOption('-F', '10.5')) + } +}