Skip to content

Commit 60bf469

Browse files
authored
Merge pull request exercism#635 from exercism/sync-journey-test-with-xkotlin
journey test: pull in improvements from xkotlin
2 parents dc1ac8c + f6702f9 commit 60bf469

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

bin/journey-test.sh

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env bash
22

3+
# This script is shared between the Java and Kotlin tracks. If you make an update to this script on
4+
# one track, please create a companion PR to merge it in to the other. Thank you!
5+
TRACK=java
6+
TRACK_REPO="x${TRACK}"
7+
TRACK_SRC_EXT="java"
8+
39
on_exit() {
410
echo ">>> on_exit()"
511
if [[ "$xapi_pid" != "" ]] ; then
@@ -16,7 +22,7 @@ assert_installed() {
1622

1723
if [[ "`which $binary`" == "" ]]; then
1824
echo "${binary} not found; it is required to perform this test."
19-
echo -e "Have you completed the setup instructions at https://github.com/exercism/xjava ?\n"
25+
echo -e "Have you completed the setup instructions at https://github.com/exercism/${TRACK_REPO} ?\n"
2026
echo "PATH=${PATH}"
2127
echo "aborting."
2228
exit 1
@@ -35,7 +41,7 @@ assert_ruby_installed() {
3541
if [[ "${expected_ruby_ver}" != "" && "${current_ruby_ver}" != "${expected_ruby_ver}" ]]; then
3642
echo "${ruby_app_home} requires Ruby ${expected_ruby_ver}; current Ruby version is ${current_ruby_ver}."
3743
echo -e "Ruby used: `which ruby`.\n"
38-
echo -e "Have you completed the setup instructions at https://github.com/exercism/xjava ?\n"
44+
echo -e "Have you completed the setup instructions at https://github.com/exercism/${TRACK_REPO} ?\n"
3945
echo "PATH=${PATH}"
4046
echo "aborting."
4147
exit 1
@@ -141,7 +147,7 @@ make_local_trackler() {
141147
local xapi_home="$2"
142148
echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
143149

144-
local xjava=$( pwd )
150+
local track_root=$( pwd )
145151
pushd ${trackler}
146152

147153
# Get the version of Trackler x-api is currently using
@@ -151,11 +157,11 @@ make_local_trackler() {
151157
git submodule init -- common
152158
git submodule update
153159

154-
# Bake in local copy of xjava; this is what we are testing.
155-
rmdir tracks/java
156-
mkdir -p tracks/java/exercises
157-
cp ${xjava}/config.json tracks/java
158-
cp -r ${xjava}/exercises tracks/java
160+
# Bake in local copy of this track; this is what we are testing.
161+
rmdir tracks/${TRACK}
162+
mkdir -p tracks/${TRACK}/exercises
163+
cp ${track_root}/config.json tracks/${TRACK}
164+
cp -r ${track_root}/exercises tracks/${TRACK}
159165

160166
gem install bundler
161167
bundle install
@@ -208,7 +214,7 @@ solve_all_exercises() {
208214
local exercism_configfile="$2"
209215
echo ">>> solve_all_exercises(exercism_exercises_dir=\"${exercism_exercises_dir}\", exercism_configfile=\"${exercism_configfile}\")"
210216

211-
local xjava=$( pwd )
217+
local track_root=$( pwd )
212218
local exercism_cli="./exercism --config ${exercism_configfile}"
213219
local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
214220
local total_exercises=`cat config.json | jq '.exercises | length'`
@@ -222,15 +228,15 @@ solve_all_exercises() {
222228
echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
223229
echo "=================================================="
224230

225-
${exercism_cli} fetch java $exercise
226-
cp -R -H ${xjava}/exercises/${exercise}/src/example/java/* ${exercism_exercises_dir}/java/${exercise}/src/main/java/
231+
${exercism_cli} fetch ${TRACK} $exercise
232+
cp -R -H ${track_root}/exercises/${exercise}/src/example/${TRACK}/* ${exercism_exercises_dir}/${TRACK}/${exercise}/src/main/${TRACK}/
227233

228-
pushd ${exercism_exercises_dir}/java/${exercise}
234+
pushd ${exercism_exercises_dir}/${TRACK}/${exercise}
229235
# Check that tests compile before we strip @Ignore annotations
230236
"$EXECPATH"/gradlew compileTestJava
231237
# Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
232-
for testfile in `find . -name "*Test.java"`; do
233-
sed 's/@Ignore\(.*\)//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
238+
for testfile in `find . -name "*Test.${TRACK_SRC_EXT}"`; do
239+
sed 's/@Ignore\(\(.*\)\)\{0,1\}//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
234240
done
235241
"$EXECPATH"/gradlew test
236242
popd
@@ -244,9 +250,9 @@ main() {
244250
# all functions assume current working directory is repository root.
245251
cd "${SCRIPTPATH}/.."
246252

247-
local xjava=$( pwd )
253+
local track_root=$( pwd )
248254
local build_dir="build"
249-
local build_path="${xjava}/${build_dir}"
255+
local build_path="${track_root}/${build_dir}"
250256

251257
local xapi_home="${build_path}/x-api"
252258
local trackler_home="${build_path}/trackler"
@@ -260,7 +266,7 @@ main() {
260266

261267
clean "${build_dir}"
262268

263-
# Make a version of trackler that includes the source from this repo.
269+
# Make a local version of trackler that includes the source from this repo.
264270
git_clone "x-api" "${xapi_home}"
265271
git_clone "trackler" "${trackler_home}"
266272
assert_ruby_installed "${trackler_home}"

0 commit comments

Comments
 (0)