-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from grails/add-jvm-version-info
Add JVM version info to Grails CLI
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
grails-cli/src/test/groovy/org/grails/forge/cli/command/ApplicationCommandSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.grails.forge.cli.command | ||
|
||
import io.micronaut.configuration.picocli.PicocliRunner | ||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.context.env.Environment | ||
import org.grails.forge.cli.Application | ||
import org.grails.forge.cli.CommandFixture | ||
import org.grails.forge.cli.CommandSpec | ||
import org.grails.forge.util.VersionInfo | ||
import spock.lang.AutoCleanup | ||
import spock.lang.Shared | ||
|
||
class ApplicationCommandSpec extends CommandSpec implements CommandFixture { | ||
|
||
@Shared | ||
@AutoCleanup | ||
ApplicationContext ctx = ApplicationContext.run(Environment.CLI) | ||
|
||
@Shared | ||
@AutoCleanup | ||
ApplicationContext beanContext = ApplicationContext.run() | ||
|
||
void "print version info via: grails #args"() { | ||
given: | ||
ByteArrayOutputStream out = new ByteArrayOutputStream() | ||
System.setOut(new PrintStream(out)) | ||
|
||
when: | ||
PicocliRunner.run(Application, ctx, args) | ||
|
||
then: | ||
noExceptionThrown() | ||
out.toString().contains("Grails Version: " + VersionInfo.getGrailsVersion()) | ||
out.toString().contains("JVM Version: " + System.getProperty("java.version")) | ||
|
||
where: | ||
args | _ | ||
"--version" | _ | ||
"-V" | _ | ||
} | ||
} |