1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-16 05:16:08 +02:00

Handle shell calls in base class.

This commit is contained in:
Marcus Holl 2017-11-14 11:08:42 +01:00
parent 111a8e8222
commit 2c53ade200
3 changed files with 6 additions and 8 deletions

View File

@ -16,7 +16,6 @@ public class MTABuildTest extends PiperTestBase {
@Rule
public TemporaryFolder tmp = new TemporaryFolder()
def shellCalls = []
def currentDir
def otherDir
def pipeline
@ -30,7 +29,6 @@ public class MTABuildTest extends PiperTestBase {
otherDir = tmp.newFolder().toURI().getPath()[0..-2] //omit final '/'
pipeline = "${tmp.newFolder("pipeline").toURI().getPath()}pipeline"
helper.registerAllowedMethod('sh', [String], {s -> shellCalls.add(s)} )
helper.registerAllowedMethod('readYaml', [Map], {
m ->
return new Yaml().load((m.file as File).text)

View File

@ -20,8 +20,6 @@ class NeoDeploymentTest extends PiperTestBase {
def script
def shellCalls = []
def pipeline
def archivePath
@ -33,9 +31,6 @@ class NeoDeploymentTest extends PiperTestBase {
archivePath = "${tmp.newFolder("workspace").toURI().getPath()}archiveName.mtar"
pipeline = "${tmp.newFolder("pipeline").toURI().getPath()}pipeline"
helper.registerAllowedMethod('sh', [String], { GString s ->
shellCalls.add(s.replaceAll(/\s+/, " ").trim())
})
helper.registerAllowedMethod('error', [String], { s -> throw new AbortException(s) })
helper.registerAllowedMethod('usernamePassword', [Map], { m -> return m })
helper.registerAllowedMethod('withCredentials', [List, Closure], { l, c ->

View File

@ -5,17 +5,22 @@ import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
public class PiperTestBase extends BasePipelineTest {
protected messages = []
protected messages = [], shellCalls = []
protected final void _setUp() {
super.setUp()
messages.clear()
shellCalls.clear()
preparePiperLib()
helper.registerAllowedMethod('echo', [String], {s -> messages.add(s)} )
helper.registerAllowedMethod('sh', [String], { s ->
shellCalls.add(s.replaceAll(/\s+/, " ").trim())
})
}
private preparePiperLib() {