From d9432527414f66c5eaa8d44697ad307f9b37bd66 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 6 Aug 2019 14:51:04 +0200 Subject: [PATCH] Fix shared resource paths in tests Resources shared by tests were incorrectly setup. Resources would always be registered with BASE/filename as alias. In these cases the fix is to set the alias with the original file name. Change-Id: I667ce7b74ae5f86740c8bb8a040cc2895a3dc116 Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 905c2107d78..8a002244ef0 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -133,8 +133,12 @@ def process_qrc_file(target: str, filepath: str, base_dir: str = '', project_fil resource_name = os.path.splitext(os.path.basename(filepath))[0] - base_dir = os.path.join('' if base_dir == '.' else base_dir, os.path.dirname(filepath)) + dir_name = os.path.dirname(filepath) + base_dir = os.path.join('' if base_dir == '.' else base_dir, dir_name) + # Small not very thorough check to see if this a shared qrc resource + # pattern is mostly used by the tests. + is_parent_path = dir_name.startswith('..') if not os.path.isfile(filepath): raise RuntimeError('Invalid file path given to process_qrc_file: {}'.format(filepath)) @@ -159,6 +163,11 @@ def process_qrc_file(target: str, filepath: str, base_dir: str = '', project_fil # Get alias: alias = file.get('alias', '') + # In cases where examples use shared resources, we set the alias + # too the same name of the file, or the applications won't be + # be able to locate the resource + if not alias and is_parent_path: + alias = path files[path] = alias sorted_files = sorted(files.keys())