Browse Source

fix some formatting and check for errors in suite

python
Jørgen Lien Sellæg 7 years ago committed by Jørgen Sverre Lien Sellæg
parent
commit
f8a607a8ab
  1. 8
      tests/python_bindings/CompileCommands_tests/compile_commands_test.cc
  2. 2
      tests/python_bindings/jucipp_test.py
  3. 8
      tests/python_bindings/test_suite.cc

8
tests/python_bindings/CompileCommands_tests/compile_commands_test.cc

@ -8,20 +8,16 @@ int main() {
auto project_path = test_suite.test_file_path / "cmake_project";
auto &config = Config::get();
#ifdef _WIN32
std::string slash = "\\";
config.project.cmake.command = "cmake -G\"MSYS Makefiles\" -DCMAKE_INSTALL_PREFIX=/mingw64";
#else
std::string slash = "/";
config.project.cmake.command = "cmake";
#endif
CMake cmake(project_path);
cmake.update_default_build(boost::filesystem::path(project_path) / "build");
try {
auto module = py::module::import("compile_commands_test");
std::string slash =
#ifdef _WIN32
"\\";
#else
"/";
#endif
module.attr("run")(project_path.make_preferred().string(), slash);
test_suite.has_assertion = true;
}

2
tests/python_bindings/jucipp_test.py

@ -2,4 +2,4 @@
def assert_equal(expected, actual):
""" Assert two variables for equality with an useful error message """
assert actual == expected, "Expected: " + expected + ", got " + actual
assert actual == expected, "Expected: " + str(expected) + ", got " + str(actual)

8
tests/python_bindings/test_suite.cc

@ -4,11 +4,19 @@
suite::suite(const boost::filesystem::path &path) {
py::initialize_interpreter();
if(!Py_IsInitialized()) {
throw std::runtime_error("Unable to initialize interpreter");
}
auto sys = py::module::import("sys");
if(!sys) {
throw std::runtime_error("Unable to append sys path");
}
sys.attr("path").cast<py::list>().append((test_file_path / path).string());
config.terminal.history_size = 100;
}
suite::~suite() {
if(Py_IsInitialized()) {
py::finalize_interpreter();
g_assert_true(has_assertion);
}
}

Loading…
Cancel
Save