Skip to content

Commit

Permalink
Merge pull request #1833 from uqbar-project/dev
Browse files Browse the repository at this point in the history
Releasing v1.9.0
  • Loading branch information
fdodino authored Oct 6, 2019
2 parents 6a2d39f + 1a73b4f commit 07ef748
Show file tree
Hide file tree
Showing 80 changed files with 1,749 additions and 405 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.uqbar.project.wollok.launch.messages"; //$NON-NLS-1$

public static String TEST_RESULTS;
public static String ALL_TEST_IN_PROJECT;
public static String ALL_TEST_IN_FOLDER;
public static String LINE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class WollokLauncher extends WollokChecker {

interpreter.interpret(filesToParse.parse(parameters), parameters.folder)
System.exit(0)
} catch (WollokTestsFailedException e) {
throw e
} catch (Exception e) {
System.exit(-1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.uqbar.project.wollok.wollokDsl.WTest
import static extension org.uqbar.project.wollok.errorHandling.WollokExceptionExtensions.*
import static extension org.uqbar.project.wollok.launch.tests.WollokExceptionUtils.*
import static extension org.uqbar.project.wollok.model.WMethodContainerExtensions.*
import static extension org.uqbar.project.wollok.model.WollokModelExtensions.*

/**
*
Expand All @@ -36,39 +35,50 @@ class WollokLauncherInterpreterEvaluator extends WollokInterpreterEvaluator {
if (main !== null)
main.eval
else {
val time = System.currentTimeMillis
val _isASuite = isASuite
var testsToRun = tests
var String suiteName = null
if (_isASuite) {
suiteName = suite.name
testsToRun = suite.tests
}
wollokTestsReporter.testsToRun(suiteName, it, testsToRun)
try {
testsToRun.fold(null) [ a, _test |
resetGlobalState
if (_isASuite) {
_test.evalInSuite(suite)
} else {
_test.eval
}
]
} finally {
wollokTestsReporter.finished(System.currentTimeMillis - time)
}
wollokTestsReporter.started
wollokTestsReporter.folderStarted(null)
runTestFile
wollokTestsReporter.folderFinished
wollokTestsReporter.finished
null
}
}

def void runTestFile(WFile it){
if(!tests.empty){
wollokTestsReporter.testsToRun(null, it, tests)
tests.forEach [ test |
resetGlobalState
test.eval
]
}

suites.forEach [suite |
val testsToRun = suite.tests
val String suiteName = suite.name
wollokTestsReporter.testsToRun(suiteName, it, testsToRun)
testsToRun.forEach [ test |
resetGlobalState
test.evalInSuite(suite)
]
]
}

override evaluateAll(List<EObject> eObjects, String folder) {
wollokTestsReporter.initProcessManyFiles(folder)
val result = eObjects.fold(null, [ o, eObject |
wollokTestsReporter.started
wollokTestsReporter.folderStarted(folder ?: "several-files")

eObjects.forEach [ eObject |
val file = eObject as WFile
wollokTestsReporter.groupStarted(file.toString)
interpreter.initStack
interpreter.generateStack(eObject)
evaluate(eObject as WFile)
])
wollokTestsReporter.endProcessManyFiles
result
interpreter.generateStack(eObject)
file.runTestFile
wollokTestsReporter.groupFinished(file.toString)
]
wollokTestsReporter.folderFinished
wollokTestsReporter.finished
null
}

def WollokObject evalInSuite(WTest test, WSuite suite) {
Expand All @@ -87,6 +97,7 @@ class WollokLauncherInterpreterEvaluator extends WollokInterpreterEvaluator {

override dispatch evaluate(WTest test) {
try {
wollokTestsReporter.testStarted(test)
test.elements.forEach [ expr |
interpreter.performOnStack(expr, currentContext) [ | expr.eval ]
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Unit testing
TEST_RESULTS=Tests results
ALL_TEST_IN_PROJECT=All tests in project
ALL_TEST_IN_FOLDER=All tests in folder {0}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#
# Unit testing
TEST_RESULTS=Resultado de los tests
ALL_TEST_IN_PROJECT=Todos los tests del proyecto
ALL_TEST_IN_FOLDER=Todos los tests de la carpeta {0}

Expand All @@ -24,7 +25,7 @@ WollokLauncherOptions_JSON_TEST_OUTPUT = Reporte de tests con salida en formato
WollokLauncherOptions_DISABLE_COLORS_REPL = Deshabilita colores para la consola
WollokLauncherOptions_SEVERAL_FILES = Permite correr varios archivos a la vez
WollokLauncherOptions_SERVER_PORT = Puerto del server para correr los tests
WollokLauncherOptions_OBJECT_DIAGRAM_PORT = Puerto del server para sincronizar el REPL con el diagrama de objetos
WollokLauncherOptions_DYNAMIC_DIAGRAM_PORT = Puerto del server para sincronizar el REPL con el diagrama de objetos
WollokLauncherOptions_REQUEST_PORT = Puerto para hacer pedidos
WollokLauncherOptions_EVENTS_PORT = Puerto para escuchar eventos
WollokLauncherOptions_SPECIFIC_FOLDER = Definir una carpeta espec\u00EDfica
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,75 @@
package org.uqbar.project.wollok.launch.tests

import java.util.List
import java.util.Map
import org.eclipse.emf.common.util.URI
import org.eclipse.xtend.lib.annotations.Accessors
import org.uqbar.project.wollok.wollokDsl.WFile
import org.uqbar.project.wollok.wollokDsl.WTest
import wollok.lib.AssertionException

/**
* Does nothing (?)
* Default implementation
* Measures performance between tests, a group of tests and overall process
*
* @author tesonep
* @author dodain Adding time elapsed for each test
*/
@Accessors
class DefaultWollokTestsReporter implements WollokTestsReporter {
// Attributes for carrying a folder test run
String folder
boolean processingManyFiles
long folderStartTime
long folderTimeElapsedInMilliseconds

// Total time of group of tests run
long groupStartTime
long groupTimeElapsedInMilliseconds

// Total time of all tests run
long overallStartTime
long overallTimeElapsedInMilliseconds

Map<WTest,TimeDuration> testTimeElapsed = newHashMap

/**
* Global events - starting & finishing the whole execution
*/
override started() {
this.overallStartTime = System.currentTimeMillis
}

override finished() {
overallTimeElapsedInMilliseconds = System.currentTimeMillis - overallStartTime
}

/** starting & finishing execution of a certain folder, a group of files */
override folderStarted(String folder) {
this.processingManyFiles = folder !== null && !folder.equals("")
this.folder = folder
this.folderStartTime = System.currentTimeMillis
}

override folderFinished() {
this.processingManyFiles = false
folderTimeElapsedInMilliseconds = System.currentTimeMillis - this.folderStartTime
}

/** starting & finishing a group of tests */
override groupStarted(String groupName) {
this.groupStartTime = System.currentTimeMillis
}

override groupFinished(String groupName) {
this.groupTimeElapsedInMilliseconds = System.currentTimeMillis - groupStartTime
}

/** starting & finishing execution of a single test */
override testStarted(WTest test) {
testTimeElapsed.put(test, new TimeDuration(System.currentTimeMillis))
}

override reportTestAssertError(WTest test, AssertionException assertionError, int lineNumber, URI resource) {
throw assertionError
}
Expand All @@ -21,20 +78,29 @@ class DefaultWollokTestsReporter implements WollokTestsReporter {

override testsToRun(String suiteName, WFile file, List<WTest> tests) {}

override testStart(WTest test) {}

override reportTestError(WTest test, Exception exception, int lineNumber, URI resource) {
throw exception
}

override finished(long millisecondsElapsed) {

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

override initProcessManyFiles(String folder) {
def getTotalTime(WTest test) {
testTimeElapsed.get(test).totalTime
}
}

@Accessors
class TimeDuration {
long from
long to

override endProcessManyFiles() {
new(long from) {
this.from = from
}

def totalTime() {
to - from
}
}
Loading

0 comments on commit 07ef748

Please sign in to comment.