-
Notifications
You must be signed in to change notification settings - Fork 4
/
tests.gradle
115 lines (104 loc) · 4.01 KB
/
tests.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import de.itemis.mps.gradle.TestLanguages
buildscript {
repositories {
maven { url 'https://projects.itemis.de/nexus/content/repositories/mbeddr' }
mavenCentral()
mavenLocal()
jcenter()
}
dependencies {
classpath 'de.itemis.mps:mps-gradle-plugin:1.0.85.03fbeda'
}
}
def examineTestFile(file) {
def testsResult = new XmlParser().parse(file)
def errors = testsResult.attributes()["errors"] as Integer
def failures = testsResult.attributes()["failures"] as Integer
def tests = testsResult.attributes()["tests"] as Integer
def skipped = testsResult.attributes()["skipped"] as Integer
def successes = tests - skipped - failures - errors
testsResult.get("testcase").each { tc ->
if (tc.get("failure").size() > 0) {
println("[FAILED TEST]")
println(" classname: " + tc.attributes()["classname"])
println(" name: " + tc.attributes()["name"])
println(" message: " + tc.get("failure").get(0).attributes()["message"])
println()
} else if (tc.get("error").size() > 0) {
println("[FAILED TEST]")
println(" classname: " + tc.attributes()["classname"])
println(" name: " + tc.attributes()["name"])
println(" message: " + tc.get("error").get(0).attributes()["message"])
println()
}
}
println("Tests : $tests")
println("Skipped : $skipped")
println("Failures : $failures")
println("Successes : $successes")
println("Errors : $errors")
println()
if (failures > 0 || errors > 0) {
println("Check tests: FAILURE")
throw new GradleException("Not all tests were run successfully")
} else {
println("Check tests: SUCCESS")
}
}
task runLanguageTests(type: TestLanguages, dependsOn: [buildCore, buildExamples]) {
doFirst {
def antTestScriptFile = file(it['script'])
antTestScriptFile.text = antTestScriptFile.text.replace("-Xmx1024m", "-Xmx2048m")
antTestScriptFile.text = antTestScriptFile.text
.replace('<jvmarg value="-ea" />',
'<jvmarg value="-ea" /><jvmarg value="-Djava.awt.headless=true" />')
}
scriptArgs = antScriptArgs
scriptClasspath = buildScriptClasspath
script new File('mpscode/build-tests.xml')
}
task justCheckLanguageTests() {
doLast {
examineTestFile("mpscode/TEST-jetbrains.mps.testbench.junit.suites.AntModuleTestSuite0-mpsserver.tests.xml")
}
}
task checkLanguageTests() {
dependsOn 'runLanguageTests'
dependsOn 'justCheckLanguageTests'
tasks.findByName('justCheckLanguageTests').mustRunAfter 'runLanguageTests'
}
task prepareFunctionalTests(dependsOn:[packageExtensionKit, packageBuild]) {
doLast {
def extensionkitDir = new File(mpscode, 'build/artifacts/mpsserver-extensionkit')
def buildPluginDir = new File(mpscode, 'build/artifacts/mpsserver-build')
def exampleProjectDir = new File(rootDir, "functional_tests/mps_example_project_withextension")
def exampleProjectArtifactsDir = new File(rootDir, "functional_tests/mps_example_project_withextension/artifacts")
println("[extension kit plugin]")
fileTree(extensionkitDir).visit { FileVisitDetails details ->
println(" * ${details.file.path}")
}
println()
println("[build plugin]")
fileTree(buildPluginDir).visit { FileVisitDetails details ->
println(" * ${details.file.path}")
}
println()
copy {
from {
extensionkitDir
}
into exampleProjectArtifactsDir
}
copy {
from {
buildPluginDir
}
into exampleProjectArtifactsDir
}
println("[exampleProjectDir]")
fileTree(exampleProjectDir).visit { FileVisitDetails details ->
println(" * ${details.file.path}")
}
println()
}
}