Преглед изворни кода

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

journey test: pull in improvements from xkotlin
Stuart Kent пре 9 година
родитељ
комит
60bf4696e7
1 измењених фајлова са 23 додато и 17 уклоњено
  1. 23
    17
      bin/journey-test.sh

+ 23
- 17
bin/journey-test.sh Прегледај датотеку

@@ -1,5 +1,11 @@
1 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 9
 on_exit() {
4 10
   echo ">>> on_exit()"
5 11
   if [[ "$xapi_pid" != "" ]] ; then
@@ -16,7 +22,7 @@ assert_installed() {
16 22
 
17 23
   if [[ "`which $binary`" == "" ]]; then
18 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 26
     echo "PATH=${PATH}"
21 27
     echo "aborting."
22 28
     exit 1
@@ -35,7 +41,7 @@ assert_ruby_installed() {
35 41
   if [[ "${expected_ruby_ver}" != "" && "${current_ruby_ver}" != "${expected_ruby_ver}" ]]; then
36 42
     echo "${ruby_app_home} requires Ruby ${expected_ruby_ver}; current Ruby version is ${current_ruby_ver}."
37 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 45
     echo "PATH=${PATH}"
40 46
     echo "aborting."
41 47
     exit 1
@@ -141,7 +147,7 @@ make_local_trackler() {
141 147
   local xapi_home="$2"
142 148
   echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
143 149
 
144
-  local xjava=$( pwd )
150
+  local track_root=$( pwd )
145 151
   pushd ${trackler}
146 152
 
147 153
   # Get the version of Trackler x-api is currently using
@@ -151,11 +157,11 @@ make_local_trackler() {
151 157
   git submodule init -- common
152 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 166
   gem install bundler
161 167
   bundle install
@@ -208,7 +214,7 @@ solve_all_exercises() {
208 214
   local exercism_configfile="$2"
209 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 218
   local exercism_cli="./exercism --config ${exercism_configfile}"
213 219
   local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
214 220
   local total_exercises=`cat config.json | jq '.exercises | length'`
@@ -222,15 +228,15 @@ solve_all_exercises() {
222 228
     echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
223 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 235
     # Check that tests compile before we strip @Ignore annotations
230 236
     "$EXECPATH"/gradlew compileTestJava
231 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 240
     done
235 241
     "$EXECPATH"/gradlew test
236 242
     popd
@@ -244,9 +250,9 @@ main() {
244 250
   # all functions assume current working directory is repository root.
245 251
   cd "${SCRIPTPATH}/.."
246 252
 
247
-  local xjava=$( pwd )
253
+  local track_root=$( pwd )
248 254
   local build_dir="build"
249
-  local build_path="${xjava}/${build_dir}"
255
+  local build_path="${track_root}/${build_dir}"
250 256
 
251 257
   local xapi_home="${build_path}/x-api"
252 258
   local trackler_home="${build_path}/trackler"
@@ -260,7 +266,7 @@ main() {
260 266
 
261 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 270
   git_clone "x-api" "${xapi_home}"
265 271
   git_clone "trackler" "${trackler_home}"
266 272
   assert_ruby_installed "${trackler_home}"