Skip to content

Commit bec8b1f

Browse files
committed
Simplified/cleaner test output
1 parent af33c51 commit bec8b1f

1 file changed

Lines changed: 43 additions & 18 deletions

File tree

build.gradle

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,61 @@ class Tags {
3333
return block.contains("// {" + marker + "}")
3434
}
3535
private def extract(String marker) {
36-
if(!block.contains("// {" + marker))
36+
if(!block.contains("// {" + marker))
3737
return null
3838
def re = "\\/\\/ \\{" + marker + /[^}]+}/
3939
def tagline = block =~ re
4040
if(tagline.getCount()) {
41-
println lines[0]
4241
def rtrim = tagline[0] - "}"
4342
def ltrim = rtrim - ("// {" + marker)
44-
println ">" + ltrim
45-
return ltrim
43+
return ltrim.trim()
4644
} else {
4745
println "Searching for: " + re
4846
println block
4947
System.exit(1)
5048
}
5149
}
50+
public boolean hasTags() {
51+
return compileTimeError ||
52+
throwsException ||
53+
errorOutputExpected ||
54+
validateByHand ||
55+
ignoreOutput ||
56+
javaCmd ||
57+
args ||
58+
jVMArgs ||
59+
exec ||
60+
runFirst
61+
}
5262
public String toString() {
5363
String result = ""
5464
for(ln in lines)
55-
result += ln + "\n"
56-
result += "mainMethod: " + mainMethod + "\n"
57-
result += "compileTimeError: " + compileTimeError + "\n"
58-
result += "throwsException: " + throwsException + "\n"
59-
result += "errorOutputExpected: " + errorOutputExpected + "\n"
60-
result += "validateByHand: " + validateByHand + "\n"
61-
result += "ignoreOutput: " + ignoreOutput + "\n"
62-
result += "javaCmd: " + javaCmd + "\n"
63-
result += "args: " + args + "\n"
64-
result += "jVMArgs: " + jVMArgs + "\n"
65-
result += "exec: " + exec + "\n"
66-
result += "runFirst: " + runFirst + "\n"
65+
if(ln.startsWith("//") || ln.startsWith("package "))
66+
result += ln + "\n"
67+
else
68+
break
69+
if(mainMethod)
70+
result += "mainMethod: " + mainMethod + "\n"
71+
if(compileTimeError)
72+
result += "compileTimeError: " + compileTimeError + "\n"
73+
if(throwsException)
74+
result += "throwsException: " + throwsException + "\n"
75+
if(errorOutputExpected)
76+
result += "errorOutputExpected: " + errorOutputExpected + "\n"
77+
if(validateByHand)
78+
result += "validateByHand: " + validateByHand + "\n"
79+
if(ignoreOutput)
80+
result += "ignoreOutput: " + ignoreOutput + "\n"
81+
if(javaCmd)
82+
result += "javaCmd: " + javaCmd + "\n"
83+
if(args)
84+
result += "args: " + args + "\n"
85+
if(jVMArgs)
86+
result += "jVMArgs: " + jVMArgs + "\n"
87+
if(exec)
88+
result += "exec: " + exec + "\n"
89+
if(runFirst)
90+
result += "runFirst: " + runFirst + "\n"
6791
return result
6892
}
6993
}
@@ -96,15 +120,16 @@ subprojects {
96120
List lines = it.readLines()
97121

98122
Tags tags = new Tags(lines) // Not used yet; just for demo
99-
println tags
123+
if(tags.hasTags())
124+
println tags
100125

101126
Boolean hasMainMethod = lines.join('').contains('main(String[] args)')
102127
Boolean hasMainParam = lines.find { it.startsWith('// {main: ')}
103128
Boolean willNotCompile = lines.find { it.startsWith('// {CompileTimeError') }
104129
Boolean validateByHand = lines.find { it.startsWith('// {ValidateByHand}') }
105130
Boolean throwsException = lines.find { it.startsWith('// {ThrowsException}') }
106131

107-
// add tasks for java sources with main methods
132+
// Add tasks for java sources with main methods
108133
if ((hasMainMethod || hasMainParam) && (!willNotCompile)) {
109134

110135
String maybeArgsLine = lines.find { it.startsWith('// {Args: ')}

0 commit comments

Comments
 (0)