Exemple #1
0
 def test_filter_by_all_libraries(self):
     """
     Assert something
     """
     res = Resources(MockNotifier(), collect_ignores=True)
     res._add_labels('TARGET', ['K64F', 'FRDM'])
     for name, loc in SRC_PATHS.items():
         res.add_directory(loc, into_path=name)
     res.filter_by_libraries(res.get_file_refs(FileType.JSON))
     assert ("main.cpp" in res.get_file_names(FileType.CPP_SRC))
     lib_dirs = (dirname(name) or "."
                 for name in res.get_file_names(FileType.JSON))
     assert (not any(dir in res.ignored_dirs for dir in lib_dirs))
Exemple #2
0
 def test_filter_by_bm_lib(self):
     res = Resources(MockNotifier())
     res._add_labels('TARGET', ['K64F', 'FRDM'])
     for name, loc in SRC_PATHS.items():
         res.add_directory(loc, into_path=name)
     filter_by = [
         ref for ref in res.get_file_refs(FileType.JSON)
         if join("platform", "bm", "mbed_lib.json") in ref.name
     ]
     res.filter_by_libraries(filter_by)
     assert ("main.cpp" not in res.get_file_names(FileType.CPP_SRC))
     assert (join("mbed-os", "platform", "bm", "bm.cpp")
             in res.get_file_names(FileType.CPP_SRC))
     assert (join("mbed-os", "TARGET_FRDM", "not-main.cpp")
             in res.get_file_names(FileType.CPP_SRC))
Exemple #3
0
 def test_filter_by_all_libraries(self):
     """
     Assert something
     """
     res = Resources(MockNotifier())
     res._add_labels('TARGET', ['K64F', 'FRDM'])
     for name, loc in SRC_PATHS.items():
         res.add_directory(loc, into_path=name)
     res.filter_by_libraries(res.get_file_refs(FileType.JSON))
     assert ("main.cpp" in res.get_file_names(FileType.CPP_SRC))
Exemple #4
0
 def test_basic_scan(self):
     """
     Verify that the ordering of Target info addition and directory addition
     does not matter, so long as all the Target info and all directories are
     added.
     """
     first = Resources(MockNotifier())
     first._add_labels('TARGET', ['K64F'])
     first._add_labels('TARGET', ['FRDM'])
     for name, loc in SRC_PATHS.items():
         print(name, loc)
         first.add_directory(loc, into_path=name)
     assert ("main.cpp" in first.get_file_names(FileType.CPP_SRC))
Exemple #5
0
 def test_filter_by_bm_lib(self):
     res = Resources(MockNotifier(), collect_ignores=True)
     res._add_labels('TARGET', ['K64F', 'FRDM'])
     for name, loc in SRC_PATHS.items():
         res.add_directory(loc, into_path=name)
     libs = [
         ref for ref in res.get_file_refs(FileType.JSON)
         if basename(ref.name) == MBED_LIB_FILENAME
     ]
     filter_by = [
         ref for ref in libs
         if join("platform", "bm", "mbed_lib.json") in ref.name
     ]
     res.filter_by_libraries(filter_by)
     assert ("main.cpp" not in res.get_file_names(FileType.CPP_SRC))
     assert (join("mbed-os", "platform", "bm", "bm.cpp")
             in res.get_file_names(FileType.CPP_SRC))
     assert (join("mbed-os", "TARGET_FRDM", "not-main.cpp")
             in res.get_file_names(FileType.CPP_SRC))
     inc_names = [dirname(name) or "." for name, _ in filter_by]
     assert (not any(d in res.ignored_dirs for d in inc_names))
     excluded_libs = set(libs) - set(filter_by)
     exc_names = [dirname(name) or "." for name, _ in excluded_libs]
     assert (all(e in res.ignored_dirs for e in exc_names))