Skip to content

Commit

Permalink
Merge branch 'dev' into fix-colliders
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Nov 19, 2019
2 parents 8e8bbd1 + 8fa7c53 commit 2c20c7f
Show file tree
Hide file tree
Showing 90 changed files with 4,054 additions and 3,348 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class WollokChecker {
def void collectWollokFiles(File folder, List<File> classpath) {
classpath.addAll(
folder.listFiles [ dir, name |
name.endsWith("." + WollokConstants.CLASS_OBJECTS_EXTENSION) ||
name.endsWith("." + WollokConstants.WOLLOK_DEFINITION_EXTENSION) ||
name.endsWith("." + WollokConstants.PROGRAM_EXTENSION) ||
name.endsWith("." + WollokConstants.TEST_EXTENSION)
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,20 @@ class DefaultWollokTestsReporter implements WollokTestsReporter {
}

def testFinished(WTest test) {
testTimeElapsed.get(test).to = System.currentTimeMillis
if (test.hasTimeElapsedRecord) {
testTimeElapsed.get(test).to = System.currentTimeMillis
}
}

def getTotalTime(WTest test) {
testTimeElapsed.get(test).totalTime
if (test.hasTimeElapsedRecord) testTimeElapsed.get(test).totalTime else 0
}

/**
* If there was an error in the fixture, or in variable initialization, we won't be able to get the test in the map
*/
def hasTimeElapsedRecord(WTest test) {
testTimeElapsed.get(test) !== null
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.uqbar.project.wollok.launch.tests

import java.util.List
import org.eclipse.emf.common.util.URI
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtend.lib.annotations.Data
import org.fusesource.jansi.AnsiConsole
import org.uqbar.project.wollok.interpreter.WollokTestsFailedException
import org.uqbar.project.wollok.wollokDsl.WFile
Expand Down Expand Up @@ -34,7 +36,10 @@ class WollokConsoleTestsReporter extends DefaultWollokTestsReporter {
int testsFailed = 0
int testsErrored = 0
int testsRun = 0

List<WTestFailed> reportTestsFailed = newArrayList

public static String FINAL_SEPARATOR = "====================================================================================================="

override testsToRun(String suiteName, WFile file, List<WTest> tests) {
AnsiConsole.systemInstall
if (suiteName ?: '' !== '') {
Expand All @@ -50,14 +55,8 @@ class WollokConsoleTestsReporter extends DefaultWollokTestsReporter {
override reportTestAssertError(WTest test, AssertionException assertionError, int lineNumber, URI resource) {
test.testFinished
incrementTestsFailed
println(ansi
.a(" ").fg(YELLOW).a(test.name).a(": ✗ FAILED (").a(test.totalTime).a("ms) => ").reset
.fg(YELLOW).a(assertionError.message).reset
.fg(YELLOW).a(" (").a(resource.trimFragment).a(":").a(lineNumber).a(")").reset
.a("\n ")
.fg(YELLOW).a(assertionError.wollokException?.convertStackTrace.join("\n ")).reset
.a("\n")
)
test.printAssertionException(assertionError, lineNumber, resource)
reportTestsFailed.add(new WTestFailed(test, assertionError, null, lineNumber, resource))
}

override reportTestOk(WTest test) {
Expand All @@ -68,17 +67,30 @@ class WollokConsoleTestsReporter extends DefaultWollokTestsReporter {
override reportTestError(WTest test, Exception exception, int lineNumber, URI resource) {
test.testFinished
incrementTestsErrored
println(ansi.a(" ").fg(RED).a(test.name).a(": ✗ ERRORED (").a(test.totalTime).a("ms) => ").reset
.fg(RED).a(exception.convertToString).reset
.a("\n ").fg(RED).a(exception.convertStackTrace.join("\n ")).reset
.a("\n")
)
test.printException(exception, lineNumber, resource)
reportTestsFailed.add(new WTestFailed(test, null, exception, lineNumber, resource))
}

override finished() {
super.finished
printTestsResults(totalTestsRun, totalTestsFailed, totalTestsErrored, overallTimeElapsedInMilliseconds)

val ok = overallProcessWasOK
ok.printSeparator
val STATUS = if (ok) GREEN else RED
println(ansi
.fg(STATUS)
.bold
.a("FINAL REPORT")
.reset
)
if (!ok) {
printTestsFailed
}
println()
printTestsResults(totalTestsRun, totalTestsFailed, totalTestsErrored, overallTimeElapsedInMilliseconds)
println()
ok.printSeparator

resetGroupTestsCount
if (!ok) throw new WollokTestsFailedException
}
Expand Down Expand Up @@ -137,4 +149,60 @@ class WollokConsoleTestsReporter extends DefaultWollokTestsReporter {
)
AnsiConsole.systemUninstall
}

private def printAssertionException(WTest test, AssertionException assertionError, int lineNumber, URI resource) {
println(ansi
.a(" ").fg(YELLOW).a(test.name).a(": ✗ FAILED (").a(test.totalTime).a("ms) => ").reset
.fg(YELLOW).a(assertionError.message).reset
.fg(YELLOW).a(" (").a(resource.trimFragment).a(":").a(lineNumber).a(")").reset
.a("\n ")
.fg(YELLOW).a(assertionError.wollokException?.convertStackTrace.join("\n ")).reset
.a("\n")
)
}

private def printException(WTest test, Exception exception, int lineNumber, URI resource) {
println(ansi.a(" ").fg(RED).a(test.name).a(": ✗ ERRORED (").a(test.totalTime).a("ms) => ").reset
.fg(RED).a(exception.convertToString).reset
.a("\n ").fg(RED).a(exception.convertStackTrace.join("\n ")).reset
.a("\n")
)
}

private def printSeparator(boolean ok) {
val STATUS = if (ok) GREEN else RED
println(ansi
.fg(STATUS)
.bold
.a(FINAL_SEPARATOR)
.a("\n")
.reset
)
}

private def printTestsFailed() {
println(ansi
.fg(RED)
.a("\n")
)
reportTestsFailed.forEach [
if (assertionOrigin) test.printAssertionException(assertionException, lineNumber, resource)
else test.printException(exception, lineNumber, resource)
]
}

}

@Accessors
@Data
class WTestFailed {
WTest test
AssertionException assertionException
Exception exception
int lineNumber
URI resource

def isAssertionOrigin() {
assertionException !== null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class WollokDocParser extends WollokChecker {
}

def String toHtmlFile(String fileName) {
fileName.replace(WollokConstants.CLASS_OBJECTS_EXTENSION, "html")
fileName.replace(WollokConstants.WOLLOK_DEFINITION_EXTENSION, "html")
}

def String libraryName(String fileName) {
Expand Down
Loading

0 comments on commit 2c20c7f

Please sign in to comment.