buildtest: ignore empty folders
`compile_test.py` fails if there are empty folders in `/examples` or `tests`. This is not a problem for Travis, because it always has a clean repo. For the average users there is a problem if they work on multiple branches and one branch has new examples or tests. If they don't delete the residual `bin` folders, then `compile_test.py` will print out these applications as having failed. This change checks for the existence of a `Makefile` in the application folder. Also I added a progress indicator, because I like it. :)
This commit is contained in:
parent
f3a587f43a
commit
bd1630adca
67
dist/tools/compile_test/compile_test.py
vendored
67
dist/tools/compile_test/compile_test.py
vendored
@ -21,49 +21,59 @@ from __future__ import print_function
|
|||||||
|
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from os import devnull, environ, listdir
|
from os import devnull, environ, listdir
|
||||||
from os.path import abspath, dirname, isdir, join
|
from os.path import abspath, dirname, isfile, join
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import CalledProcessError, check_call, PIPE, Popen
|
||||||
from sys import exit, stdout
|
from sys import exit, stdout
|
||||||
|
|
||||||
riotbase = environ.get('RIOTBASE') or abspath(join(dirname(abspath(__file__)), '../' * 3))
|
riotbase = environ.get('RIOTBASE') or abspath(join(dirname(abspath(__file__)), '../' * 3))
|
||||||
|
|
||||||
null = open(devnull, 'w')
|
null = open(devnull, 'w', 0)
|
||||||
|
|
||||||
success = []
|
success = []
|
||||||
failed = []
|
failed = []
|
||||||
exceptions = []
|
exceptions = []
|
||||||
|
|
||||||
for folder in ('examples', 'tests'):
|
def is_tracked(application_folder):
|
||||||
print('Building all applications in: \033[1;34m{}\033[0m'.format(folder))
|
if not isfile(join(application_folder, 'Makefile')):
|
||||||
for application in sorted(listdir(join(riotbase, folder))):
|
return False
|
||||||
if not isdir(join(riotbase, folder, application)):
|
try:
|
||||||
|
check_call(('git', 'ls-files', '--error-unmatch', 'Makefile'),
|
||||||
|
stdin=null, stdout=null, stderr=null, cwd=application_folder)
|
||||||
|
except CalledProcessError:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_lines(readline, prefix):
|
||||||
|
while 1:
|
||||||
|
result = readline()
|
||||||
|
if not result:
|
||||||
|
break
|
||||||
|
elif not result.startswith(prefix):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
stdout.write('\tBuilding application: \033[1;34m{}\033[0m '.format(application))
|
result = result[len(prefix):].rstrip().split(' .. ')[::-1]
|
||||||
|
if len(result) == 2:
|
||||||
|
stdout.write('.')
|
||||||
|
stdout.flush()
|
||||||
|
yield result
|
||||||
|
|
||||||
|
for folder in ('examples', 'tests'):
|
||||||
|
print('Building all applications in: \033[1;34m{}\033[0m'.format(folder))
|
||||||
|
|
||||||
|
applications = listdir(join(riotbase, folder))
|
||||||
|
applications = filter(lambda app: is_tracked(join(riotbase, folder, app)), applications)
|
||||||
|
applications = sorted(applications)
|
||||||
|
|
||||||
|
for nth, application in enumerate(applications, 1):
|
||||||
|
stdout.write('\tBuilding application: \033[1;34m{}\033[0m ({}/{}) '.format(application, nth, len(applications)))
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
try:
|
try:
|
||||||
subprocess = Popen(('make', 'buildtest'),
|
subprocess = Popen(('make', 'buildtest'),
|
||||||
bufsize=1,
|
bufsize=1, stdin=null, stdout=PIPE, stderr=null,
|
||||||
stdin=null,
|
|
||||||
stdout=PIPE,
|
|
||||||
stderr=null,
|
|
||||||
cwd=join(riotbase, folder, application))
|
cwd=join(riotbase, folder, application))
|
||||||
|
|
||||||
def lines(readline, prefix):
|
lines = get_lines(subprocess.stdout.readline, 'Building for ')
|
||||||
while 1:
|
|
||||||
result = readline()
|
|
||||||
if not result:
|
|
||||||
break
|
|
||||||
elif not result.startswith(prefix):
|
|
||||||
continue
|
|
||||||
|
|
||||||
result = result[len(prefix):].rstrip().split(' .. ')[::-1]
|
|
||||||
if len(result) == 2:
|
|
||||||
stdout.write('.')
|
|
||||||
stdout.flush()
|
|
||||||
yield result
|
|
||||||
|
|
||||||
lines = lines(subprocess.stdout.readline, 'Building for ')
|
|
||||||
lines = groupby(sorted(lines), lambda (outcome, board): outcome)
|
lines = groupby(sorted(lines), lambda (outcome, board): outcome)
|
||||||
for group, results in lines:
|
for group, results in lines:
|
||||||
print('\n\t\t{}: {}'.format(group, ', '.join(sorted(board for outcome, board in results))))
|
print('\n\t\t{}: {}'.format(group, ', '.join(sorted(board for outcome, board in results))))
|
||||||
@ -80,7 +90,8 @@ for folder in ('examples', 'tests'):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
print('Outcome:')
|
print('Outcome:')
|
||||||
for color, group, applications in (('2', 'success', success), ('1', 'failed', failed), ('4', 'exceptions', exceptions)):
|
for color, group in (('2', 'success'), ('1', 'failed'), ('4', 'exceptions')):
|
||||||
|
applications = locals()[group]
|
||||||
if applications:
|
if applications:
|
||||||
print('\t\033[1;3{}m{}\033[0m: {}'.format(color, group, ', '.join(applications)))
|
print('\t\033[1;3{}m{}\033[0m: {}'.format(color, group, ', '.join(applications)))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user