Added "gradlew verify"
This commit is contained in:
parent
d6e63d4265
commit
873637cf1d
@ -184,3 +184,8 @@ configure(subprojects - project(':onjava')) {
|
||||
compile project(':onjava')
|
||||
}
|
||||
}
|
||||
|
||||
task verify(type:Exec) {
|
||||
println("execute 'gradlew run' first")
|
||||
commandLine 'python', 'test_output.py'
|
||||
}
|
||||
|
2
gradle.properties
Normal file
2
gradle.properties
Normal file
@ -0,0 +1,2 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.parallel=true
|
46
phase1.py
46
phase1.py
@ -1,46 +0,0 @@
|
||||
#! py -3
|
||||
# Requires Python 3.5
|
||||
# Phase1:
|
||||
# (0) Do first/last lines before formatting to width
|
||||
# (1) Combine output and error (if present) files
|
||||
# (2) Format all output to width limit
|
||||
# (3) Add closing '*/'
|
||||
from pathlib import Path
|
||||
import textwrap
|
||||
import pprint
|
||||
|
||||
def fill_to_width(text):
|
||||
result = ""
|
||||
for line in text.splitlines():
|
||||
result += textwrap.fill(line, width=59) + "\n"
|
||||
return result.strip()
|
||||
|
||||
def adjust_lines(text):
|
||||
text = text.replace("\0", "NUL")
|
||||
lines = text.splitlines()
|
||||
slug = lines[0]
|
||||
if "(First and Last " in slug:
|
||||
num_of_lines = int(slug.split()[5])
|
||||
adjusted = lines[:num_of_lines + 1] +\
|
||||
["...________...________...________...________..."] +\
|
||||
lines[-num_of_lines:]
|
||||
return "\n".join(adjusted)
|
||||
elif "(First " in slug:
|
||||
num_of_lines = int(slug.split()[3])
|
||||
adjusted = lines[:num_of_lines + 1] +\
|
||||
[" ..."]
|
||||
return "\n".join(adjusted)
|
||||
else:
|
||||
return text
|
||||
|
||||
if __name__ == '__main__':
|
||||
for outfile in Path(".").rglob("*.out"):
|
||||
out_text = adjust_lines(outfile.read_text())
|
||||
phase_1 = outfile.with_suffix(".p1")
|
||||
with phase_1.open('w') as phs1:
|
||||
phs1.write(fill_to_width(out_text) + "\n")
|
||||
errfile = outfile.with_suffix(".err")
|
||||
if errfile.exists():
|
||||
phs1.write("___[ Error Output ]___\n")
|
||||
phs1.write(fill_to_width(errfile.read_text()) + "\n")
|
||||
phs1.write("*/\n")
|
@ -5,10 +5,53 @@
|
||||
# (2) If direct comparison of actual output with output stored in Java file fails:
|
||||
# (3) Use chain of responsibility to successively try filters until one matches or all fail
|
||||
from pathlib import Path
|
||||
import textwrap
|
||||
import re
|
||||
|
||||
def fill_to_width(text):
|
||||
result = ""
|
||||
for line in text.splitlines():
|
||||
result += textwrap.fill(line, width=59) + "\n"
|
||||
return result.strip()
|
||||
|
||||
def adjust_lines(text):
|
||||
text = text.replace("\0", "NUL")
|
||||
lines = text.splitlines()
|
||||
slug = lines[0]
|
||||
if "(First and Last " in slug:
|
||||
num_of_lines = int(slug.split()[5])
|
||||
adjusted = lines[:num_of_lines + 1] +\
|
||||
["...________...________...________...________..."] +\
|
||||
lines[-num_of_lines:]
|
||||
return "\n".join(adjusted)
|
||||
elif "(First " in slug:
|
||||
num_of_lines = int(slug.split()[3])
|
||||
adjusted = lines[:num_of_lines + 1] +\
|
||||
[" ..."]
|
||||
return "\n".join(adjusted)
|
||||
else:
|
||||
return text
|
||||
|
||||
def phase1():
|
||||
"""
|
||||
(0) Do first/last lines before formatting to width
|
||||
(1) Combine output and error (if present) files
|
||||
(2) Format all output to width limit
|
||||
(3) Add closing '*/'
|
||||
"""
|
||||
for outfile in Path(".").rglob("*.out"):
|
||||
out_text = adjust_lines(outfile.read_text())
|
||||
phase_1 = outfile.with_suffix(".p1")
|
||||
with phase_1.open('w') as phs1:
|
||||
phs1.write(fill_to_width(out_text) + "\n")
|
||||
errfile = outfile.with_suffix(".err")
|
||||
if errfile.exists():
|
||||
phs1.write("___[ Error Output ]___\n")
|
||||
phs1.write(fill_to_width(errfile.read_text()) + "\n")
|
||||
phs1.write("*/\n")
|
||||
|
||||
if __name__ == '__main__':
|
||||
phase1()
|
||||
find_output = re.compile(r"/\* (Output:.*)\*/", re.DOTALL) # should space be \s+ ??
|
||||
for outfile in Path(".").rglob("*.p1"):
|
||||
javafile = outfile.with_suffix(".java")
|
||||
|
Loading…
x
Reference in New Issue
Block a user