Skip to content

Commit

Permalink
Remove buildSrc from gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
LexManos committed Dec 12, 2023
1 parent a27d091 commit d246ce0
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#occupational hazards
/projects/
/repo/
/buildSrc/
/out/
/src/generated-sources/
/logs/
Expand All @@ -31,3 +30,4 @@
/out.log
gradle.properties
/**/logs/
/test_results.html
14 changes: 14 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
id 'groovy'
}

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

dependencies {
implementation 'com.github.Steppschuh:Java-Markdown-Generator:1.3.2'
}
140 changes: 140 additions & 0 deletions buildSrc/src/main/groovy/AggregateTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import groovy.xml.DOMBuilder
import groovy.xml.dom.DOMCategory
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction

abstract class AggregateTest extends DefaultTask {
@InputDirectory
abstract DirectoryProperty getInput()

@OutputFile
abstract RegularFileProperty getOutput()

@TaskAction
void exec() throws IOException {
final javas = [:] as TreeMap
final results = [:] as TreeMap

for (def java : input.asFile.get().listFiles()) {
for (def test : java.listFiles()) {
if (!test.name.startsWith('TEST-') || !test.name.endsWith('.xml'))
continue

def dirName = test.parentFile.name
def (javaName, javaVersion) = dirName.split('-')
javas.computeIfAbsent(javaName, { [] as SortedSet }).add(javaVersion)

def data = DOMBuilder.parse(new StringReader(test.text)).documentElement
use(DOMCategory) {
def suite = data['@name']
suite = suite.substring(suite.lastIndexOf('.') + 1)
def byTest = results.computeIfAbsent(suite, { [:] })
for (def testcase : data.testcase) {
def name = testcase['@name']
if (name.startsWith('repetition '))
continue
def byJava = byTest.computeIfAbsent(name, { [:] })
def byVersion = byJava.computeIfAbsent(javaName, { [:] })
byVersion.put(javaVersion, testcase.failure.isEmpty())
}
}
test.delete()
}
if (java.listFiles().length == 0)
java.deleteDir()
}

def buffer = new StringBuilder()
buffer.append("""
<html>
<style>
.tooltip-text {
visibility: hidden;
position: absolute;
z-index: 1;
width: 100px;
color: white;
font-size: 12px;
background-color: #192733;
border-radius: 10px;
padding: 10px 15px 10px 15px;
top: -40px;
left: -50%;
}
.hover-text:hover .tooltip-text {
visibility: visible;
}
.success {
background-color: #008000;
}
.failure {
background-color: #b60808;
}
.hover-text {
font-size: 16px;
position: relative;
display: inline;
font-family: monospace;
text-align: center;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding-left: 3px;
padding-right: 3px;
}
.result {
font-size: 0px;
}
</style>
<body>
""")
results.forEach{ suite, byTest ->
buffer << "<h1>${suite}</h1>\n"
buffer << "<table>\n"
buffer << " <thead>\n"
buffer << " <th>Test</th>\n"
javas.keySet().forEach{ javaName ->
buffer << " <th>${javaName}</th>\n"
}
buffer << " </thead>\n"
buffer << " <tbody>\n"
byTest.forEach{ testName, byJava ->
buffer << " <tr>\n"
buffer << " <td>${testName}</td>\n"
javas.forEach{ javaName, versions ->
buffer << " <td class=\"result\">\n"
def byVersion = byJava.get(javaName)
versions.forEach { ver ->
if (byVersion.containsKey(ver) && byVersion.get(ver)) {
buffer << " <span class=\"hover-text success\">O<span class=\"tooltip-text success\" id=\"failure\">${javaName} v${ver}</span></span>\n"
} else {
buffer << " <span class=\"hover-text failure\">X<span class=\"tooltip-text failure\">${javaName} v${ver}</span></span>\n"
}
}
buffer << " </td>\n"
}
buffer << " </tr>\n"
}
buffer << " </tbody>\n"
buffer << "</table>\n"

}
buffer << "</body></html>"

output.asFile.get().text = buffer
}
}

0 comments on commit d246ce0

Please sign in to comment.