Skip to content

Commit 5e9f286

Browse files
author
Alan Christie
committed
- Adds -stoponerror option
Stops on first error
1 parent 933d11c commit 5e9f286

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/groovy/Log.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static separate() {
3939
* Print an 'info' message prefixed with `->` string. You can specify a
4040
* tag and a message which is printed as "-> <tag> : <msg>"
4141
*/
42-
static info(String tag, String msg) {
42+
static info(String tag, msg) {
4343

4444
println ":" + sprintf('%16s: %s', tag, msg)
4545

src/groovy/PipelineTester.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def cli = new CliBuilder(usage:'groovy PipelineTester.groovy',
4343
stopAtNonOption:false)
4444
cli.v(longOpt: 'verbose', "Display the pipeline's log")
4545
cli.d(longOpt: 'indocker', "Run tests using their container images")
46+
cli.s(longOpt: 'stoponerror', "Stop executing on the first test failure")
4647
cli.h(longOpt: 'help', "Print this message")
4748
def options = cli.parse(args)
4849
if (!options) {
@@ -56,7 +57,8 @@ if (options.help) {
5657
// Create a Tester object
5758
// and run all the tests that have been discovered...
5859
Tester pipelineTester = new Tester(verbose:options.v,
59-
inDocker:options.d)
60+
inDocker:options.d,
61+
stopOnError:options.s)
6062
boolean testResult = pipelineTester.run()
6163

6264
// Leave with a non-zero exit code on failure...

src/groovy/Tester.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Tester {
3434
// Controlled by command-line
3535
boolean verbose = false
3636
boolean inDocker = true
37+
boolean stopOnError = false
3738

3839
// Constants?
3940
int defaultTimeoutSeconds = 60
@@ -110,6 +111,7 @@ class Tester {
110111

111112
// Log supported test file versions
112113
Log.info('Setup', "Supporting test file versions: $supportedTestFileVersions")
114+
Log.info('Stop on error', stopOnError)
113115

114116
// Before we start - cleanup (everything)
115117
cleanUpOutput()
@@ -194,8 +196,20 @@ class Tester {
194196
recordFailedTest(section_key_lower)
195197
}
196198

199+
if (stopOnError && failedTests.size() > 0) {
200+
break
201+
}
202+
197203
}
198204

205+
if (stopOnError && failedTests.size() > 0) {
206+
break
207+
}
208+
209+
}
210+
211+
if (stopOnError && failedTests.size() > 0) {
212+
break
199213
}
200214

201215
}

0 commit comments

Comments
 (0)