def test_load_reads_data(self, mock_load_file): proj = CMakeProject('x/proj-a') self.assertEqual(proj.version, '1.41.5') self.assertEqual(proj.name, 'TestProj') mock_load_file.assert_called_with(proj.path, 'CMakeLists.txt')
def from_path(cls, path, steps): repo = git.Repo(path) if os.path.isfile(os.path.join(path, CMakeProject.PROJECT_CONFIG)): proj = CMakeProject(path) return cls(proj, repo, steps) raise UnsupportedProjectException( "'{}' no supported project found".format(path))
def test_parse_project_config_handles_additional_arguments(self): content_ws = 'cmake_minimum_required(VERSION 3.14)\n\n' \ 'project(TestProj DESCRIPTION "text" VERSION {} LANGUAGES CXX C)' with patch('release_tool.cmake._load_file', return_value=content_ws.format('1.18.203')): proj = CMakeProject('abc') self.assertEqual(proj.name, 'TestProj') self.assertEqual(proj.version, '1.18.203')
def test_parse_project_config_handles_whitespaces(self): content_ws = 'cmake_minimum_required(VERSION 3.14)\n\n' \ ' \n \t project (\n\n\t TestProj \n \nVERSION \n {} \n)\n\n' with patch('release_tool.cmake._load_file', return_value=content_ws.format('395.18.20')): proj = CMakeProject('abc') self.assertEqual(proj.name, 'TestProj') self.assertEqual(proj.version, '395.18.20')
def test_parse_project_config_parses_values_multiline( self, _mock_load_file): proj = CMakeProject('abc') self.assertEqual(proj.name, 'project-name-1') self.assertEqual(proj.version, '1.16.7')
def test_parse_project_config_parses_values(self, _mock_load_file): proj = CMakeProject('abc') self.assertEqual(proj.name, 'TestProj') self.assertEqual(proj.version, '1.23.456')
def _mock_load(): with patch('release_tool.cmake._load_file', return_value=CMAKE_CONTENT.format('0.1.2')): proj = CMakeProject('x') return proj