Skip to content

Commit

Permalink
Merge 3790d23 into 563f6b7
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Jul 2, 2019
2 parents 563f6b7 + 3790d23 commit 75ad49f
Show file tree
Hide file tree
Showing 59 changed files with 367 additions and 161 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ script:
# Moved from before_deploy, because it runs for each deploy, not only once
# I list the used space if there is a problem with the size of the build
- df -h
- du -h -d 4 ..
# Previously it was `du -h -d 4 ..` but since there are no longer any build problems, we use a deep level of 2
- du -h -d 2 ..
# Generating the release
- cd ..
- mkdir results-server
Expand All @@ -38,7 +39,7 @@ script:
- mv org.uqbar.project.wollok.updatesite/target/org.uqbar.project.wollok.updatesite-*.zip results-products/
- mv org.uqbar.project.wollok.updatesite/target/products/*.zip results-products/
- mkdir results-update
- unzip results-products/org.uqbar.project.wollok.updatesite-*.zip -d results-update/
- unzip -q results-products/org.uqbar.project.wollok.updatesite-*.zip -d results-update/
- ls results-server
- ls results-products
- df -h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class Messages extends NLS {
public static String WollokLauncherOptions_JAR_LIBRARIES;
public static String WollokLauncherOptions_WOLLOK_FILES;
public static String WollokLauncherOptions_DONT_VALIDATE;
public static String WollokLauncherOptions_EXIT_ON_BUILD_FAILURE;
public static String WollokLauncherOptions_SAVE_FILE;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import org.eclipse.xtext.validation.IResourceValidator
import org.eclipse.xtext.validation.Issue
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1
import org.uqbar.project.wollok.WollokConstants
import org.uqbar.project.wollok.interpreter.nativeobj.WollokNumbersPreferences
import org.uqbar.project.wollok.launch.setup.WollokLauncherSetup
import org.uqbar.project.wollok.validation.WollokDslValidator
import org.uqbar.project.wollok.wollokDsl.WFile
import org.uqbar.project.wollok.interpreter.nativeobj.WollokNumbersPreferences
import org.uqbar.project.wollok.interpreter.WollokTestsFailedException

/**
* Wollok checker program.
Expand Down Expand Up @@ -59,13 +60,9 @@ class WollokChecker {
}

parameters.parse(args)

this.configureNumberPreferences(parameters)

injector = new WollokLauncherSetup(parameters).createInjectorAndDoEMFRegistration

this.doConfigureParser(parameters)

if (parameters.severalFiles) {
// Tests may run several files
launch(parameters.wollokFiles, parameters)
Expand All @@ -76,6 +73,8 @@ class WollokChecker {
}

log.debug("Program finished")
} catch (WollokTestsFailedException e) {
System.exit(1)
} catch (Throwable t) {
log.error("Checker error : " + t.class.name)
t.stackTrace.forEach [ ste |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.uqbar.project.wollok.debugger.server.out.XTextInterpreterEventPublish
import org.uqbar.project.wollok.debugger.server.rmi.DebuggerCommandHandlerFactory
import org.uqbar.project.wollok.interpreter.WollokInterpreter
import org.uqbar.project.wollok.interpreter.WollokRuntimeException
import org.uqbar.project.wollok.interpreter.WollokTestsFailedException
import org.uqbar.project.wollok.interpreter.api.XDebugger
import org.uqbar.project.wollok.interpreter.listeners.WollokRemoteContextStateListener
import org.uqbar.project.wollok.launch.repl.AnsiColoredReplOutputFormatter
Expand Down Expand Up @@ -67,8 +68,10 @@ class WollokLauncher extends WollokChecker {
new WollokRepl(this, injector, interpreter, mainFile, parsed, formatter).startRepl
}
System.exit(0)
}
catch (Exception e) {
} catch (Exception e) {
if (e instanceof WollokTestsFailedException) {
throw e
}
if (!e.class.simpleName.toUpperCase.startsWith("WOLLOK")) {
val stackTrace = e.stackTrace.map [ "\tat " + className + "." + methodName + " (" + fileName + ":" + lineNumber + ")" ].join("\n")
println("Error in Wollok Launcher => " + e.message + "\n" + stackTrace)
Expand Down Expand Up @@ -136,7 +139,7 @@ class WollokLauncher extends WollokChecker {
}

override blockErrorHandler(WollokLauncherIssueHandler handler, WollokLauncherParameters parameters) {
if (parameters.hasRepl) {
if (parameters.hasRepl || parameters.exitOnBuildFailure) {
return [ handler.finished ; System.exit(-1) ]
}
super.blockErrorHandler(handler, parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class WollokLauncherParameters {
boolean noAnsiFormat = false
boolean severalFiles = false
boolean validate = true
boolean exitOnBuildFailure = false
boolean saveFile = false

Integer numberOfDecimals = null
Expand All @@ -56,6 +57,7 @@ class WollokLauncherParameters {
if (severalFiles) sb.append("-severalFiles ")
sb.appendIfNotNull(folder, "folder")
if (jsonOutput) sb.append("-jsonOutput ")
if (exitOnBuildFailure) sb.append("-exitOnBuildFailure ")
if (noAnsiFormat) sb.append("-noAnsiFormat ")
if (!validate) sb.append("-dontValidate ")
buildNumberPreferences(sb)
Expand Down Expand Up @@ -107,6 +109,7 @@ class WollokLauncherParameters {
eventsPort = parseParameterInt(cmdLine, "eventsPort")

validate = !cmdLine.hasOption("dontValidate")
exitOnBuildFailure = !cmdLine.hasOption("exitOnBuildFailure")
numberOfDecimals = parseParameterInt(cmdLine, "numberOfDecimals", null)
printingStrategy = parseParameterString(cmdLine, "printingStrategy")
coercingStrategy = parseParameterString(cmdLine, "coercingStrategy")
Expand Down Expand Up @@ -200,6 +203,7 @@ class WollokLauncherParameters {
addOption(new Option("noAnsiFormat", Messages.WollokLauncherOptions_DISABLE_COLORS_REPL))
addOption(new Option("severalFiles", Messages.WollokLauncherOptions_SEVERAL_FILES))
addOption(new Option("dontValidate", Messages.WollokLauncherOptions_DONT_VALIDATE))
addOption(new Option("exitOnBuildFailure", Messages.WollokLauncherOptions_EXIT_ON_BUILD_FAILURE))

add("testPort", Messages.WollokLauncherOptions_SERVER_PORT, "port", 1)
add("dynamicDiagramPort", Messages.WollokLauncherOptions_DYNAMIC_DIAGRAM_PORT, "port", 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ WollokLauncherOptions_DECIMAL_CONVERSION_STRATEGY = Strategy to use when convert
WollokLauncherOptions_JAR_LIBRARIES = Extra JAR libraries
WollokLauncherOptions_WOLLOK_FILES = Wollok files
WollokLauncherOptions_DONT_VALIDATE = Avoid running Wollok validator, just execute program.
WollokLauncherOptions_SAVE_FILE=Save formatter result in the same file
WollokLauncherOptions_EXIT_ON_BUILD_FAILURE = Avoid running the file if build error occurs.
WollokLauncherOptions_SAVE_FILE=Save formatter result in the same file
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ WollokLauncherOptions_DECIMAL_CONVERSION_STRATEGY = Criterio a usar para convert
WollokLauncherOptions_JAR_LIBRARIES = Librer\u00EDas JAR extras
WollokLauncherOptions_WOLLOK_FILES = Archivos Wollok a ejecutar
WollokLauncherOptions_DONT_VALIDATE = Ejecutar el programa sin utilizar el validador de Wollok
WollokLauncherOptions_SAVE_FILE=Grabar el resultado del formateo en el mismo archivo
WollokLauncherOptions_EXIT_ON_BUILD_FAILURE = Validar el archivo y no ejecutarlo en caso de encontrar errores
WollokLauncherOptions_SAVE_FILE=Grabar el resultado del formateo en el mismo archivo
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class WollokLauncherModule extends WollokDslRuntimeModule {
else
return WollokLauncherInterpreterEvaluator
}

override libs() {
params.libraries
}
Expand All @@ -50,12 +50,12 @@ class WollokLauncherModule extends WollokDslRuntimeModule {
if (params.tests) {
if (params.testPort !== null && params.testPort != 0)
return WollokRemoteTestReporter
else if (params.jsonOutput)
if (params.jsonOutput)
return WollokJSONTestsReporter
else
return WollokConsoleTestsReporter
} else
return WollokConsoleTestsReporter
} else {
return DefaultWollokTestsReporter
}
}

def Class<? extends WollokLauncherIssueHandler> bindWollokLauncherIssueHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@ class WollokLauncherSetup extends WollokDslStandaloneSetup {
}

}


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

import java.util.List
import org.eclipse.emf.common.util.URI
import org.fusesource.jansi.AnsiConsole
import org.uqbar.project.wollok.interpreter.WollokTestsFailedException
import org.uqbar.project.wollok.wollokDsl.WFile
import org.uqbar.project.wollok.wollokDsl.WTest
import wollok.lib.AssertionException

import static org.fusesource.jansi.Ansi.*
import static org.fusesource.jansi.Ansi.Color.*

import static extension org.uqbar.project.wollok.errorHandling.WollokExceptionExtensions.*

/**
* Logs the events to the console output.
* Used when running the tests from console without a remote client program (RMI)
* like eclipse UI.
*
* @author tesonep
* @author dodain
*
*/
class WollokConsoleTestsReporter implements WollokTestsReporter {

override reportTestAssertError(WTest test, AssertionException assertionError, int lineNumber, URI resource) {
println('''Test: «test.name» : «assertionError.message» («resource.trimFragment»:«lineNumber»)''')
}

override reportTestOk(WTest test) {
println('''Test: «test.name» : Ok''')
}

int testsFailed = 0
int testsErrored = 0
int totalTests = 0

override testsToRun(String suiteName, WFile file, List<WTest> tests) {
println('''Suite: «suiteName»''')
AnsiConsole.systemInstall
totalTests = tests.size
if (suiteName ?: '' !== '') {
println('''Running all tests from suite «suiteName»''')
} else {
println('''Running «totalTests» tests...''')
}
resetTestsCount
}

override testStart(WTest test) {}

override reportTestAssertError(WTest test, AssertionException assertionError, int lineNumber, URI resource) {
incrementTestsFailed
println(ansi
.a(" ").fg(YELLOW).a(test.name).a(": ✗ FAILED => ").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")
)
}

override reportTestOk(WTest test) {
println(ansi.a(" ").fg(GREEN).a(test.name).a(": √ (Ok)").reset)
}

override reportTestError(WTest test, Exception exception, int lineNumber, URI resource) {
println('''Test: «test.name» : «exception.message» («resource.trimFragment»:«lineNumber»)''')
incrementTestsErrored
println(ansi.a(" ").fg(RED).a(test.name).a(": ✗ ERRORED => ").reset
.fg(RED).a(exception.convertToString).reset
.a("\n ").fg(RED).a(exception.convertStackTrace.join("\n ")).reset
.a("\n")
)
}

override finished() {
val STATUS = if (processWasOK) GREEN else RED
println(ansi
.fg(STATUS)
.bold
.a(totalTests).a(" tests, ")
.a(testsFailed).a(if (testsFailed == 1) " failure and " else " failures and ")
.a(testsErrored).a(if (testsErrored == 1) " error" else " errors")
.a("\n")
.reset
)
AnsiConsole.systemUninstall
if (!processWasOK) {
throw new WollokTestsFailedException
}
}

override initProcessManyFiles(String folder) {
override initProcessManyFiles(String folder) {}

override endProcessManyFiles() {}

def resetTestsCount() {
testsFailed = 0
testsErrored = 0
}

override endProcessManyFiles() {
def incrementTestsFailed() {
testsFailed++
}

def incrementTestsErrored() {
testsErrored++
}

def processWasOK() {
testsFailed + testsErrored === 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,4 @@ class WollokResultTestDTO implements Serializable {
]
}

def getStackTraceFiltered() {
stackTrace.filter [ it.contextDescription !== null ].toList
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ class WCollection<T extends Collection<WollokObject>> {
hasNativeType(this.class.name)
}

protected def getNativeCollection(WollokObject it) {
protected def Collection<?> getNativeCollection(WollokObject it) {
getNativeObject(this.class).getWrapped()
}

protected def verifySizes(Collection col, Collection col2) {
protected def verifySizes(Collection<?> col, Collection<?> col2) {
col.size.equals(col2.size)
}

protected def verifyWollokElementsContained(Collection set, Collection set2) { false } // Abstract method
protected def verifyWollokElementsContained(Collection<?> set, Collection<?> set2) { false } // Abstract method
}
2 changes: 1 addition & 1 deletion org.uqbar.project.wollok.lib/src/wollok/lang/WDate.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class WDate extends AbstractJavaWrapper<LocalDate> {

@NativeMessage("==")
def wollokEquals(WollokObject other) {
other.hasNativeType(this.class.name) && (other.getNativeObject(this.class).wrapped?.equals(this.wrapped))
other.hasNativeType(this.class.name) && (other.getNativeObject(this.class).wrapped.equals(this.wrapped))
}

@NativeMessage("-")
Expand Down
1 change: 0 additions & 1 deletion org.uqbar.project.wollok.lib/src/wollok/lang/WNumber.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package wollok.lang

import java.math.BigDecimal
import java.math.BigInteger
import java.math.MathContext
import java.math.RoundingMode
import org.eclipse.osgi.util.NLS
import org.uqbar.project.wollok.Messages
Expand Down
2 changes: 2 additions & 0 deletions org.uqbar.project.wollok.releng/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-Xlint:none</compilerArgument>
</configuration>
</plugin>

Expand Down Expand Up @@ -401,6 +402,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.11.2</version>
<executions>
<execution>
<id>add-changelog-to-git</id>
Expand Down
8 changes: 4 additions & 4 deletions org.uqbar.project.wollok.tests/src/log4j-normal.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
log4j.rootLogger=INFO, stdout
log4j.rootLogger=WARN, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.logger.org.uqbar=INFO, stdout
log4j.logger.org.eclipse=INFO, stdout
log4j.logger.org.uqbar.project.wollok.typesystem=DEBUG, stdout
log4j.logger.org.uqbar=WARN, stdout
log4j.logger.org.eclipse=WARN, stdout
log4j.logger.org.uqbar.project.wollok.typesystem=WARN, stdout

log4j.additivity.org.uqbar=false
log4j.additivity.org.eclipse=false
Expand Down
8 changes: 4 additions & 4 deletions org.uqbar.project.wollok.tests/src/log4j-travis.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
log4j.rootLogger=INFO, stdout, general
log4j.rootLogger=WARN, stdout, general

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
Expand All @@ -19,9 +19,9 @@ log4j.appender.general.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.general.Threshold=DEBUG


log4j.logger.org.uqbar=DEBUG, stdout, general
log4j.logger.org.uqbar.project.wollok.typesystem=DEBUG, stdout, general, ts
log4j.logger.org.eclipse=INFO, stdout, general
log4j.logger.org.uqbar=WARN, stdout, general
log4j.logger.org.uqbar.project.wollok.typesystem=WARN, stdout, general, ts
log4j.logger.org.eclipse=WARN, stdout, general

log4j.additivity.org.uqbar=false
log4j.additivity.org.eclipse=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AssertTestCase extends AbstractWollokInterpreterTestCase {
@Test(expected = ComparisonFailure)
def void assertIsTranslatedToComparisonFailure(){
'''
assert.equals(1,"hola")
assert.equals(1, "hola")
'''.test
}

Expand Down
Loading

0 comments on commit 75ad49f

Please sign in to comment.