-
Notifications
You must be signed in to change notification settings - Fork 9
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 #44 from caarlos0/new
clitest and bugfixes
- Loading branch information
Showing
8 changed files
with
158 additions
and
59 deletions.
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
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
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.jvm</groupId> | ||
<artifactId>jdk8</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../java8</relativePath> | ||
</parent> | ||
<groupId>com.jvm</groupId> | ||
<artifactId>empty</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
</project> |
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
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
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
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,115 @@ | ||
# jvm test suite | ||
|
||
This is the self-document test suite for JVM. | ||
|
||
# Initial setup | ||
|
||
Just cleanup, variable setting and source what needs to be sourced. | ||
|
||
```console | ||
$ ROOT="$(pwd)" | ||
$ TESTS="tests" | ||
$ find . -name '.java-version' -delete | ||
$ source jvm.sh | ||
$ export MAVEN_OPTS="" | ||
$ | ||
``` | ||
|
||
# jvm global | ||
|
||
Test setting a global version. | ||
|
||
```console | ||
$ jvm global 7 | ||
$ jvm version | ||
7 | ||
$ | ||
``` | ||
|
||
# jvm local | ||
|
||
Test setting a version to the current folder. | ||
|
||
```console | ||
$ jvm local 7 | ||
$ jvm version | ||
7 | ||
$ | ||
``` | ||
|
||
# maven.compiler.source | ||
|
||
Test a pom with a `maven.compiler.source` property set to Java 8. | ||
|
||
```console | ||
$ cd "$ROOT/$TESTS/java8" | ||
$ jvm reload | ||
$ jvm version | ||
8 | ||
$ | ||
``` | ||
|
||
# java.version | ||
|
||
Test a pom with a `java.version` property set to Java 7. | ||
|
||
```console | ||
$ cd "$ROOT/$TESTS/java7" | ||
$ jvm reload | ||
$ jvm version | ||
7 | ||
$ | ||
``` | ||
|
||
# maven-compiler-plugin | ||
|
||
Test reading the `source` tag from `maven-compiler-plugin`, which in this | ||
example is set to Java 7. | ||
|
||
```console | ||
$ cd "$ROOT/$TESTS/grep" | ||
$ jvm reload | ||
$ jvm version | ||
7 | ||
$ | ||
``` | ||
|
||
# parent pom | ||
|
||
Test a pom with no java config at all, the config is at its parent pom, | ||
therefore, this will run `mvn help:evaluate` and find out that the parent | ||
is using Java 8. | ||
|
||
```console | ||
$ cd "$ROOT/$TESTS/empty" | ||
$ jvm reload | ||
$ jvm version | ||
8 | ||
$ | ||
``` | ||
|
||
# jvmconfig | ||
|
||
Test that `jvm` respects a custom java version in `~/.jvmconfig`, in this case, | ||
pointing out Java 6 to use Java 7 home. | ||
|
||
```console | ||
$ cd "$ROOT/$TESTS/grep" | ||
$ rm .java-version | ||
$ echo "6=$(__jvm_javahome 7)" > ~/.jvmconfig | ||
$ jvm local 6 | ||
$ jvm reload | ||
$ jvm version | ||
6 | ||
$ | ||
``` | ||
|
||
# Cleanup | ||
|
||
Remove unneeded files after all tests ran. | ||
|
||
```console | ||
$ cd "$ROOT" | ||
$ find . -name '.java-version' -delete | ||
$ | ||
``` |
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 |
---|---|---|
@@ -1,49 +1,3 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
ROOT="$(pwd)" | ||
TESTS="$(dirname "${BASH_SOURCE[0]}")" | ||
|
||
assert_java() { | ||
version="$1" | ||
test "$(jvm version)" = "$version" || exit 1 | ||
} | ||
|
||
test_pom7() { | ||
cd "$ROOT/$TESTS"/java7 | ||
jvm reload | ||
assert_java 7 | ||
} | ||
|
||
test_pom7_grep() { | ||
cd "$ROOT/$TESTS"/grep | ||
jvm reload | ||
assert_java 7 | ||
} | ||
|
||
test_pom8() { | ||
cd "$ROOT/$TESTS"/java8 | ||
jvm reload | ||
assert_java 8 | ||
} | ||
|
||
find . -name '.java-version' -delete | ||
|
||
# shellcheck disable=SC1091 | ||
source jvm.sh | ||
|
||
echo "jvm global 8" | ||
jvm global 8 | ||
assert_java 8 | ||
|
||
echo "jvm local 7" | ||
jvm local 7 | ||
assert_java 7 | ||
|
||
echo "cdwd java 8 pom" | ||
test_pom8 | ||
|
||
echo "cdwd java 7 pom" | ||
test_pom7 | ||
|
||
echo "cdwd java 7 grep" | ||
test_pom7_grep | ||
curl -s https://raw.githubusercontent.com/aureliojargas/clitest/master/clitest | | ||
bash -s -- ./tests/test.clitest.md |