Просмотр исходного кода

Merge pull request #635 from exercism/sync-journey-test-with-xkotlin

journey test: pull in improvements from xkotlin
Stuart Kent 9 лет назад
Родитель
Сommit
60bf4696e7
1 измененных файлов: 23 добавлений и 17 удалений
  1. 23
    17
      bin/journey-test.sh

+ 23
- 17
bin/journey-test.sh Просмотреть файл

1
 #!/usr/bin/env bash
1
 #!/usr/bin/env bash
2
 
2
 
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
+
3
 on_exit() {
9
 on_exit() {
4
   echo ">>> on_exit()"
10
   echo ">>> on_exit()"
5
   if [[ "$xapi_pid" != "" ]] ; then
11
   if [[ "$xapi_pid" != "" ]] ; then
16
 
22
 
17
   if [[ "`which $binary`" == "" ]]; then
23
   if [[ "`which $binary`" == "" ]]; then
18
     echo "${binary} not found; it is required to perform this test."
24
     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"
20
     echo "PATH=${PATH}"
26
     echo "PATH=${PATH}"
21
     echo "aborting."
27
     echo "aborting."
22
     exit 1
28
     exit 1
35
   if [[ "${expected_ruby_ver}" != "" && "${current_ruby_ver}" != "${expected_ruby_ver}" ]]; then
41
   if [[ "${expected_ruby_ver}" != "" && "${current_ruby_ver}" != "${expected_ruby_ver}" ]]; then
36
     echo "${ruby_app_home} requires Ruby ${expected_ruby_ver}; current Ruby version is ${current_ruby_ver}."
42
     echo "${ruby_app_home} requires Ruby ${expected_ruby_ver}; current Ruby version is ${current_ruby_ver}."
37
     echo -e "Ruby used: `which ruby`.\n"
43
     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"
39
     echo "PATH=${PATH}"
45
     echo "PATH=${PATH}"
40
     echo "aborting."
46
     echo "aborting."
41
     exit 1
47
     exit 1
141
   local xapi_home="$2"
147
   local xapi_home="$2"
142
   echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
148
   echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
143
 
149
 
144
-  local xjava=$( pwd )
150
+  local track_root=$( pwd )
145
   pushd ${trackler}
151
   pushd ${trackler}
146
 
152
 
147
   # Get the version of Trackler x-api is currently using
153
   # Get the version of Trackler x-api is currently using
151
   git submodule init -- common
157
   git submodule init -- common
152
   git submodule update
158
   git submodule update
153
 
159
 
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}
159
 
165
 
160
   gem install bundler
166
   gem install bundler
161
   bundle install
167
   bundle install
208
   local exercism_configfile="$2"
214
   local exercism_configfile="$2"
209
   echo ">>> solve_all_exercises(exercism_exercises_dir=\"${exercism_exercises_dir}\", exercism_configfile=\"${exercism_configfile}\")"
215
   echo ">>> solve_all_exercises(exercism_exercises_dir=\"${exercism_exercises_dir}\", exercism_configfile=\"${exercism_configfile}\")"
210
 
216
 
211
-  local xjava=$( pwd )
217
+  local track_root=$( pwd )
212
   local exercism_cli="./exercism --config ${exercism_configfile}"
218
   local exercism_cli="./exercism --config ${exercism_configfile}"
213
   local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
219
   local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
214
   local total_exercises=`cat config.json | jq '.exercises | length'`
220
   local total_exercises=`cat config.json | jq '.exercises | length'`
222
     echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
228
     echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
223
     echo "=================================================="
229
     echo "=================================================="
224
 
230
 
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}/
227
 
233
 
228
-    pushd ${exercism_exercises_dir}/java/${exercise}
234
+    pushd ${exercism_exercises_dir}/${TRACK}/${exercise}
229
     # Check that tests compile before we strip @Ignore annotations
235
     # Check that tests compile before we strip @Ignore annotations
230
     "$EXECPATH"/gradlew compileTestJava
236
     "$EXECPATH"/gradlew compileTestJava
231
     # Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
237
     # 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}"
234
     done
240
     done
235
     "$EXECPATH"/gradlew test
241
     "$EXECPATH"/gradlew test
236
     popd
242
     popd
244
   # all functions assume current working directory is repository root.
250
   # all functions assume current working directory is repository root.
245
   cd "${SCRIPTPATH}/.."
251
   cd "${SCRIPTPATH}/.."
246
 
252
 
247
-  local xjava=$( pwd )
253
+  local track_root=$( pwd )
248
   local build_dir="build"
254
   local build_dir="build"
249
-  local build_path="${xjava}/${build_dir}"
255
+  local build_path="${track_root}/${build_dir}"
250
 
256
 
251
   local xapi_home="${build_path}/x-api"
257
   local xapi_home="${build_path}/x-api"
252
   local trackler_home="${build_path}/trackler"
258
   local trackler_home="${build_path}/trackler"
260
 
266
 
261
   clean "${build_dir}"
267
   clean "${build_dir}"
262
 
268
 
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.
264
   git_clone "x-api" "${xapi_home}"
270
   git_clone "x-api" "${xapi_home}"
265
   git_clone "trackler" "${trackler_home}"
271
   git_clone "trackler" "${trackler_home}"
266
   assert_ruby_installed "${trackler_home}"
272
   assert_ruby_installed "${trackler_home}"