Skip to content

Commit

Permalink
Merge pull request #29 from pimoroni/patch-cmake-depends
Browse files Browse the repository at this point in the history
Add test for and fix #28
  • Loading branch information
Gadgetoid committed Oct 3, 2020
2 parents 85bec11 + 4091cdd commit d8af524
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/tests/test_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ def test_empty_metadata_file():
return temp_yml


@pytest.fixture
def test_asset_config_file():
temp_yml = tempfile.NamedTemporaryFile('w', suffix='.yml')
temp_yml.write(f'''assets.cpp:
assets/buttons.png: asset_buttons
''')
temp_yml.flush()
return temp_yml



@pytest.fixture
def test_cmake_file():
temp_cmake = tempfile.NamedTemporaryFile('wb', suffix='.cmake')
Expand All @@ -52,6 +63,21 @@ def test_cmake_no_args(parsers):
parser.parse_args(['cmake'])


def test_cmake_asset(parsers, test_asset_config_file, test_cmake_file):
from ttblit.tool import cmake

parser, subparser = parsers

cmake = cmake.CMake(subparser)

args = parser.parse_args([
'cmake',
'--config', test_asset_config_file.name,
'--cmake', test_cmake_file.name])

cmake.run(args)


def test_cmake(parsers, test_metadata_file, test_cmake_file):
from ttblit.tool import cmake

Expand Down
5 changes: 5 additions & 0 deletions src/ttblit/tool/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def run_for_asset_config(self, args):
options.pop(key, None)

for file_glob, file_options in options.items():
# Rewrite a single string option to `name: option`
# This handles: `inputfile.bin: filename` entries
if type(file_options) is str:
file_options = {'name': file_options}

input_files = []
# Parse the options for any references to input files
for key, value in file_options.items():
Expand Down

0 comments on commit d8af524

Please sign in to comment.