Browse Source

test cmake bindings

python
Jørgen Lien Sellæg 7 years ago committed by Jørgen Sverre Lien Sellæg
parent
commit
3368b4ffc2
  1. 1
      src/cmake.cpp
  2. 7
      tests/python_bindings/CMake_tests/cmake_project/CMakeLists.txt
  3. 14
      tests/python_bindings/CMake_tests/cmake_test.cc
  4. 11
      tests/python_bindings/CMake_tests/cmake_test.py

1
src/cmake.cpp

@ -352,6 +352,7 @@ void CMake::parse_file(const std::string &src, std::map<std::string, std::list<s
void CMake::init_module(pybind11::module &api) {
py::class_<CMake>(api, "CMake")
.def(py::init<const boost::filesystem::path &>())
.def_readwrite("project_path", &CMake::project_path)
.def("update_default_build", &CMake::update_default_build,
py::arg("default_build_path"),

7
tests/python_bindings/CMake_tests/cmake_project/CMakeLists.txt

@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8)
project(cmake_project)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wextra")
add_executable(cmake_project main.cpp)

14
tests/python_bindings/CMake_tests/cmake_test.cc

@ -1,7 +1,17 @@
#include "test_suite.h"
#include <iostream>
int main() {
suite test_suite("CMake_tests");
py::module::import("cmake_test");
auto &config = Config::get();
config.project.cmake.command = "cmake";
auto suite_name = "CMake_tests";
suite test_suite(suite_name);
auto module = py::module::import("cmake_test");
try {
module.attr("run")((test_suite.test_file_path / suite_name / "cmake_project").string());
test_suite.has_assertion = true;
} catch(const py::error_already_set &error){
std::cout << error.what();
}
}

11
tests/python_bindings/CMake_tests/cmake_test.py

@ -1 +1,12 @@
from Jucipp import CMake
def run(project_path):
cmake = CMake(project_path)
assert project_path == cmake.project_path, "Construction of CMake failed"
default_build_path = project_path + "/build"
assert cmake.update_default_build(default_build_path) == True, "Update of default build failed"
executable = cmake.get_executable(default_build_path, project_path)
assert executable == default_build_path + "/cmake_project", "Invalid executable"
default_debug_path = project_path + "/debug"
assert cmake.update_debug_build(default_debug_path), "Update of debug build failed"
executable = cmake.get_executable(default_debug_path, project_path)

Loading…
Cancel
Save