Commit 044d7b7a authored by Ole Christian Eidheim's avatar Ole Christian Eidheim
Browse files

Fixed tests on Linux

parent 8f4bc899
#include "clangmm.h"
#include <string>
#include <cassert>
#include <regex>
int main() {
std::string tests_path=LIBCLANGMM_TESTS_PATH;
std::string path(tests_path+"/case/main.cpp");
std::vector<std::string> arguments;
auto clang_version_string=clangmm::to_string(clang_getClangVersion());
const static std::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$");
std::smatch sm;
if(std::regex_match(clang_version_string, sm, clang_version_regex)) {
auto clang_version=sm[1].str();
arguments.emplace_back("-I/usr/lib/clang/"+clang_version+"/include");
arguments.emplace_back("-I/usr/lib64/clang/"+clang_version+"/include"); // For Fedora
}
clangmm::Index index(0, 0);
clangmm::TranslationUnit tu(index, path, {});
clangmm::TranslationUnit tu(index, path, arguments);
std::string buffer="#include <string>\n"
"int main(int argc, char *argv[]) {\n"
......
......@@ -2,6 +2,7 @@
#include <iostream>
#include <fstream>
#include <cassert>
#include <regex>
using namespace std;
......@@ -11,7 +12,17 @@ int main() {
clangmm::Index index(0, 0);
clangmm::TranslationUnit tu(index, path, {});
std::vector<std::string> arguments;
auto clang_version_string=clangmm::to_string(clang_getClangVersion());
const static std::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$");
std::smatch sm;
if(std::regex_match(clang_version_string, sm, clang_version_regex)) {
auto clang_version=sm[1].str();
arguments.emplace_back("-I/usr/lib/clang/"+clang_version+"/include");
arguments.emplace_back("-I/usr/lib64/clang/"+clang_version+"/include"); // For Fedora
}
clangmm::TranslationUnit tu(index, path, arguments);
auto diagnostics=tu.get_diagnostics();
assert(diagnostics.size()>0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment