Skip to content

Commit

Permalink
Merge pull request #92 from Yelp/run-precommit-on-travis
Browse files Browse the repository at this point in the history
Update make test to run pre-commit hooks on the whole codebase
  • Loading branch information
cortinico committed Feb 4, 2020
2 parents 80e2315 + aeb2192 commit 71e73af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: install-hooks regenerate-samples test
.PHONY: install-hooks regenerate-samples test run-hooks

.git/hooks/pre-commit: venv
${CURDIR}/venv/bin/pre-commit install --install-hooks
Expand All @@ -11,7 +11,10 @@ regenerate-samples:
${CURDIR}/gradlew plugin:publishToMavenLocal
${CURDIR}/gradlew generateSwagger

test:
run-hooks: venv
${CURDIR}/venv/bin/pre-commit run --all-files

test: run-hooks
${CURDIR}/gradlew plugin:build
${CURDIR}/gradlew plugin:publishToMavenLocal
${CURDIR}/gradlew generateSwagger
Expand Down
30 changes: 14 additions & 16 deletions plugin/src/test/java/com/yelp/plugin/PluginTests.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package com.yelp.plugin

import org.gradle.testkit.runner.BuildResult
import java.io.File
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Assert
import org.junit.Test
import java.io.File


class PluginTests {
@Test
fun basicPluginTest() {
val tmpDir = File(".", "build/testProject")
tmpDir.deleteRecursively()
@Test
fun basicPluginTest() {
val tmpDir = File(".", "build/testProject")
tmpDir.deleteRecursively()

println(File(".").absolutePath)
File(".", "src/test/testProject").copyRecursively(tmpDir)
println(File(".").absolutePath)
File(".", "src/test/testProject").copyRecursively(tmpDir)

val result = GradleRunner.create().withProjectDir(tmpDir)
.forwardStdOutput(System.out.writer())
.forwardStdError(System.err.writer())
.withArguments("generateSwagger")
.build()
val result = GradleRunner.create().withProjectDir(tmpDir)
.forwardStdOutput(System.out.writer())
.forwardStdError(System.err.writer())
.withArguments("generateSwagger")
.build()

Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateSwagger")?.outcome)
}
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateSwagger")?.outcome)
}
}

0 comments on commit 71e73af

Please sign in to comment.