-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathrun-all-tests.groovy
More file actions
154 lines (134 loc) · 5.12 KB
/
run-all-tests.groovy
File metadata and controls
154 lines (134 loc) · 5.12 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/env groovy
/**
* run-all-tests.groovy - Automated Test Suite
*
* Executes all test scripts and reports results
* Exit code 0 = all tests passed
* Exit code 1 = one or more tests failed
*/
println """
╔═══════════════════════════════════════════════════════════════════════════╗
║ arc42-generator Test Suite ║
║ Automated Integration Tests ║
╚═══════════════════════════════════════════════════════════════════════════╝
"""
def startTime = System.currentTimeMillis()
// Test configuration
def tests = [
[
name: "Template Generation",
script: "test-templates.groovy",
description: "Tests Golden Master processing, language discovery, and feature removal"
],
[
name: "Template Discovery",
script: "test-discovery.groovy",
description: "Tests template scanning and metadata extraction"
],
[
name: "Format Conversion",
script: "test-converter.groovy",
description: "Tests AsciidoctorJ and Pandoc integration"
]
]
def results = []
def totalTests = tests.size()
def passedTests = 0
def failedTests = 0
// Run each test
tests.eachWithIndex { test, index ->
println "\n[${ index + 1}/${totalTests}] Running: ${test.name}"
println "Description: ${test.description}"
println "Script: ${test.script}"
println "-" * 79
def testStartTime = System.currentTimeMillis()
try {
// Execute test script
def process = ["groovy", test.script].execute()
// Capture output
def output = new StringBuilder()
def error = new StringBuilder()
process.consumeProcessOutput(output, error)
process.waitFor()
def exitCode = process.exitValue()
def testDuration = (System.currentTimeMillis() - testStartTime) / 1000.0
if (exitCode == 0) {
println "✅ PASSED (${String.format('%.1f', testDuration)}s)"
passedTests++
results << [
name: test.name,
status: "PASSED",
duration: testDuration,
exitCode: exitCode,
output: output.toString()
]
} else {
println "❌ FAILED (${String.format('%.1f', testDuration)}s)"
println "\nError Output:"
println error.toString()
failedTests++
results << [
name: test.name,
status: "FAILED",
duration: testDuration,
exitCode: exitCode,
output: output.toString(),
error: error.toString()
]
}
} catch (Exception e) {
def testDuration = (System.currentTimeMillis() - testStartTime) / 1000.0
println "❌ EXCEPTION (${String.format('%.1f', testDuration)}s)"
println "Error: ${e.message}"
e.printStackTrace()
failedTests++
results << [
name: test.name,
status: "EXCEPTION",
duration: testDuration,
exception: e.message
]
}
}
// Print summary
def totalDuration = (System.currentTimeMillis() - startTime) / 1000.0
println """
╔═══════════════════════════════════════════════════════════════════════════╗
║ TEST SUMMARY ║
╚═══════════════════════════════════════════════════════════════════════════╝
"""
println "Total Tests: ${totalTests}"
println "Passed: ${passedTests} ✅"
println "Failed: ${failedTests} ❌"
println "Success Rate: ${String.format('%.1f', (passedTests / totalTests) * 100)}%"
println "Total Time: ${String.format('%.1f', totalDuration)}s"
println ""
// Print detailed results
if (failedTests > 0) {
println "Failed Tests:"
results.findAll { it.status != "PASSED" }.each { result ->
println " ❌ ${result.name}"
if (result.error) {
println " Error: ${result.error.split('\n')[0]}"
}
if (result.exception) {
println " Exception: ${result.exception}"
}
}
println ""
}
// Print test details
println "Test Details:"
results.each { result ->
def icon = result.status == "PASSED" ? "✅" : "❌"
println " ${icon} ${result.name}: ${result.status} (${String.format('%.1f', result.duration)}s)"
}
println ""
// Exit with appropriate code
if (failedTests > 0) {
println "❌ TEST SUITE FAILED"
System.exit(1)
} else {
println "✅ ALL TESTS PASSED"
System.exit(0)
}