3
3
default_dirs=( " src/script/scala" )
4
4
out_root=" target/script-tests"
5
5
out_ext=" out"
6
+ timestamp=$( date +" %Y-%m-%d_%H-%M-%S" )
6
7
expected_errors_in=(
7
- src/script/scala/progscala3/appdesign/Deprecated.scala
8
- src/script/scala/progscala3/patternmatching/MatchExhaustive.scala
9
- src/script/scala/progscala3/patternmatching/MatchSurprise.scala
8
+
10
9
src/script/scala/progscala3/IndentationSyntax.scala
11
- src/script/scala/progscala3/contexts/typeclass/TypeClassSubtypingProblems.scala
10
+ src/script/scala/progscala3/appdesign/Deprecated.scala
11
+ src/script/scala/progscala3/basicoop/MatchableOpaque.scala
12
+ src/script/scala/progscala3/collections/MultiMap.scala
13
+ src/script/scala/progscala3/contexts/ImplicitEvidence.scala
14
+ src/script/scala/progscala3/contexts/ImplicitNotFound.scala
15
+ src/script/scala/progscala3/contexts/MatchGivens.scala
12
16
src/script/scala/progscala3/contexts/SeqUnzip.scala
13
- src/script/scala/progscala3/meta/inline/Recursive.scala
14
- src/script/scala/progscala3/meta/inline/Overrides.scala
17
+ src/script/scala/progscala3/dynamic/SelectableSQL.scala
15
18
src/script/scala/progscala3/meta/compiletime/RequireConst.scala
16
19
src/script/scala/progscala3/meta/compiletime/SummonAll.scala
17
- src/script/scala/progscala3/rounding/TypeErasureProblem.scala
20
+ src/script/scala/progscala3/meta/inline/ConditionalMatch.scala
21
+ src/script/scala/progscala3/meta/inline/Overrides.scala
22
+ src/script/scala/progscala3/meta/inline/Recursive.scala
23
+ src/script/scala/progscala3/objectsystem/variance/MutableVariance.scala
24
+ src/script/scala/progscala3/patternmatching/Matchable.scala
25
+ src/script/scala/progscala3/patternmatching/MatchExhaustive.scala
26
+ src/script/scala/progscala3/patternmatching/MatchForFiltering.scala
27
+ src/script/scala/progscala3/patternmatching/MatchSurprise.scala
28
+ src/script/scala/progscala3/patternmatching/MatchTypesErasure.scala
29
+ src/script/scala/progscala3/patternmatching/UnapplySingleValue2.scala
18
30
src/script/scala/progscala3/rounding/InfixMethod.scala
31
+ src/script/scala/progscala3/rounding/InfixType.scala
32
+ src/script/scala/progscala3/rounding/TypeErasureProblem.scala
19
33
src/script/scala/progscala3/typelessdomore/Human.scala
20
- src/script/scala/progscala3/typelessdomore/RepeatedParameters.scala
21
34
src/script/scala/progscala3/typelessdomore/MethodBroadInference.scala
22
- src/script/scala/progscala3/typelessdomore/MethodRecursiveReturn.scala
23
35
src/script/scala/progscala3/typelessdomore/MethodNestedReturn.scala
24
- src/script/scala/progscala3/basicoop/MatchableOpaque.scala
36
+ src/script/scala/progscala3/typelessdomore/MethodRecursiveReturn.scala
37
+ src/script/scala/progscala3/typelessdomore/RepeatedParameters.scala
38
+ src/script/scala/progscala3/typesystem/bounds/ViewToContextBounds.scala
39
+ src/script/scala/progscala3/typesystem/deptypes/DependentTypes.scala
40
+ src/script/scala/progscala3/typesystem/deptypes/DependentTypesBounds.scala
41
+ src/script/scala/progscala3/typesystem/deptypes/DependentTypesSimple.scala
42
+ src/script/scala/progscala3/typesystem/intersectionunion/Intersection.scala
43
+ src/script/scala/progscala3/typesystem/intersectionunion/Union.scala
44
+ src/script/scala/progscala3/typesystem/matchtypes/MatchTypes2.scala
25
45
src/script/scala/progscala3/typesystem/typepaths/TypePath.scala
26
46
src/script/scala/progscala3/typesystem/valuetypes/SingletonTypes.scala
27
- src/script/scala/progscala3/patternmatching/MatchTypesErasure.scala
28
- src/script/scala/progscala3/patternmatching/MatchForFiltering.scala
29
- src/script/scala/progscala3/collections/MultiMap.scala
47
+ src/script/scala/progscala3/typesystem/valuetypes/TypeProjection.scala
30
48
)
31
49
32
50
error () {
@@ -46,18 +64,19 @@ are files with @main methods under src/main that can be interpreted as Scala 3
46
64
argument.
47
65
48
66
So, this bash script starts the REPL (using "sbt console") for each file and then
49
- uses :load to load the file. The output is written to
67
+ uses :load to load the file. The output for that console sessions is written to
50
68
$out_root /path/to/file.$out_ext .
51
69
70
+ A list of files with errors or warnings is written to $out_root /errors-$timestamp .log.
71
+
52
72
The following files are known to throw errors intentionally:
53
73
$( for f in ${expected_errors_in[@]} ; do echo " $f " ; done)
54
74
55
- Failures for these known files are ignored. In some of them, you'll see a comment
56
- on the same line, like "// ERROR" or "// COMPILATION ERROR", which are easier to
57
- spot when looking at error messages. In other cases, you have to look at the book
58
- discussion to see if the error is expected. Unfortunately, this means that any
59
- unexpected errors in these files will be missed, unless you inspect the output
60
- when running them!
75
+ Failures for these known files are ignored, but logged in $out_root /errors-$timestamp .log.
76
+ In most of them, you'll see a comment on the same line, like "// ERROR" or "// COMPILATION ERROR",
77
+ which are easier to spot when looking at error messages. In the rest of the cases, you have to
78
+ look at the book discussion to see if the error is expected. Unfortunately, this means that any
79
+ unexpected errors in these files will be missed, unless you inspect the output carefully!
61
80
62
81
For finding unexpected errors, the console output is searched for errors by looking
63
82
for any of the following lines near the end (where N=2+):
@@ -67,7 +86,7 @@ N warnings found
67
86
1 error found
68
87
N errors found
69
88
70
- HOWEVER, to be really safe, all the outputs should still be inspected manually.
89
+ ** HOWEVER, to be really safe, all the outputs should still be inspected manually. **
71
90
72
91
Usage: $0 [-h|--help] [-v|--verbose] [-c|--clean] [-n|--no-exec] [dir ...]
73
92
Where:
@@ -128,44 +147,47 @@ then
128
147
[[ -n " $out_root " ]] && rm -rf " $out_root " # safety check!
129
148
fi
130
149
150
+
151
+ error_log=" $out_root /errors-$timestamp .log"
152
+ rm -f $error_log
153
+
154
+ print_count () {
155
+ let count=$1 ; shift
156
+ file=$1 ; shift
157
+ out=$1 ; shift
158
+ message=" $1 " ; shift
159
+ printf ' %5d: %s %s %s\n' $count " $file " " $out " " $message " >> $error_log
160
+ }
161
+
131
162
count_problem () {
132
- problem=$1
133
- script=$2
134
- out=$3
135
- let count=$( grep -cE " ^.+ $problem ? found$" " $out " | sed -e " s/ $problem .*//" )
136
- case $count in
137
- 0)
138
- # do nothing
139
- ;;
140
- 1)
141
- echo " ERROR: 1 ${problem} found in $script ($out )"
142
- ;;
143
- * )
144
- echo " ERROR: $count ${problem} s found in $script ($out )"
145
- ;;
146
- esac
163
+ script=$1
164
+ out=$2
165
+ let count=$( grep -cE " ^.+ (error|warning)s? found$" " $out " )
166
+ [[ $count -gt 0 ]] && print_count $count $script $out
147
167
return $count
148
168
}
149
169
150
170
report () {
151
171
let status=$1
152
172
script=$2
153
173
out=$3
174
+ for skip in ${expected_errors_in[@]}
175
+ do
176
+ if [[ " $skip " = " $script " ]]
177
+ then
178
+ print_count 0 " $script " " $out " " NOTE: because of known deliberate errors, unexpected errors might be missed!"
179
+ return 0
180
+ fi
181
+ done
154
182
let error_count=0
155
183
if [[ $status -ne 0 ]]
156
184
then
157
185
echo " ERROR: $script failed! ($out )"
158
186
let error_count+=1
159
187
fi
160
- for skip in ${expected_errors_in[@]}
161
- do
162
- [[ " $skip " = " $script " ]] && return $error_count
163
- done
164
- count_problem ' warning' " $script " " $out "
165
- let error_count+=$?
166
- count_problem ' error' " $script " " $out "
188
+ count_problem " $script " " $out "
167
189
let error_count+=$?
168
- $VERBOSE && cat " $out "
190
+ # $VERBOSE && cat "$out"
169
191
return $error_count
170
192
}
171
193
214
236
rm -f " $problem_count "
215
237
if [[ $total_problem_count -gt 0 ]]
216
238
then
217
- echo " ERROR: $total_problem_count issues found."
239
+ echo " ERROR: $total_problem_count issues found. See $error_log "
240
+ print_count $total_problem_count $error_log " " " issues found!"
218
241
exit 1
219
242
fi
220
243
fi
0 commit comments