mirror of https://gitlab.com/cppit/jucipp
4 changed files with 63 additions and 1 deletions
@ -0,0 +1,21 @@
|
||||
#include "cmake.h" |
||||
#include "test_suite.h" |
||||
#include <iostream> |
||||
|
||||
int main() { |
||||
auto suite_name = "CompileCommands_tests"; |
||||
suite test_suite(suite_name); |
||||
auto project_path = (test_suite.test_file_path / "cmake_project"); |
||||
auto &config = Config::get(); |
||||
config.project.cmake.command = "cmake"; |
||||
CMake cmake(project_path); |
||||
cmake.update_default_build(project_path/"build"); |
||||
try { |
||||
auto module = py::module::import("compile_commands_test"); |
||||
module.attr("run")(project_path.string()); |
||||
test_suite.has_assertion = true; |
||||
} |
||||
catch(const py::error_already_set &error) { |
||||
std::cout << error.what(); |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
|
||||
from Jucipp import CompileCommands |
||||
|
||||
def run(project_path): |
||||
build_path = project_path + "/build" |
||||
cc = CompileCommands(build_path) |
||||
commands = cc.commands |
||||
assert len(commands) == 1, "Wrong length of compile commands" |
||||
command = commands.pop() |
||||
assert command.directory == build_path |
||||
assert command.file == project_path + "/main.cpp" |
||||
|
||||
params = command.parameters |
||||
param = params.pop() |
||||
assert param == project_path + "/main.cpp" |
||||
|
||||
param = params.pop() |
||||
assert param == "-c" |
||||
|
||||
param = params.pop() |
||||
param = params.pop() |
||||
assert param == "-o" |
||||
|
||||
values = command.parameter_values("-c") |
||||
value = values.pop() |
||||
assert value == project_path + "/main.cpp" |
||||
|
||||
assert CompileCommands.is_source(project_path + "/main.cpp") == True |
||||
assert CompileCommands.is_header(project_path + "/main.cpp") == False |
||||
|
||||
arguments = CompileCommands.get_arguments(build_path, project_path + "/main.cpp") |
||||
argument = arguments.pop() |
||||
assert argument == build_path |
||||
Loading…
Reference in new issue