def test_add_outputs_variables(self): """Add Outputs Variables""" # If NO output is given self.data_test['cmake'] = get_cmake_lists(self.cur_dir) under_test = ProjectVariables(self.data_test) under_test.add_project_variables() under_test.add_outputs_variables() self.data_test['cmake'].close() cmakelists_test = open('%s/CMakeLists.txt' % self.cur_dir, 'r') content_test = cmakelists_test.read() self.assertTrue('OUTPUT_DEBUG ../../../build/vc2017_x64d/bin/', content_test) self.assertTrue('OUTPUT_REL ../../../build/vc2017_x64/bin/' in content_test) cmakelists_test.close() # If output is given under_test.output = '../output_binaries' under_test.cmake = get_cmake_lists(self.cur_dir) under_test.add_outputs_variables() under_test.cmake.close() cmakelists_test = open('%s/CMakeLists.txt' % self.cur_dir, 'r') content_test = cmakelists_test.read() self.assertTrue('OUTPUT_DEBUG ../output_binaries/${CMAKE_BUILD_TYPE}', content_test) self.assertTrue('OUTPUT_REL ../output_binaries/${CMAKE_BUILD_TYPE}' in content_test) cmakelists_test.close()
def test_add_cmake_project(self): """Add CMake Project""" self.data_test['cmake'] = get_cmake_lists(self.cur_dir) under_test = ProjectVariables(self.data_test) # Case CXX language under_test.add_cmake_project(['cpp']) self.data_test['cmake'].close() cmakelists_test = open('%s/CMakeLists.txt' % self.cur_dir, 'r') content_test = cmakelists_test.read() self.assertTrue('project(${PROJECT_NAME} CXX)' in content_test) cmakelists_test.close() # Case C language under_test.cmake = get_cmake_lists(self.cur_dir) under_test.add_cmake_project(['c']) under_test.cmake.close() cmakelists_test = open('%s/CMakeLists.txt' % self.cur_dir, 'r') content_test = cmakelists_test.read() self.assertTrue('project(${PROJECT_NAME} C)' in content_test) cmakelists_test.close()
def test_add_outputs_variables(self): """Add Outputs Variables""" # If NO output is given self.data_test['cmake'] = get_cmake_lists(self.cur_dir) under_test = ProjectVariables(self.data_test) under_test.add_project_variables() under_test.add_outputs_variables() self.data_test['cmake'].close() cmakelists_test = open('%s/CMakeLists.txt' % self.cur_dir, 'r') content_test = cmakelists_test.read() self.assertTrue('OUTPUT_DEBUG ../../../build/vc2017_x64d/bin/', content_test) self.assertTrue( 'OUTPUT_REL ../../../build/vc2017_x64/bin/' in content_test) cmakelists_test.close() # If output is given under_test.output = '../output_binaries' under_test.cmake = get_cmake_lists(self.cur_dir) under_test.add_outputs_variables() under_test.cmake.close() cmakelists_test = open('%s/CMakeLists.txt' % self.cur_dir, 'r') content_test = cmakelists_test.read() self.assertTrue('OUTPUT_DEBUG ../output_binaries/${CMAKE_BUILD_TYPE}', content_test) self.assertTrue('OUTPUT_REL ../output_binaries/${CMAKE_BUILD_TYPE}' in content_test) cmakelists_test.close()