Skip to content

Commit

Permalink
Implemented compilation test
Browse files Browse the repository at this point in the history
Which actually fails on at least one MCU, interesting...

This won't impact Travis however, because the compilation test is not
yet activated in the Travis configuration.
  • Loading branch information
amosnier committed May 10, 2020
1 parent 17efe31 commit 92bd339
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
__pycache__
generated/
build/
13 changes: 13 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import os
import ecg
import sys
import argparse


def main():
parser = argparse.ArgumentParser(description='Test ecg.')
parser.add_argument('-c', '--compiler', help='C++ header file name')
args = parser.parse_args()
compiler = args.compiler
os.makedirs('build', exist_ok=True)
num_files = 0
for subdir, dirs, files in os.walk('svd'):
for in_file in files:
Expand All @@ -14,6 +20,13 @@ def main():
try:
full_out_path = os.path.join(out_dir, 'mcu.h')
ecg.generate_code(full_in_path, full_out_path, 'mcu_support')
if compiler:
compile_string = '{} -std=c++17 -o {} -c test.cpp -I {}'
object_file = os.path.join('build', 'test.o')
command = compile_string.format(compiler, object_file, out_dir)
print('Running: {}'.format(command))
assert not os.system(command)
print('Compilation successful\n')
num_files += 1
except Exception:
sys.stderr.write('--- Caught exception while parsing {} ---\n'.format(full_in_path))
Expand Down

0 comments on commit 92bd339

Please sign in to comment.