33default_dirs=( " src/script/scala" )
44out_root=" target/script-tests"
55out_ext=" out"
6+ timestamp=$( date +" %Y-%m-%d_%H-%M-%S" )
67expected_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+
109 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
1216 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
1518 src/script/scala/progscala3/meta/compiletime/RequireConst.scala
1619 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
1830 src/script/scala/progscala3/rounding/InfixMethod.scala
31+ src/script/scala/progscala3/rounding/InfixType.scala
32+ src/script/scala/progscala3/rounding/TypeErasureProblem.scala
1933 src/script/scala/progscala3/typelessdomore/Human.scala
20- src/script/scala/progscala3/typelessdomore/RepeatedParameters.scala
2134 src/script/scala/progscala3/typelessdomore/MethodBroadInference.scala
22- src/script/scala/progscala3/typelessdomore/MethodRecursiveReturn.scala
2335 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
2545 src/script/scala/progscala3/typesystem/typepaths/TypePath.scala
2646 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
3048)
3149
3250error () {
@@ -46,18 +64,19 @@ are files with @main methods under src/main that can be interpreted as Scala 3
4664argument.
4765
4866So, 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
5068$out_root /path/to/file.$out_ext .
5169
70+ A list of files with errors or warnings is written to $out_root /errors-$timestamp .log.
71+
5272The following files are known to throw errors intentionally:
5373$( for f in ${expected_errors_in[@]} ; do echo " $f " ; done)
5474
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!
6180
6281For finding unexpected errors, the console output is searched for errors by looking
6382for any of the following lines near the end (where N=2+):
@@ -67,7 +86,7 @@ N warnings found
67861 error found
6887N errors found
6988
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. **
7190
7291Usage: $0 [-h|--help] [-v|--verbose] [-c|--clean] [-n|--no-exec] [dir ...]
7392Where:
@@ -128,44 +147,47 @@ then
128147 [[ -n " $out_root " ]] && rm -rf " $out_root " # safety check!
129148fi
130149
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+
131162count_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
147167 return $count
148168}
149169
150170report () {
151171 let status=$1
152172 script=$2
153173 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
154182 let error_count=0
155183 if [[ $status -ne 0 ]]
156184 then
157185 echo " ERROR: $script failed! ($out )"
158186 let error_count+=1
159187 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 "
167189 let error_count+=$?
168- $VERBOSE && cat " $out "
190+ # $VERBOSE && cat "$out"
169191 return $error_count
170192}
171193
214236 rm -f " $problem_count "
215237 if [[ $total_problem_count -gt 0 ]]
216238 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!"
218241 exit 1
219242 fi
220243fi
0 commit comments