Skip to content

Commit 964e71f

Browse files
committed
Hook gtest to the test command
1 parent 7918ebb commit 964e71f

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

ddprof-lib/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def createDebugLinkTask(config, linkTask, extractDebugTask) {
112112
}
113113
dependsOn extractDebugTask
114114
description = 'Add debug link to the original library'
115-
115+
116116
inputs.files linkTask, extractDebugTask
117117
outputs.file { linkTask.get().linkedFile.get().asFile }
118118

@@ -362,7 +362,7 @@ def patchStackFrame = tasks.register("patchStackFrame") {
362362
}
363363
inputs.files copyUpstreamFiles
364364
outputs.file("${projectDir}/src/main/cpp-external/stackFrame_x64.cpp")
365-
365+
366366
doLast {
367367
def file = file("${projectDir}/src/main/cpp-external/stackFrame_x64.cpp")
368368
if (!file.exists()) throw new GradleException("File not found: ${file}")
@@ -417,7 +417,7 @@ def patchStackWalker = tasks.register("patchStackWalker") {
417417
}
418418
inputs.files copyUpstreamFiles
419419
outputs.file("${projectDir}/src/main/cpp-external/stackWalker.cpp")
420-
420+
421421
doLast {
422422
def file = file("${projectDir}/src/main/cpp-external/stackWalker.cpp")
423423
if (!file.exists()) throw new GradleException("File not found: ${file}")

ddprof-lib/gtest/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ tasks.whenTaskAdded { task ->
199199
}
200200

201201
inputs.files binary
202-
outputs.upToDateWhen {true}
202+
// Test tasks should run every time the test command is run
203+
outputs.upToDateWhen { false }
203204
}
204205

205206
def compileTask = tasks.findByName("compileGtest${config.name.capitalize()}_${testName}")

ddprof-test/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,11 @@ gradle.projectsEvaluated {
120120
if (testTask && assembleTask) {
121121
assembleTask.dependsOn testTask
122122
}
123+
124+
// Hook C++ gtest tasks to run as part of the corresponding Java test tasks
125+
def gtestTask = project(':ddprof-lib:gtest').tasks.findByName("gtest${it.capitalize()}")
126+
if (testTask && gtestTask) {
127+
testTask.dependsOn gtestTask
128+
}
123129
}
124130
}

0 commit comments

Comments
 (0)