Пример #1
0
    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'),
        )
Пример #2
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'),
        )
Пример #3
0
 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')
Пример #4
0
 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)")