Skip to content

Commit cb38709

Browse files
Vulpix test framework cleaned-up
There are four types of tests in the Vulpix framework: positive compilation, negative compilation, run and fuzzy. They shared a deal of common logic on which a lot of hacks was done over time. This lead to them doing essentially the same thing in different ways and with minor semantic differences. This commit makes the code in question more DRY and abstracts away the common logic for the four test types.
1 parent 7988c58 commit cb38709

File tree

3,425 files changed

+766
-10614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,425 files changed

+766
-10614
lines changed

.drone.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,41 @@ pipeline:
2020
# We run tests in parallel. Tests run in a copy of the working directory to avoid conflict
2121
test:
2222
group: test
23-
image: lampepfl/dotty:2019-04-22
23+
image: lampepfl/dotty:2019-02-06
2424
commands:
2525
- cp -R . /tmp/1/ && cd /tmp/1/
2626
- ./project/scripts/sbt ";compile ;test"
2727
- ./project/scripts/cmdTests
2828

2929
test_bootstrapped:
3030
group: test
31-
image: lampepfl/dotty:2019-04-22
31+
image: lampepfl/dotty:2019-02-06
3232
commands:
3333
- cp -R . /tmp/2/ && cd /tmp/2/
3434
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test; dotty-semanticdb/compile; dotty-semanticdb/test:compile;sjsSandbox/run"
3535
- ./project/scripts/bootstrapCmdTests
3636

3737
community_build:
3838
group: test
39-
image: lampepfl/dotty:2019-04-22
39+
image: lampepfl/dotty:2019-02-06
4040
commands:
4141
- cp -R . /tmp/3/ && cd /tmp/3/
4242
- git submodule update --init --recursive --jobs 7
4343
- ./project/scripts/sbt community-build/test
4444

4545
test_sbt:
4646
group: test
47-
image: lampepfl/dotty:2019-04-22
47+
image: lampepfl/dotty:2019-02-06
4848
commands:
4949
- cp -R . /tmp/4/ && cd /tmp/4/
5050
- ./project/scripts/sbt sbt-dotty/scripted
5151
when:
5252
# sbt scripted tests are slow and only run on nightly or deployment
5353
event: [ tag, deployment ]
5454

55-
test_scala212:
56-
group: test
57-
image: lampepfl/dotty:2019-04-22
58-
commands:
59-
- cp -R . /tmp/5/ && cd /tmp/5/
60-
- ./project/scripts/sbt ";++2.12.8 ;compile ;test"
61-
when:
62-
event: [ push, tag, deployment ]
63-
6455
# DOCUMENTATION:
6556
documentation:
66-
image: lampepfl/dotty:2019-04-22
57+
image: lampepfl/dotty:2019-02-06
6758
commands:
6859
- ./project/scripts/genDocs
6960
secrets: [ bot_token ]
@@ -75,7 +66,7 @@ pipeline:
7566
# PUBLISHING:
7667
# Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala
7768
publish_nightly:
78-
image: lampepfl/dotty:2019-04-22
69+
image: lampepfl/dotty:2019-02-06
7970
environment:
8071
- NIGHTLYBUILD=yes
8172
commands:
@@ -86,7 +77,7 @@ pipeline:
8677
environment: nightly
8778

8879
publish_release:
89-
image: lampepfl/dotty:2019-04-22
80+
image: lampepfl/dotty:2019-02-06
9081
environment:
9182
- RELEASEBUILD=yes
9283
commands:
@@ -110,7 +101,7 @@ pipeline:
110101
event: tag
111102

112103
publish_sbt_release:
113-
image: lampepfl/dotty:2019-04-22
104+
image: lampepfl/dotty:2019-02-06
114105
environment:
115106
- RELEASEBUILD=yes
116107
commands:
Submodule stdLib213 updated 547 files

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,15 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
119119

120120
// binary operation
121121
case rarg :: Nil =>
122-
val isShift = isShiftOp(code)
123-
resKind = tpeTK(larg).maxType(if (isShift) INT else tpeTK(rarg))
124-
125-
if (isShift || isBitwiseOp(code)) {
122+
resKind = tpeTK(larg).maxType(tpeTK(rarg))
123+
if (isShiftOp(code) || isBitwiseOp(code)) {
126124
assert(resKind.isIntegralType || (resKind == BOOL),
127125
s"$resKind incompatible with arithmetic modulo operation.")
128126
}
129127

130128
genLoad(larg, resKind)
131-
genLoad(rarg, if (isShift) INT else resKind)
129+
genLoad(rarg, // check .NET size of shift arguments!
130+
if (isShiftOp(code)) INT else resKind)
132131

133132
(code: @switch) match {
134133
case ADD => bc add resKind

compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,16 @@ class BTypesFromSymbols[I <: BackendInterface](val int: I) extends BTypes {
200200

201201
val finalFlag = sym.getsJavaFinalFlag
202202

203+
// Primitives are "abstract final" to prohibit instantiation
204+
// without having to provide any implementations, but that is an
205+
// illegal combination of modifiers at the bytecode level so
206+
// suppress final if abstract if present.
203207
import asm.Opcodes._
204208
GenBCodeOps.mkFlags(
205209
if (privateFlag) ACC_PRIVATE else ACC_PUBLIC,
206210
if (sym.isDeferred || sym.hasAbstractFlag) ACC_ABSTRACT else 0,
207211
if (sym.isInterface) ACC_INTERFACE else 0,
208-
209-
if (finalFlag &&
210-
// Primitives are "abstract final" to prohibit instantiation
211-
// without having to provide any implementations, but that is an
212-
// illegal combination of modifiers at the bytecode level so
213-
// suppress final if abstract if present.
214-
!sym.hasAbstractFlag &&
215-
// Mixin forwarders are bridges and can be final, but final bridges confuse some frameworks
216-
!sym.isBridge)
217-
ACC_FINAL else 0,
212+
if (finalFlag && !sym.hasAbstractFlag) ACC_FINAL else 0,
218213
if (sym.isStaticMember) ACC_STATIC else 0,
219214
if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0,
220215
if (sym.isArtifact) ACC_SYNTHETIC else 0,

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -482,19 +482,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
482482

483483
private def verifySignature(sym: Symbol, sig: String)(implicit ctx: Context): Unit = {
484484
import scala.tools.asm.util.CheckClassAdapter
485-
def wrap(body: => Unit): Unit = {
486-
try body
487-
catch {
488-
case ex: Throwable =>
489-
ctx.error(i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName}
490-
|signature: $sig
491-
|if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues
492-
""".trim, sym.sourcePos)
493-
throw ex
494-
}
495-
}
485+
def wrap(body: => Unit): Boolean =
486+
try { body; true }
487+
catch { case ex: Throwable => println(ex.getMessage); false }
496488

497-
wrap {
489+
val valid = wrap {
498490
if (sym.is(Flags.Method)) {
499491
CheckClassAdapter.checkMethodSignature(sig)
500492
}
@@ -505,6 +497,14 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
505497
CheckClassAdapter.checkClassSignature(sig)
506498
}
507499
}
500+
501+
if (!valid) {
502+
ctx.error(
503+
i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName}
504+
|signature: $sig
505+
|if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues
506+
""".trim, sym.sourcePos)
507+
}
508508
}
509509

510510
/**
@@ -841,14 +841,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
841841

842842
def addRemoteRemoteExceptionAnnotation: Unit = ()
843843

844-
def samMethod(): Symbol = ctx.atPhase(ctx.erasurePhase) { implicit ctx =>
845-
toDenot(sym).info.abstractTermMembers.toList match {
846-
case x :: Nil => x.symbol
847-
case Nil => abort(s"${sym.show} is not a functional interface. It doesn't have abstract methods")
848-
case xs => abort(s"${sym.show} is not a functional interface. " +
849-
s"It has the following abstract methods: ${xs.map(_.name).mkString(", ")}")
850-
}
851-
}
844+
def samMethod(): Symbol =
845+
toDenot(sym).info.abstractTermMembers.headOption.getOrElse(toDenot(sym).info.member(nme.apply)).symbol
852846

853847
def isFunctionClass: Boolean =
854848
defn.isFunctionClass(sym)

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
180180
try { /*withCurrentUnit(item.cunit)*/(visit(item)) }
181181
catch {
182182
case ex: Throwable =>
183-
println(s"Error while emitting ${int.sourceFileFor(item.cunit)}")
184-
throw ex
183+
ex.printStackTrace()
184+
ctx.error(s"Error while emitting ${int.sourceFileFor(item.cunit)}\n${ex.getMessage}")
185185
}
186186
}
187187
}
@@ -414,8 +414,8 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
414414
addToQ3(item)
415415
} catch {
416416
case ex: Throwable =>
417-
println(s"Error while emitting ${item.plain.classNode.name}")
418-
throw ex
417+
ex.printStackTrace()
418+
ctx.error(s"Error while emitting ${item.plain.classNode.name}\n${ex.getMessage}")
419419
}
420420
}
421421
}

compiler/src/dotty/tools/dotc/Driver.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import config.CompilerCommand
77
import core.Comments.{ContextDoc, ContextDocstrings}
88
import core.Contexts.{Context, ContextBase}
99
import core.{MacroClassLoader, Mode, TypeError}
10-
import dotty.tools.dotc.ast.Positioned
1110
import reporting._
1211

1312
import scala.util.control.NonFatal
@@ -56,7 +55,6 @@ class Driver {
5655
val summary = CompilerCommand.distill(args)(ctx)
5756
ctx.setSettings(summary.sstate)
5857
MacroClassLoader.init(ctx)
59-
Positioned.updateDebugPos(ctx)
6058

6159
if (!ctx.settings.YdropComments.value(ctx) || ctx.mode.is(Mode.ReadComments)) {
6260
ctx.setProperty(ContextDoc, new ContextDocstrings)

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,21 +274,27 @@ object desugar {
274274

275275
/** Transforms a definition with a name starting with a `$` in a quoted pattern into a `quoted.binding.Binding` splice.
276276
*
277-
* The desugaring consists in adding the `@patternBindHole` annotation. This annotation is used during typing to perform the full transformation.
277+
* The desugaring consists in renaming the the definition and adding the `@patternBindHole` annotation. This
278+
* annotation is used during typing to perform the full transformation.
278279
*
279280
* A definition
280281
* ```scala
281-
* case '{ def $a(...) = ...; ... `$a`() ... } => a
282+
* case '{ def $a(...) = ... a() ...; ... a() ... }
282283
* ```
283284
* into
284285
* ```scala
285-
* case '{ @patternBindHole def `$a`(...) = ...; ... `$a`() ... } => a
286+
* case '{ @patternBindHole def a(...) = ... a() ...; ... a() ... }
286287
* ```
287288
*/
288289
def transformQuotedPatternName(tree: ValOrDefDef)(implicit ctx: Context): ValOrDefDef = {
289290
if (ctx.mode.is(Mode.QuotedPattern) && !tree.isBackquoted && tree.name != nme.ANON_FUN && tree.name.startsWith("$")) {
291+
val name = tree.name.toString.substring(1).toTermName
292+
val newTree: ValOrDefDef = tree match {
293+
case tree: ValDef => cpy.ValDef(tree)(name)
294+
case tree: DefDef => cpy.DefDef(tree)(name)
295+
}
290296
val mods = tree.mods.withAddedAnnotation(New(ref(defn.InternalQuoted_patternBindHoleAnnot.typeRef)).withSpan(tree.span))
291-
tree.withMods(mods)
297+
newTree.withMods(mods)
292298
} else tree
293299
}
294300

compiler/src/dotty/tools/dotc/ast/Positioned.scala

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Pro
2424
def uniqueId: Int = myUniqueId
2525

2626
def uniqueId_=(id: Int): Unit = {
27-
if (Positioned.debugId == id) {
28-
def printTrace() = {
29-
val stack = Thread.currentThread().getStackTrace().map("> " + _)
30-
System.err.println(stack.mkString(s"> Debug tree (id=${Positioned.debugId}) creation \n> $this\n", "\n", "\n"))
31-
}
32-
printTrace()
33-
}
27+
//assert(id != 2523, this)
3428
myUniqueId = id
3529
}
3630

@@ -232,11 +226,3 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Pro
232226
throw ex
233227
}
234228
}
235-
236-
object Positioned {
237-
@sharable private[Positioned] var debugId = Int.MinValue
238-
239-
def updateDebugPos(implicit ctx: Context): Unit = {
240-
debugId = ctx.settings.YdebugTreeWithId.value
241-
}
242-
}

0 commit comments

Comments
 (0)