Skip to content

Commit 4a4c805

Browse files
committed
Avoid null dereference when testing an already-built QEMU PR
1 parent ca83468 commit 4a4c805

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

test/CheckCheribuildProjects.groovy

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CheckCheribuildProjects extends BaseRegressionTest {
2424
@Test
2525
void qemu_test() throws Exception {
2626
// def script = loadScript("test-scripts/qemu.groovy")
27-
// script.run()
27+
// script.run()[
2828
// printCallStack()
2929
CommonTestHelper.addEnvVars(this, ["JOB_NAME": "QEMU/qemu-cheri"])
3030
def script = runScript("test-scripts/qemu.groovy")
@@ -33,6 +33,32 @@ class CheckCheribuildProjects extends BaseRegressionTest {
3333
assertJobStatusUnstable()
3434
}
3535

36+
@Test
37+
void qemu_pr_test_run() throws Exception {
38+
CommonTestHelper.addEnvVars(this, ["JOB_NAME": "QEMU/qemu-cheri", "CHANGE_ID": "12"])
39+
binding.setVariable('pullRequest', [
40+
labels : [],
41+
commits: [[sha: "12345abc", statuses: []]]
42+
])
43+
// Normal run should work
44+
runScript("test-scripts/qemu.groovy")
45+
printCallStack()
46+
assertJobStatusUnstable()
47+
}
48+
49+
@Test
50+
void qemu_pr_test_skipped() throws Exception {
51+
// Regression test for a null dereference when skipping PR builds
52+
CommonTestHelper.addEnvVars(this, ["JOB_NAME": "QEMU/qemu-cheri", "CHANGE_ID": "12"])
53+
binding.setVariable('pullRequest', [
54+
labels : ['NO-JENKINS'],
55+
commits: [[sha: "12345abc", statuses: []]]
56+
])
57+
runScript("test-scripts/qemu.groovy")
58+
printCallStack()
59+
assertJobStatusSuccess()
60+
}
61+
3662
@Test
3763
void llvm_test() throws Exception {
3864
CommonTestHelper.addEnvVars(this, [JOB_NAME : "CLANG-LLVM-linux/dev",

vars/cheribuildProject.groovy

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,10 @@ def call(Map args) {
741741
}
742742
def tasks = [:]
743743
boolean shouldBuild = false
744-
def skippedBuildTask = { -> echo "Not building this pull request." }
744+
def skippedBuildTask = { params ->
745+
echo "Not building this pull request."
746+
return params
747+
}
745748
taskArgs.each { key, val ->
746749
def params = parseParams(val)
747750
if (env.CHANGE_ID && !shouldBuildPullRequest(context: params.gitHubStatusContext)) {
@@ -752,7 +755,7 @@ def call(Map args) {
752755
tasks[key] = { -> return runCheribuild(params) }
753756
}
754757
if (!shouldBuild) {
755-
return skippedBuildTask()
758+
return skippedBuildTask([:])
756759
}
757760
if (singleArch) {
758761
assert tasks.size() == 1

0 commit comments

Comments
 (0)