Browse Source

add debug lldb test and fix bug with functional header missing

python
Jørgen Lien Sellæg 7 years ago committed by Jørgen Sverre Lien Sellæg
parent
commit
ff0c52cc45
  1. 4
      src/debug_lldb.cpp
  2. 6
      tests/python_bindings/CMakeLists.txt
  3. 27
      tests/python_bindings/Debug_lldb_tests/debug_lldb_test.cc
  4. 21
      tests/python_bindings/Debug_lldb_tests/debug_lldb_test.py
  5. 4
      tests/python_bindings/test_suite.cc
  6. 1
      tests/python_bindings/test_suite.h

4
src/debug_lldb.cpp

@ -11,6 +11,7 @@
#include <boost/filesystem.hpp>
#include <iostream>
#include <pybind11/stl.h>
#include <pybind11/functional.h>
extern char **environ;
@ -601,7 +602,6 @@ void Debug::LLDB::init_module(pybind11::module &api) {
dbg
.def(py::init([]() { return &(Debug::LLDB::get()); }))
.def_readwrite("on_exit", &Debug::LLDB::on_exit)
// .def_readwrite("mutex", &Debug::LLDB::mutex)
.def("continue_debug", &Debug::LLDB::continue_debug)
.def("stop", &Debug::LLDB::stop)
.def("kill", &Debug::LLDB::kill)
@ -642,7 +642,7 @@ void Debug::LLDB::init_module(pybind11::module &api) {
py::arg("file_path"),
py::arg("line_nr"),
py::arg("line_count"))
.def(" write", &Debug::LLDB::write,
.def("write", &Debug::LLDB::write,
py::arg("buffer"))
;

6
tests/python_bindings/CMakeLists.txt

@ -27,3 +27,9 @@ add_test(pb_config_test pb_config_test)
add_executable(pb_ctags_test Ctags_tests/ctags_test.cc $<TARGET_OBJECTS:test_stubs>)
target_link_libraries(pb_ctags_test test_suite)
add_test(pb_ctags_test pb_ctags_test)
if(LIBLLDB_FOUND AND NOT DEBIAN_STRETCH_FOUND)
add_executable(pb_debug_lldb_test Debug_lldb_tests/debug_lldb_test.cc $<TARGET_OBJECTS:test_stubs>)
target_link_libraries(pb_debug_lldb_test test_suite)
add_test(pb_debug_lldb_test pb_debug_lldb_test)
endif()

27
tests/python_bindings/Debug_lldb_tests/debug_lldb_test.cc

@ -0,0 +1,27 @@
#include "test_suite.h"
#include <iostream>
int main() {
auto &config = Config::get();
config.project.ctags_command = "ctags";
auto suite_name = "Debug_lldb_tests";
{
auto doTest = [&](auto test) {
auto test_suite = suite(suite_name);
auto build_path = test_suite.build_file_path / "tests" / "lldb_test_files" / "lldb_test_executable";
{
auto module = py::module::import("debug_lldb_test");
test_suite.has_assertion = false;
try {
module.attr(test)(build_path.c_str());
test_suite.has_assertion = true;
}
catch(const std::exception &error) {
std::cout << error.what();
}
}
};
doTest("start_on_exit");
}
}

21
tests/python_bindings/Debug_lldb_tests/debug_lldb_test.py

@ -0,0 +1,21 @@
from Jucipp import LLDB
from time import sleep
from jucipp_test import assert_equal
exited = False
def on_exit(exit_code):
assert_equal(0, exit_code)
global exited
exited = True
def start_on_exit(exec_path):
print(exec_path)
l = LLDB()
l.on_exit = [on_exit]
l.start(exec_path, "", [])
while not exited:
sleep(0.1)
l.cancel()

4
tests/python_bindings/test_suite.cc

@ -11,7 +11,9 @@ suite::suite(const boost::filesystem::path &path) {
if(!sys) {
throw std::runtime_error("Unable to append sys path");
}
sys.attr("path").cast<py::list>().append((test_file_path / path).string());
auto sys_path = sys.attr("path").cast<py::list>();
sys_path.append((test_file_path / path).string());
sys_path.append((test_file_path).string());
config.terminal.history_size = 100;
}
suite::~suite() {

1
tests/python_bindings/test_suite.h

@ -10,6 +10,7 @@ public:
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
Config &config = Config::get();
boost::filesystem::path test_file_path = boost::filesystem::canonical(std::string(JUCI_TESTS_PATH) + "/python_bindings");
boost::filesystem::path build_file_path = boost::filesystem::canonical(JUCI_BUILD_PATH);
bool has_assertion = false;
Plugins plugins;
~suite();

Loading…
Cancel
Save