forked from opensearch-project/opensearch-build-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestRunGradleCheck.groovy
81 lines (67 loc) · 2.41 KB
/
TestRunGradleCheck.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.hamcrest.CoreMatchers.containsString
import static org.hamcrest.CoreMatchers.hasItem
import static org.hamcrest.MatcherAssert.assertThat
class TestRunGradleCheck extends BuildPipelineTest {
@Before
void setUp() {
this.registerLibTester(new RunGradleCheckLibTester(
'https://github.com/opensearch-project/OpenSearch',
'main',
'false'
)
)
super.setUp()
}
@Test
void testRunGradleCheck() {
super.testPipeline("tests/jenkins/jobs/RunGradleCheck_Jenkinsfile")
}
@Test
void testNoAlignParamInGradleCommand() {
runScript("tests/jenkins/jobs/RunGradleCheck_Jenkinsfile")
def gradleCommands = getCommandExecutions('sh', 'gradle').findAll {
shCommand -> shCommand.contains('gradle')
}
assertThat(gradleCommands, hasItem(containsString("./gradlew clean && ./gradlew check -Dtests.coverage=true --no-daemon --no-scan || GRADLE_CHECK_STATUS=1")
))
}
@Test
void testRunGradleCheckBwcAlign() {
super.testPipeline("tests/jenkins/jobs/RunGradleCheckBwcAlign_Jenkinsfile")
}
@Test
void testAlignParamInGradleCommand() {
runScript("tests/jenkins/jobs/RunGradleCheckBwcAlign_Jenkinsfile")
def gradleCommands = getCommandExecutions('sh', 'gradle').findAll {
shCommand -> shCommand.contains('gradle')
}
assertThat(gradleCommands, hasItem(containsString("./gradlew clean && ./gradlew check -Dtests.coverage=true -Dbwc.checkout.align=true --no-daemon --no-scan || GRADLE_CHECK_STATUS=1")
))
}
def getCommandExecutions(methodName, command) {
def shCommands = helper.callStack.findAll {
call ->
call.methodName == methodName
}.
collect {
call ->
callArgsToString(call)
}.findAll {
shCommand ->
shCommand.contains(command)
}
return shCommands
}
}