@@ -4,6 +4,7 @@ TRACK=java
44TRACK_REPO=" $TRACK "
55TRACK_SRC_EXT=" java"
66CPU_CORES=` getconf NPROCESSORS_ONLN 2> /dev/null || getconf _NPROCESSORS_ONLN 2> /dev/null || echo 1`
7+ EXERCISES_TO_SOLVE=$@
78
89on_exit () {
910 echo " >>> on_exit()"
@@ -256,6 +257,42 @@ solve_all_exercises() {
256257 popd
257258}
258259
260+ solve_single_exercise () {
261+ local exercism_exercises_dir=" $1 "
262+ local exercism_configfile=" $2 "
263+ local exercise_to_solve=" $3 "
264+ echo " >>> solve_all_exercises(exercism_exercises_dir=\" ${exercism_exercises_dir} \" , exercism_configfile=\" ${exercism_configfile} \" , exercise_to_solve=\" $exercise_to_solve \" )"
265+
266+ local track_root=$( pwd )
267+ local exercism_cli=" ./exercism --config ${exercism_configfile} "
268+ local tempfile=" ${TMPDIR:-/ tmp} /journey-test.sh-unignore_all_tests.txt"
269+
270+ pushd ${exercism_exercises_dir}
271+
272+ echo -e " \n\n"
273+ echo " =================================================="
274+ echo " Solving ${exercise_to_solve} "
275+ echo " =================================================="
276+
277+ ${exercism_cli} fetch ${TRACK} $exercise_to_solve
278+ cp -R -H ${track_root} /exercises/${exercise_to_solve} /src/example/${TRACK} /* ${exercism_exercises_dir} /${TRACK} /${exercise_to_solve} /src/main/${TRACK} /
279+
280+ pushd ${exercism_exercises_dir} /${TRACK} /${exercise_to_solve}
281+ # Check that tests compile before we strip @Ignore annotations
282+ " $EXECPATH " /gradlew compileTestJava
283+ # Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
284+ for testfile in ` find . -name " *Test.${TRACK_SRC_EXT} " ` ; do
285+ # Strip @Ignore annotations to ensure we run the tests (as delivered, all but the first is @Ignore'd).
286+ # Note that unit-test.sh also strips @Ignore annotations via the Gradle task copyTestsFilteringIgnores.
287+ # The stripping implementations here and in copyTestsFilteringIgnores should be kept consistent.
288+ sed ' s/@Ignore\(\(.*\)\)\{0,1\}//' ${testfile} > " ${tempfile} " && mv " ${tempfile} " " ${testfile} "
289+ done
290+ " $EXECPATH " /gradlew test
291+ popd
292+
293+ popd
294+ }
295+
259296main () {
260297 # all functions assume current working directory is repository root.
261298 cd " ${SCRIPTPATH} /.."
@@ -296,7 +333,13 @@ main() {
296333 # Create a CLI install and config just for this build; this script does not use your CLI install.
297334 configure_exercism_cli " ${exercism_home} " " ${exercism_configfile} " " ${xapi_port} "
298335
299- solve_all_exercises " ${exercism_home} " " ${exercism_configfile} "
336+ if [[ $EXERCISES_TO_SOLVE == " " ]]; then
337+ solve_all_exercises " ${exercism_home} " " ${exercism_configfile} "
338+ else
339+ for exercise in $EXERCISES_TO_SOLVE
340+ do solve_single_exercise " ${exercism_home} " " ${exercism_configfile} " " ${exercise} "
341+ done
342+ fi
300343}
301344
302345# #########################################################################
0 commit comments