def test_update_project_dev_version_when_succeeded_by_another_set(self): test_cmake_lists = """ cmake_minimum_required(VERSION 3.1) project(hello_world VERSION 41.41.41) set(PROJECT_DEV_VERSION 1) add_executable(app main.c) """ under_test = CMakeVersionParser(test_cmake_lists) self.assertEqual(under_test._project_dev_version_line_number, 4) self.assertEqual(under_test._project_dev_version, '1') result = under_test.update_version('41.41.41', develop=False) self.assertEqual(under_test._project_dev_version, '0') self.assertEqual( result, test_cmake_lists.replace('PROJECT_DEV_VERSION 1', 'PROJECT_DEV_VERSION 0'), )
def test_update_project_dev_version(self): test_cmake_lists = """ project( DESCRIPTION something VERSION 41.41.41 LANGUAGES c ) set( PROJECT_DEV_VERSION 1 ) """ under_test = CMakeVersionParser(test_cmake_lists) self.assertEqual(under_test._project_dev_version_line_number, 7) self.assertEqual(under_test._project_dev_version, '1') result = under_test.update_version('41.41.41', develop=False) self.assertEqual(under_test._project_dev_version, '0') self.assertEqual( result, test_cmake_lists.replace('PROJECT_DEV_VERSION 1', 'PROJECT_DEV_VERSION 0'), )
def test_find_project_dev_version(self): test_cmake_lists = """ project( DESCRIPTION something VERSION 41.41.41 LANGUAGES c ) set( PROJECT_DEV_VERSION 1 ) """ under_test = CMakeVersionParser(test_cmake_lists) self.assertEqual(under_test._project_dev_version_line_number, 7) self.assertEqual(under_test._project_dev_version, '1')
def test_raise_exception_project_no_version(self): with self.assertRaises(ValueError) as context: CMakeVersionParser("project(DESCRIPTION something LANGUAGES c)") self.assertEqual(str(context.exception), 'unable to find cmake version in project.')
def test_get_current_version_multiline_project_combined_token(self): under_test = CMakeVersionParser( "project\n(\nDESCRIPTION something VERSION 2.3.4 LANGUAGES c\n)") self.assertEqual(under_test.get_current_version(), '2.3.4')
def test_get_current_version_multiline_project(self): under_test = CMakeVersionParser("project\n(\nVERSION\n\t 2.3.4)") self.assertEqual(under_test.get_current_version(), '2.3.4')
def test_not_confuse_version_outside_project(self): under_test = CMakeVersionParser( "non_project(VERSION 2.3.5)\nproject(VERSION 2.3.4)") self.assertEqual(under_test.get_current_version(), '2.3.4')
def test_update_raise_exception_when_version_is_incorrect(self): under_test = CMakeVersionParser("project(VERSION 2.3.4)") with self.assertRaises(VersionError): under_test.update_version('su_much_version_so_much_wow')
def test_update_version_project(self): under_test = CMakeVersionParser("project(VERSION 2.3.4)") self.assertEqual(under_test.update_version('2.3.5'), "project(VERSION 2.3.5)")
def test_get_current_version_single_line_project(self): under_test = CMakeVersionParser("project(VERSION 2.3.4)") self.assertEqual(under_test.get_current_version(), '2.3.4')
def test_raise_exception_no_project(self): with self.assertRaises(ValueError) as context: CMakeVersionParser("non_project(VERSION 2.3.5)", ) self.assertEqual(str(context.exception), 'unable to find cmake project.')