Skip to content

Commit 4495766

Browse files
committed
Pretty messages in the build-site script.
1 parent c075a69 commit 4495766

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

software/util/buildsite.py

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@
2929
import subprocess
3030
import textutils
3131
import time
32+
import shutil
3233

3334
import rdflib
3435
import jinja2
3536
import fileutils
37+
import runtests
38+
import buildtermpages
39+
import buildocspages
3640

3741
from sdotermsource import SdoTermSource
3842
from sdocollaborators import collaborator
@@ -102,19 +106,38 @@ def clear():
102106
for d in dirs:
103107
shutil.rmtree(os.path.join(root, d))
104108

109+
def StartMessage(message):
110+
column, lines = shutil.get_terminal_size()
111+
print('▼' * column)
112+
print(message)
113+
return time.time()
114+
115+
def EndMessage(message='Done', timestamp=None):
116+
column, lines = shutil.get_terminal_size()
117+
if timestamp:
118+
elapsed = time.time() - timestamp
119+
message = '%s in %s seconds' % (message, elapsed)
120+
print(message)
121+
print('▲' * column)
122+
123+
105124
###################################################
106125
#RUN TESTS
107126
###################################################
108-
def runtests():
109-
import runtests
110-
if args.runtests or args.autobuild:
111-
print('Running test scripts before proceeding...\n')
112-
errorcount = runtests.main('./software/tests/')
113-
if errorcount:
114-
print('Errors returned: %d' % errorcount)
115-
sys.exit(errorcount)
116-
else:
117-
print('Tests successful!\n')
127+
def run_all_unit_tests():
128+
"""Run all unit-tests"""
129+
130+
if not args.runtests and not args.autobuild:
131+
return
132+
start = StartMessage("Running test scripts before proceeding..")
133+
errorcount = runtests.main('./software/tests/')
134+
EndMessage(timestamp=start)
135+
if errorcount:
136+
print('%d test failures' % errorcount)
137+
sys.exit(errorcount)
138+
else:
139+
print('All tests successful!\n')
140+
118141

119142
DOCSDOCSDIR = '/docs'
120143
TERMDOCSDIR = '/docs'
@@ -131,7 +154,7 @@ def runtests():
131154
HANDLER_FILE = 'handlers.yaml'
132155

133156
def initdir():
134-
print('Building site in "%s" directory' % OUTPUTDIR)
157+
start = StartMessage('Building site in "%s" directory' % OUTPUTDIR)
135158
fileutils.createMissingDir(OUTPUTDIR)
136159
clear()
137160
fileutils.createMissingDir(os.path.join(OUTPUTDIR, 'docs'))
@@ -258,7 +281,6 @@ def checkFilePath(path):
258281
#BUILD INDIVIDUAL TERM PAGES
259282
###################################################
260283
def processTerms():
261-
import buildtermpages
262284
global TERMS
263285
if len(TERMS):
264286
print('Building term definition pages\n')
@@ -271,7 +293,7 @@ def processTerms():
271293
###################################################
272294
def processDocs():
273295
global PAGES
274-
import buildocspages
296+
275297
if len(PAGES):
276298
print('Building dynamic documentation pages\n')
277299
loadTerms()
@@ -336,7 +358,7 @@ def copyReleaseFiles():
336358
subprocess.check_call(cmd)
337359
print()
338360
initdir()
339-
runtests()
361+
run_all_unit_tests()
340362
processTerms()
341363
processDocs()
342364
processFiles()

0 commit comments

Comments
 (0)