-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more granularity to JAVA_HOME
checks
#104
Changes from 4 commits
444e130
ba70a09
f99a7b6
1fec7aa
ac6caf8
4dd03f3
c816bc4
0a81d33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,8 +113,10 @@ class PluginIntegrationTest constructor(private val version: String) { | |
| id "com.osacky.doctor" | ||
|} | ||
|doctor { | ||
| disallowMultipleDaemons = false | ||
| ensureJavaHomeMatches = true | ||
| javaHome { | ||
| disallowMultipleDaemons = false | ||
| ensureJavaHomeMatches = true | ||
| } | ||
|} | ||
""".trimMargin("|") | ||
) | ||
|
@@ -134,6 +136,70 @@ class PluginIntegrationTest constructor(private val version: String) { | |
) | ||
} | ||
|
||
// This is failing, perhaps because it is actually trying to use "foo" as JAVA_HOME. | ||
@Test @Ignore | ||
fun testJavaHomeNotSetWithConsoleError() { | ||
assumeSupportedVersion() | ||
|
||
writeBuildGradle( | ||
""" | ||
|plugins { | ||
| id "com.osacky.doctor" | ||
|} | ||
|doctor { | ||
| javaHome { | ||
| disallowMultipleDaemons = false | ||
| ensureJavaHomeMatches = true | ||
| failOnError = false | ||
| } | ||
|} | ||
""".trimMargin("|") | ||
) | ||
testProjectRoot.newFile("settings.gradle") | ||
|
||
val result = createRunner() | ||
.withEnvironment(mapOf("JAVA_HOME" to "foo")) | ||
.withArguments("tasks") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea, I was just copying the previous test (which is also ignored) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was leaving these as a toe-hold |
||
.buildAndFail() | ||
// Still prints the error | ||
assertThat(result.output).contains( | ||
""" | ||
|> =============================== Gradle Doctor Prescriptions ============================================ | ||
| | Gradle is not using JAVA_HOME. | | ||
| | JAVA_HOME is foo | | ||
| """ | ||
.trimMargin("|") | ||
) | ||
} | ||
|
||
// This is failing, perhaps because it is actually trying to use "foo" as JAVA_HOME. | ||
@Test @Ignore | ||
fun testJavaHomeNotSetWithCustomMessage() { | ||
assumeSupportedVersion() | ||
|
||
writeBuildGradle( | ||
""" | ||
|plugins { | ||
| id "com.osacky.doctor" | ||
|} | ||
|doctor { | ||
| javaHome { | ||
| disallowMultipleDaemons = false | ||
| ensureJavaHomeMatches = true | ||
| extraMessage = "Check for more details here!" | ||
| } | ||
|} | ||
""".trimMargin("|") | ||
) | ||
testProjectRoot.newFile("settings.gradle") | ||
|
||
val result = createRunner() | ||
.withEnvironment(mapOf("JAVA_HOME" to "foo")) | ||
.withArguments("tasks") | ||
.buildAndFail() | ||
assertThat(result.output).contains("Check for more details here!") | ||
} | ||
|
||
@Test | ||
fun testFailAssembleMultipleProjects() { | ||
assumeSupportedVersion() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have my own silly API design here that we'll need to follow in order to get a consistent printout of all the error messages together. A build can generate multiple warnings or errors so they are grouped using this API.
To get a consistent printout and so that all the errors are printed together at the end of the build we'll need to do something like this:
That being said, you might need to add a new class to
Finish
where you can pass a list of messages.Here's an example from DownloadSpeedMeasurer: https://github.com/runningcode/gradle-doctor/blob/master/doctor-plugin/src/main/java/com/osacky/doctor/DownloadSpeedMeasurer.kt#L50