Skip to content

Commit

Permalink
compiler: Support up-to-date checking in golden tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ejona86 committed Feb 26, 2024
1 parent 5f8958f commit 89d8a13
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,20 @@ publishing {
}

def configureTestTask(Task task, String dep, String serviceName) {
def genDir = files(tasks.named("generateTest${dep}Proto")).singleFile
def genFile = "${genDir}/grpc/io/grpc/testing/compiler/${serviceName}Grpc.java"
task.dependsOn "generateTest${dep}Proto"
task.inputs.file genFile
if (osdetector.os != 'windows') {
task.executable "diff"
task.args "-u"
} else {
task.executable "fc"
}
// File isn't found on Windows if last slash is forward-slash
def slash = System.getProperty("file.separator")
task.args "$buildDir/generated/source/proto/test${dep}/grpc/io/grpc/testing/compiler${slash}${serviceName}Grpc.java",
"$projectDir/src/test${dep}/golden/${serviceName}.java.txt"
task.args layout.projectDirectory.file("src/test${dep}/golden/${serviceName}.java.txt")
task.args genFile
// Register an output to allow up-to-date checking
task.outputs.file(layout.buildDirectory.file(task.name))
}

def testGolden = tasks.register("testGolden", Exec) {
Expand Down

0 comments on commit 89d8a13

Please sign in to comment.