def test_parse_cmake_pkg_check_modules_variables(self): """ Test parse_cmake to ensure accurate handling of versioned pkgconfig modules with variable version strings. """ content = 'pkg_check_modules(AVCODEC libavcodec${_avcodec_ver} libavutil$_avutil_ver)' with tempfile.TemporaryDirectory() as tmpd: with open(os.path.join(tmpd, 'fname'), 'w') as f: f.write(content) buildreq.parse_cmake(os.path.join(tmpd, 'fname')) self.assertEqual(buildreq.buildreqs, set(['pkgconfig(libavcodec)', 'pkgconfig(libavutil)']))
def test_parse_cmake_pkg_check_modules_whitespace(self): """ Test parse_cmake to ensure accurate handling of versioned pkgconfig modules with whitespace. """ content = 'pkg_check_modules(GLIB gio-unix-2.0 >= 2.46.0 glib-2.0 REQUIRED)' with tempfile.TemporaryDirectory() as tmpd: with open(os.path.join(tmpd, 'fname'), 'w') as f: f.write(content) buildreq.parse_cmake(os.path.join(tmpd, 'fname')) self.assertEqual(buildreq.buildreqs, set(['pkgconfig(gio-unix-2.0)', 'pkgconfig(glib-2.0)']))
def test_parse_cmake_pkg_check_modules_in_a_comment(self): """ Test parse_cmake to ensure it ignores pkg_check_modules in comments. """ content = ''' # For example, consider the following patch to some CMakeLists.txt. # - pkg_check_modules(FOO REQUIRED foo>=1.0) # + pkg_check_modules(FOO REQUIRED foo>=2.0) ''' with tempfile.TemporaryDirectory() as tmpd: with open(os.path.join(tmpd, 'fname'), 'w') as f: f.write(content) buildreq.parse_cmake(os.path.join(tmpd, 'fname')) self.assertEqual(buildreq.buildreqs, set([]))
def test_parse_cmake_find_package(self): """ Test parse_cmake to ensure accurate handling of find_package. """ buildreq.config.cmake_modules = { "valid": "valid", "valid_but_commented": "valid_but_commented", "different_name": "another_name", } content = ''' find_package(valid) #find_package(foo) # find_package(valid_but_commented) find_package(different_name) ''' with tempfile.TemporaryDirectory() as tmpd: with open(os.path.join(tmpd, 'fname'), 'w') as f: f.write(content) buildreq.parse_cmake(os.path.join(tmpd, 'fname')) self.assertEqual(buildreq.buildreqs, set(['valid', 'another_name']))