Skip to content

Commit fb25658

Browse files
Add Unit Test support (#16)
1 parent 37a0493 commit fb25658

File tree

11 files changed

+106
-80
lines changed

11 files changed

+106
-80
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.DS_Store
2+
build
3+
*.class

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ image:
66
docker build --rm -t $(IMAGE_NAME) .
77

88
test: image
9-
docker run --rm -v $(PWD):/code $(IMAGE_NAME) /code/test.groovy
9+
docker run --rm --workdir /usr/src/app $(IMAGE_NAME) ./test.sh
1010

1111
upgrade:
1212
docker run --rm \
File renamed without changes.

test/config.bad.json renamed to fixtures/config.bad.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"enabled": true,
33
"channel": "beta",
44
"config": {
5-
"file": "test/invalid_file",
5+
"file": "invalid_file",
66
},
77
"include_paths": [
88
"Main.java"
File renamed without changes.

test/config.new.json renamed to fixtures/config.new.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"enabled": true,
33
"channel": "beta",
44
"config": {
5-
"file": "test/rules.xml",
5+
"file": "fixtures/rules.xml",
66
},
77
"include_paths": [
88
"Main.java"

test/config.old.json renamed to fixtures/config.old.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"enabled": true,
33
"channel": "beta",
4-
"config": "test/rules.xml",
4+
"config": "fixtures/rules.xml",
55
"include_paths": [
66
"Main.java"
77
]
File renamed without changes.

test.groovy

Lines changed: 0 additions & 76 deletions
This file was deleted.

test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env sh
2+
set -ex
3+
4+
BUILD_DIR=build
5+
GROOVY="${GROOVY_HOME}/embeddable/groovy-all-${GROOVY_VERSION}.jar"
6+
JUNIT=$(ls ${GROOVY_HOME}/lib/junit*.jar)
7+
HAMCREST=$(ls ${GROOVY_HOME}/lib/hamcrest*.jar)
8+
9+
test_classes() {
10+
find test -name "*.groovy" | sed -E 's#test/(.*).groovy#\1#' | xargs
11+
}
12+
13+
clean() {
14+
rm -rf $BUILD_DIR
15+
mkdir $BUILD_DIR
16+
}
17+
18+
build() {
19+
groovyc test/**.groovy -d $BUILD_DIR
20+
}
21+
22+
run() {
23+
java -cp build:$JUNIT:$HAMCREST:$GROOVY org.junit.runner.JUnitCore $(test_classes)
24+
}
25+
26+
clean
27+
build
28+
run

0 commit comments

Comments
 (0)