mirror of https://gitlab.com/cppit/jucipp
3 changed files with 34 additions and 18 deletions
@ -1,32 +1,38 @@ |
|||||||
from Jucipp import CompileCommands |
from Jucipp import CompileCommands |
||||||
|
|
||||||
def run(project_path): |
from os import path |
||||||
build_path = project_path + "/build" |
|
||||||
|
def assert_equal(expected, actual): |
||||||
|
assert actual == expected, "Expected: " + expected + ", got " + actual |
||||||
|
|
||||||
|
def run(project_path, slash): |
||||||
|
build_path = project_path + slash + "build" |
||||||
cc = CompileCommands(build_path) |
cc = CompileCommands(build_path) |
||||||
commands = cc.commands |
commands = cc.commands |
||||||
assert len(commands) == 1, "Wrong length of compile commands" |
assert len(commands) == 1, "Wrong length of compile commands" |
||||||
command = commands.pop() |
command = commands.pop() |
||||||
assert command.directory == build_path |
assert_equal(build_path, command.directory) |
||||||
assert command.file == project_path + "/main.cpp" |
assert_equal(project_path + slash + "main.cpp", command.file) |
||||||
|
|
||||||
params = command.parameters |
params = command.parameters |
||||||
param = params.pop() |
param = path.basename(params.pop()) |
||||||
assert param == project_path + "/main.cpp" |
assert_equal("main.cpp", param) |
||||||
|
|
||||||
param = params.pop() |
param = params.pop() |
||||||
assert param == "-c" |
assert_equal("-c", param) |
||||||
|
|
||||||
param = params.pop() |
param = params.pop() |
||||||
param = params.pop() |
param = params.pop() |
||||||
assert param == "-o" |
assert_equal("-o", param) |
||||||
|
|
||||||
values = command.parameter_values("-c") |
values = command.parameter_values("-c") |
||||||
value = values.pop() |
value = path.basename(values.pop()) |
||||||
assert value == project_path + "/main.cpp" |
assert_equal("main.cpp", value) |
||||||
|
|
||||||
assert CompileCommands.is_source(project_path + "/main.cpp") == True |
assert_equal(True, CompileCommands.is_source(project_path + slash + "main.cpp")) |
||||||
assert CompileCommands.is_header(project_path + "/main.cpp") == False |
assert_equal(False, CompileCommands.is_header(project_path + slash + "main.cpp")) |
||||||
|
|
||||||
arguments = CompileCommands.get_arguments(build_path, project_path + "/main.cpp") |
arguments = CompileCommands.get_arguments(build_path, project_path + slash + "main.cpp") |
||||||
argument = arguments.pop() |
argument = arguments.pop() |
||||||
assert argument == build_path |
|
||||||
|
assert_equal(build_path, argument) |
||||||
Loading…
Reference in new issue