Skip to content

Commit 65dc93b

Browse files
authored
Merge pull request #40 from artamonovkirill/chore/groovy-4
Update test runner to Groovy 4
2 parents fc45b7c + 7dd6d8f commit 65dc93b

File tree

10 files changed

+83
-22
lines changed

10 files changed

+83
-22
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ tests/**/.gradle/
55
tests/**/*.groovy.original
66
target/
77
jansi-tmp/
8+
tmp

bin/run-in-docker.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ output_dir="${3%/}"
3131
mkdir -p "${output_dir}"
3232

3333
# Build the Docker image
34-
docker build --rm -t exercism/groovy-test-runner .
34+
if [[ "${BUILD_IMAGE:-true}" == "true" ]]; then
35+
docker build --rm -t exercism/groovy-test-runner .
36+
fi
3537

3638
# Run the Docker image using the settings mimicking the production environment
3739
docker run \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Synopsis:
6+
# Test the test runner Docker image by running it against all reference solutions from the Groovy repository.
7+
# It is recommended to run this script when upgrading Groovy exercises or Groovy test runner dependencies.
8+
9+
# Output:
10+
# Fails is
11+
12+
# Example:
13+
# ./bin/run-reference-solution-tests-in-docker.sh
14+
15+
# Build the Docker image
16+
docker build --rm -t exercism/groovy-test-runner .
17+
export BUILD_IMAGE=false
18+
19+
# Assumes exercism/groovy repository is checked out next to the exercism/groovy-test-runner repository.
20+
# If the repository is checked out elsewhere, provide the path as the first argument.
21+
groovy_repo_path=$(realpath "${1:-${PWD}/../groovy}")
22+
repo_root=$(git rev-parse --show-toplevel)
23+
24+
tmp_dir="$(mktemp -d)"
25+
echo "Using temporary directory: ${tmp_dir}"
26+
27+
cleanup() {
28+
rm -rf "${tmp_dir}"
29+
}
30+
31+
trap cleanup EXIT
32+
33+
failures=()
34+
35+
# Iterate over all exercises directories
36+
for exercise_dir in "${groovy_repo_path}"/exercises/practice/*; do
37+
exercise_slug="${exercise_dir##*/}"
38+
exercise_tmp_dir="${tmp_dir}/${exercise_slug}"
39+
mkdir -p "${exercise_tmp_dir}"
40+
cp -R "${exercise_dir}/" "${exercise_tmp_dir}"
41+
cp -R "${exercise_dir}/.meta/src/reference/" "${exercise_tmp_dir}/src/main"
42+
"${repo_root}/bin/run-in-docker.sh" "${exercise_slug}" "${exercise_tmp_dir}" "${exercise_tmp_dir}/output"
43+
results_json="${exercise_tmp_dir}/output/results.json"
44+
status=$(jq -r ".status" "${results_json}")
45+
if [[ "${status}" != "pass" ]]; then
46+
echo "💥 Test failed for ${exercise_slug}:"
47+
jq . "${results_json}"
48+
failures+=("${exercise_slug}")
49+
fi
50+
done
51+
52+
if (( "${#failures[@]}" != 0 )); then
53+
echo "💥 The following exercises failed: ${failures[*]}"
54+
echo "Check above for details"
55+
exit 1
56+
fi
57+
58+
echo "✅ All tests passed"

build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ repositories {
55
}
66

77
dependencies {
8-
implementation "org.spockframework:spock-core:2.0-M2-groovy-3.0"
9-
implementation "org.codehaus.groovy:groovy-all:3.0.2"
10-
}
8+
implementation "org.spockframework:spock-core:2.3-groovy-4.0"
9+
implementation "org.apache.groovy:groovy:4.0.24"
10+
}

pom.xml

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
14-
<groovy.version>3.0.8</groovy.version>
14+
<groovy.version>4.0.24</groovy.version>
15+
<spock.version>2.3-groovy-4.0</spock.version>
1516
<maven.compiler.source>11</maven.compiler.source>
1617
<maven.compiler.target>11</maven.compiler.target>
1718
</properties>
@@ -20,14 +21,13 @@
2021
<dependency>
2122
<groupId>org.spockframework</groupId>
2223
<artifactId>spock-core</artifactId>
23-
<version>2.0-groovy-3.0</version>
24+
<version>${spock.version}</version>
2425
<scope>test</scope>
2526
</dependency>
2627
<dependency>
27-
<groupId>org.codehaus.groovy</groupId>
28-
<artifactId>groovy-all</artifactId>
29-
<version>3.0.8</version>
30-
<type>pom</type>
28+
<groupId>org.apache.groovy</groupId>
29+
<artifactId>groovy</artifactId>
30+
<version>${groovy.version}</version>
3131
</dependency>
3232
</dependencies>
3333

@@ -91,7 +91,7 @@
9191
visit https://github.com/groovy/GMavenPlus/wiki -->
9292
<groupId>org.codehaus.gmavenplus</groupId>
9393
<artifactId>gmavenplus-plugin</artifactId>
94-
<version>1.13.0</version>
94+
<version>4.0.1</version>
9595
<executions>
9696
<execution>
9797
<goals>

tests/example-all-fail/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ repositories {
55
}
66

77
dependencies {
8-
testImplementation "org.spockframework:spock-core:2.0-M2-groovy-3.0"
9-
implementation "org.codehaus.groovy:groovy-all:3.0.2"
8+
testImplementation "org.spockframework:spock-core:2.3-groovy-4.0"
9+
implementation "org.apache.groovy:groovy:4.0.24"
1010
}
1111

1212
test {

tests/example-empty-file/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ repositories {
55
}
66

77
dependencies {
8-
testImplementation "org.spockframework:spock-core:2.0-M2-groovy-3.0"
9-
implementation "org.codehaus.groovy:groovy-all:3.0.2"
8+
testImplementation "org.spockframework:spock-core:2.3-groovy-4.0"
9+
implementation "org.apache.groovy:groovy:4.0.24"
1010
}
1111

1212
test {

tests/example-partial-fail/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ repositories {
55
}
66

77
dependencies {
8-
testImplementation "org.spockframework:spock-core:2.0-M2-groovy-3.0"
9-
implementation "org.codehaus.groovy:groovy-all:3.0.2"
8+
testImplementation "org.spockframework:spock-core:2.3-groovy-4.0"
9+
implementation "org.apache.groovy:groovy:4.0.24"
1010
}
1111

1212
test {

tests/example-success/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ repositories {
55
}
66

77
dependencies {
8-
implementation "org.spockframework:spock-core:2.0-M2-groovy-3.0"
9-
implementation "org.codehaus.groovy:groovy-all:3.0.2"
10-
}
8+
implementation "org.spockframework:spock-core:2.3-groovy-4.0"
9+
implementation "org.apache.groovy:groovy:4.0.24"
10+
}

tests/example-syntax-error/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ repositories {
55
}
66

77
dependencies {
8-
testImplementation "org.spockframework:spock-core:2.0-M2-groovy-3.0"
9-
implementation "org.codehaus.groovy:groovy-all:3.0.2"
8+
testImplementation "org.spockframework:spock-core:2.3-groovy-4.0"
9+
implementation "org.codehaus.groovy:groovy:4.0.24"
1010
}
1111

1212
test {

0 commit comments

Comments
 (0)