backend/tests: Use IGNORE_BACKEND directive to exclude java-dependent tests

This commit is contained in:
Ilya Matveev
2017-01-19 12:40:58 +03:00
parent d24f966600
commit 89a74c0591
@@ -48,6 +48,7 @@ abstract class KonanTest extends DefaultTask {
*filesToCompile, *filesToCompile,
*moreArgs, *moreArgs,
*project.globalArgs) *project.globalArgs)
} }
} }
@@ -73,6 +74,7 @@ abstract class KonanTest extends DefaultTask {
println "execution :$exe" println "execution :$exe"
def out = null def out = null
//TODO Add test timeout
project.exec { project.exec {
commandLine exe commandLine exe
if (arguments != null) { if (arguments != null) {
@@ -85,6 +87,7 @@ abstract class KonanTest extends DefaultTask {
out = new ByteArrayOutputStream() out = new ByteArrayOutputStream()
standardOutput = out standardOutput = out
} }
} }
if (goldValue != null && goldValue != out.toString()) if (goldValue != null && goldValue != out.toString())
throw new RuntimeException("test failed.") throw new RuntimeException("test failed.")
@@ -117,8 +120,12 @@ class LinkKonanTest extends KonanTest {
} }
} }
class RunExternalTest extends RunKonanTest { @ParallelizableTask
class RunExternalTestGroup extends RunKonanTest {
def groupDirectory = "."
def logFileName = "test-result.md"
String filter = project.findProperty("filter")
String goldValue = "OK" String goldValue = "OK"
String buildExePath() { String buildExePath() {
@@ -183,13 +190,35 @@ class RunExternalTest extends RunKonanTest {
void createFile(String file, String text) { void createFile(String file, String text) {
project.file(file).write(text) project.file(file).write(text)
} }
}
@ParallelizableTask List<String> findLinesWithPrefixesRemoved(String text, String prefix) {
class RunExternalTestGroup extends RunExternalTest { def result = []
def groupDirectory = "." text.eachLine {
def logFileName = "test-result.md" if (it.startsWith(prefix)) {
String filter = project.findProperty("filter") result.add(it - prefix)
}
}
return result
}
boolean isEnabledForNativeBackend(String fileName) {
def text = project.file(fileName).text
def targetBackend = findLinesWithPrefixesRemoved(text, "// TARGET_BACKEND")
if (targetBackend.size() != 0) {
// There is some target backend. Check if it is NATIVE or not
for (String s : targetBackend) {
if (s.contains("NATIVE")){ return true }
}
return false
} else {
// No target backend. Check if NATIVE backend is ignored
def ignoredBackends = findLinesWithPrefixesRemoved(text, "// IGNORE_BACKEND: ")
for (String s : ignoredBackends) {
if (s.contains("NATIVE")) { return false }
}
return true
}
}
@TaskAction @TaskAction
@Override @Override
@@ -210,21 +239,29 @@ class RunExternalTestGroup extends RunExternalTest {
} }
def current = 0 def current = 0
def passed = 0 def passed = 0
def skipped = 0
def total = ktFiles.size() def total = ktFiles.size()
def status = null
def comment = null
ktFiles.each { ktFiles.each {
current++
source = project.relativePath(it) source = project.relativePath(it)
println("TEST: $it.name (${++current}/$total, passed: $passed)") println("TEST: $it.name ($current/$total, passed: $passed, skipped: $skipped)")
try { if (isEnabledForNativeBackend(source)) {
super.executeTest() try {
logFile.append("\n|$it.name|PASSED||") super.executeTest()
println("TEST PASSED\n") status = "PASSED"; comment = ""
passed++ passed++
} catch (Exception ex) { } catch (Exception ex) {
println("TEST FAILED\n") status = "FAILED"; comment = "Exception: ${ex.getMessage()}. Cause: ${ex.getCause()?.getMessage()}"
logFile.append("\n|$it.name|FAILED|${ex.getMessage()}. Cause: ${ex.getCause()?.getMessage()}|") }
} else {
status = "SKIPPED"; comment = ""
skipped++
} }
println("TEST $status\n")
logFile.append("\n|$it.name|$status|$comment|")
} }
print("TOTAL PASSED: $passed/$total") print("TOTAL PASSED: $passed/$current (SKIPPED: $skipped)")
} }
} }