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

Merge pull request #277 from FridaTveit/JourneyTestMakeWorkWithExercises

Issue #154: make journey-test.sh use exercises
FridaTveit 9 лет назад
Родитель
Сommit
6e624c0e3f

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

72
           echo "linux";;
72
           echo "linux";;
73
       (Windows*)
73
       (Windows*)
74
           echo "windows";;
74
           echo "windows";;
75
+      (MINGW*)
76
+          echo "windows";;
75
       (*)
77
       (*)
76
           echo "linux";;
78
           echo "linux";;
77
   esac
79
   esac
102
   # "curl..." :: HTTP 302 headers, including "Location" -- URL to redirect to.
104
   # "curl..." :: HTTP 302 headers, including "Location" -- URL to redirect to.
103
   # "awk..." :: pluck last path segment from "Location" (i.e. the version number)
105
   # "awk..." :: pluck last path segment from "Location" (i.e. the version number)
104
   local version="$(curl --head --silent ${latest} | awk -v FS=/ '/Location:/{print $NF}' | tr -d '\r')"
106
   local version="$(curl --head --silent ${latest} | awk -v FS=/ '/Location:/{print $NF}' | tr -d '\r')"
105
-  local download_url=${CLI_RELEASES}/download/${version}/exercism-${os}-${arch}.tgz
107
+
108
+  local download_url_suffix
109
+  local unzip_command
110
+  local unzip_from_file_option
111
+  if [[ ${os} == "windows" ]] ; then
112
+    download_url_suffix="zip"
113
+    unzip_command="unzip -d"
114
+    unzip_from_file_option=""
115
+  else
116
+    download_url_suffix="tgz"
117
+    unzip_command="tar xz -C"
118
+    unzip_from_file_option="-f"
119
+  fi
120
+  local download_url=${CLI_RELEASES}/download/${version}/exercism-${os}-${arch}.${download_url_suffix}
106
 
121
 
107
   mkdir -p ${exercism_home}
122
   mkdir -p ${exercism_home}
108
-  curl -s --location ${download_url} | tar xz -C ${exercism_home}
123
+  local temp=`mktemp`
124
+  curl -s --location ${download_url} > ${temp}
125
+  ${unzip_command} ${exercism_home} ${unzip_from_file_option} ${temp}
109
   echo "<<< download_exercism_cli()"
126
   echo "<<< download_exercism_cli()"
110
 }
127
 }
111
 
128
 
192
 
209
 
193
   local xjava=$( pwd )
210
   local xjava=$( pwd )
194
   local exercism_cli="./exercism --config ${exercism_configfile}"
211
   local exercism_cli="./exercism --config ${exercism_configfile}"
195
-  local exercises=`cat config.json | jq '.problems []' --raw-output`
196
-  local total_exercises=`cat config.json | jq '.problems | length'`
212
+  local exercises=`cat config.json | jq '.exercises[].slug + " "' --join-output`
213
+  local total_exercises=`cat config.json | jq '.exercises | length'`
197
   local current_exercise_number=1
214
   local current_exercise_number=1
198
   local tempfile="${TMPDIR:-/tmp}/journey-test.sh-unignore_all_tests.txt"
215
   local tempfile="${TMPDIR:-/tmp}/journey-test.sh-unignore_all_tests.txt"
199
 
216
 

+ 0
- 1
exercises/allergies/src/example/java/Allergen.java Просмотреть файл

1
-../../main/java/Allergen.java

+ 20
- 0
exercises/allergies/src/example/java/Allergen.java Просмотреть файл

1
+public enum Allergen {
2
+    EGGS(1),
3
+    PEANUTS(2),
4
+    SHELLFISH(4),
5
+    STRAWBERRIES(8),
6
+    TOMATOES(16),
7
+    CHOCOLATE(32),
8
+    POLLEN(64),
9
+    CATS(128);
10
+
11
+    private final int score;
12
+
13
+    Allergen(int score) {
14
+        this.score = score;
15
+    }
16
+
17
+    public int getScore() {
18
+        return score;
19
+    }
20
+}

+ 0
- 1
exercises/meetup/src/example/java/MeetupSchedule.java Просмотреть файл

1
-../../main/java/MeetupSchedule.java

+ 8
- 0
exercises/meetup/src/example/java/MeetupSchedule.java Просмотреть файл

1
+public enum MeetupSchedule {
2
+    FIRST,
3
+    SECOND,
4
+    THIRD,
5
+    FOURTH,
6
+    LAST,
7
+    TEENTH
8
+}

+ 0
- 1
exercises/perfect-numbers/src/example/java/Classification.java Просмотреть файл

1
-../../main/java/Classification.java

+ 5
- 0
exercises/perfect-numbers/src/example/java/Classification.java Просмотреть файл

1
+enum Classification {
2
+
3
+    DEFICIENT, PERFECT, ABUNDANT
4
+
5
+}

+ 0
- 1
exercises/robot-simulator/src/example/java/GridPosition.java Просмотреть файл

1
-../../main/java/GridPosition.java

+ 29
- 0
exercises/robot-simulator/src/example/java/GridPosition.java Просмотреть файл

1
+final class GridPosition {
2
+
3
+    final int x;
4
+
5
+    final int y;
6
+
7
+    GridPosition(final int x, final int y) {
8
+        this.x = x;
9
+        this.y = y;
10
+    }
11
+
12
+    /*
13
+     * This equals method is of deliberately narrow scope (only allows comparison with another GridPosition) to increase
14
+     * readability. In general, one should provide a full implementation of Object.equals(Object obj) and a
15
+     * corresponding implementation of Object.hashCode(). See
16
+     *
17
+     * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)
18
+     *
19
+     * and
20
+     *
21
+     * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()
22
+     *
23
+     * for more information.
24
+     */
25
+    boolean equals(final GridPosition gridPosition) {
26
+        return this.x == gridPosition.x && this.y == gridPosition.y;
27
+    }
28
+
29
+}

+ 0
- 1
exercises/robot-simulator/src/example/java/Orientation.java Просмотреть файл

1
-../../main/java/Orientation.java

+ 5
- 0
exercises/robot-simulator/src/example/java/Orientation.java Просмотреть файл

1
+enum Orientation {
2
+
3
+    NORTH, EAST, SOUTH, WEST
4
+
5
+}

+ 0
- 1
exercises/secret-handshake/src/example/java/Signal.java Просмотреть файл

1
-../../main/java/Signal.java

+ 5
- 0
exercises/secret-handshake/src/example/java/Signal.java Просмотреть файл

1
+enum Signal {
2
+
3
+    WINK, DOUBLE_BLINK, CLOSE_YOUR_EYES, JUMP
4
+
5
+}

+ 0
- 1
exercises/sublist/src/example/java/Relationship.java Просмотреть файл

1
-../../main/java/Relationship.java

+ 5
- 0
exercises/sublist/src/example/java/Relationship.java Просмотреть файл

1
+enum Relationship {
2
+
3
+    EQUAL, SUBLIST, SUPERLIST, UNEQUAL
4
+
5
+}

+ 0
- 1
exercises/triangle/src/example/java/TriangleException.java Просмотреть файл

1
-../../main/java/TriangleException.java

+ 5
- 0
exercises/triangle/src/example/java/TriangleException.java Просмотреть файл

1
+public class TriangleException extends Exception {
2
+
3
+    public TriangleException() {
4
+    }
5
+}

+ 0
- 1
exercises/triangle/src/example/java/TriangleKind.java Просмотреть файл

1
-../../main/java/TriangleKind.java

+ 5
- 0
exercises/triangle/src/example/java/TriangleKind.java Просмотреть файл

1
+public enum TriangleKind {
2
+    EQUILATERAL,
3
+    ISOSCELES,
4
+    SCALENE
5
+}