Skip to content

Commit 0240d67

Browse files
groovy runner: remove createWithDelegatingEnabled
1 parent 0eb3d6c commit 0240d67

7 files changed

Lines changed: 14 additions & 20 deletions

File tree

webtau-groovy/src/main/groovy/org/testingisdocumenting/webtau/cfg/GroovyRunner.groovy

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright 2021 webtau maintainers
23
* Copyright 2019 TWO SIGMA OPEN SOURCE, LLC
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,10 +24,6 @@ import java.nio.file.Path
2324
class GroovyRunner {
2425
private static final List<String> staticImports = ["org.testingisdocumenting.webtau.WebTauGroovyDsl"]
2526

26-
static GroovyScriptEngine createWithDelegatingEnabled(Path workingDir) {
27-
return GroovyStandaloneEngine.createWithDelegatingEnabled(workingDir, staticImports)
28-
}
29-
3027
static GroovyScriptEngine createWithoutDelegating(Path workingDir) {
3128
return GroovyStandaloneEngine.createWithoutDelegating(workingDir, staticImports)
3229
}

webtau-groovy/src/main/groovy/org/testingisdocumenting/webtau/cli/WebTauCliApp.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class WebTauCliApp implements TestListener, ReportGenerator {
122122
}
123123

124124
testFiles.forEach {
125-
runner.process(it, this)
125+
runner.process(it)
126126
}
127127

128128
code()
@@ -144,7 +144,7 @@ class WebTauCliApp implements TestListener, ReportGenerator {
144144
registerListenersAndHandlers()
145145

146146
runner = new StandaloneTestRunner(
147-
GroovyRunner.createWithDelegatingEnabled(cfg.workingDir),
147+
GroovyRunner.createWithoutDelegating(cfg.workingDir),
148148
cfg.getWorkingDir())
149149

150150
WebTauGroovyDsl.initWithTestRunner(runner)

webtau-groovy/src/main/groovy/org/testingisdocumenting/webtau/cli/repl/InteractiveTests.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright 2021 webtau maintainers
23
* Copyright 2019 TWO SIGMA OPEN SOURCE, LLC
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,7 +39,7 @@ class InteractiveTests {
3839

3940
List<StandaloneTest> refreshScenarios(String filePath) {
4041
runner.clearRegisteredTests()
41-
runner.process(new TestFile(Paths.get(filePath)), this)
42+
runner.process(new TestFile(Paths.get(filePath)))
4243

4344
def withError = runner.tests.find { it.hasError() }
4445
if (withError) {

webtau-groovy/src/test/groovy/org/testingisdocumenting/webtau/cli/repl/ReplCommandsTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ class ReplCommandsTest implements StepReporter, ConsoleOutput {
5050
void init() {
5151
def workingDir = Paths.get("").toAbsolutePath()
5252
def runner = new StandaloneTestRunner(
53-
GroovyRunner.createWithDelegatingEnabled(workingDir),
53+
GroovyRunner.createWithoutDelegating(workingDir),
5454
workingDir)
5555

5656
WebTauGroovyDsl.initWithTestRunner(runner)
5757

58-
runner.process(new TestFile(Paths.get("src/test/resources/repl/doNothingScenariosOne.groovy")), this)
59-
runner.process(new TestFile(Paths.get("src/test/resources/repl/doNothingScenariosTwo.groovy")), this)
58+
runner.process(new TestFile(Paths.get("src/test/resources/repl/doNothingScenariosOne.groovy")))
59+
runner.process(new TestFile(Paths.get("src/test/resources/repl/doNothingScenariosTwo.groovy")))
6060

6161
repl = new Repl(runner)
6262

webtau-standalone-runner-groovy/src/main/groovy/org/testingisdocumenting/webtau/runner/standalone/GroovyStandaloneEngine.groovy

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright 2021 webtau maintainers
23
* Copyright 2019 TWO SIGMA OPEN SOURCE, LLC
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,10 +23,6 @@ import org.codehaus.groovy.control.customizers.ImportCustomizer
2223
import java.nio.file.Path
2324

2425
class GroovyStandaloneEngine {
25-
static GroovyScriptEngine createWithDelegatingEnabled(Path workingDir, List<String> staticImports) {
26-
return createImpl(workingDir, staticImports, DelegatingScript.class)
27-
}
28-
2926
static GroovyScriptEngine createWithoutDelegating(Path workingDir, List<String> staticImports) {
3027
return createImpl(workingDir, staticImports, null)
3128
}

webtau-standalone-runner-groovy/src/main/groovy/org/testingisdocumenting/webtau/runner/standalone/StandaloneTestRunner.groovy

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class StandaloneTestRunner {
6363
this.isTerminated = new AtomicBoolean(false)
6464
}
6565

66-
void process(TestFile testFile, delegate) {
66+
void process(TestFile testFile) {
6767
Path scriptPath = testFile.path
6868
currentTestPath = scriptPath.isAbsolute() ? scriptPath : workingDir.resolve(scriptPath)
6969
currentTestMetadata.set(new WebTauTestMetadata())
@@ -73,8 +73,6 @@ class StandaloneTestRunner {
7373

7474
def scriptParseTest = new StandaloneTest(workingDir, currentTestPath, currentShortContainerId, "parse/init", { ->
7575
def script = groovy.createScript(relativeToWorkDirPath.toString(), new Binding())
76-
77-
script.setDelegate(delegate)
7876
script.run()
7977
})
8078

webtau-standalone-runner-groovy/src/test/groovy/org/testingisdocumenting/webtau/runner/standalone/StandaloneTestRunnerTest.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class StandaloneTestRunnerTest {
297297

298298
def afterAllTest = runner.webTauTestList.get(3)
299299
afterAllTest.scenario.should == 'after all tests'
300-
afterAllTest.isSynthetic.should == true
300+
afterAllTest.synthetic.should == true
301301
afterAllTest.shortContainerId.should == 'Teardown'
302302
afterAllTest.exception.message.should == 'test error message'
303303
}
@@ -323,11 +323,12 @@ class StandaloneTestRunnerTest {
323323

324324
private static StandaloneTestRunner createRunner(String... scenarioFiles) {
325325
def workingDir = Paths.get("test-scripts")
326-
def runner = new StandaloneTestRunner(GroovyStandaloneEngine.createWithDelegatingEnabled(workingDir,
326+
def runner = new StandaloneTestRunner(
327+
GroovyStandaloneEngine.createWithoutDelegating(workingDir,
327328
["org.testingisdocumenting.webtau.runner.standalone.StandaloneTestRunnerTestStaticImport"]), workingDir)
328329

329330
StandaloneTestRunnerTestStaticImport.runner = runner
330-
scenarioFiles.each { runner.process(new TestFile(Paths.get(it)), this) }
331+
scenarioFiles.each { runner.process(new TestFile(Paths.get(it))) }
331332

332333
return runner
333334
}

0 commit comments

Comments
 (0)