-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a672ff8
commit bb83035
Showing
6 changed files
with
153 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
`// This is a derivative work. originally part of the LLVM Project. | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// Copyright (c) 2023 Klemens D. Morgenstern | ||
// | ||
|
||
#include "TestConfig.hpp" | ||
#include <mrdox/Error.hpp> | ||
#include <llvm/Support/FileSystem.h> | ||
#include <llvm/Support/Path.h> | ||
#include <llvm/Support/YAMLParser.h> | ||
#include <llvm/Support/YAMLTraits.h> | ||
|
||
|
||
template<> | ||
struct llvm::yaml::MappingTraits< | ||
clang::mrdox::TestConfig> | ||
{ | ||
static void mapping(IO &io, | ||
clang::mrdox::TestConfig& f) | ||
{ | ||
io.mapOptional("cxxstd", f.cxxstd); | ||
io.mapOptional("compile-flags", f.compile_flags); | ||
io.mapOptional("should-fail", f.should_fail); | ||
io.mapOptional("heuristics", f.heuristics); | ||
} | ||
}; | ||
|
||
namespace clang { | ||
namespace mrdox { | ||
|
||
llvm::Expected<std::vector<TestConfig>> | ||
TestConfig::loadForTest( | ||
llvm::StringRef dir, | ||
llvm::StringRef file) | ||
{ | ||
namespace fs = llvm::sys::fs; | ||
namespace path = llvm::sys::path; | ||
|
||
llvm::SmallString<256> filePath = file; | ||
path::replace_extension(filePath, "yml"); | ||
|
||
if (!fs::exists(filePath)) | ||
{ | ||
filePath = dir; | ||
filePath.append("/mrdox-test.yml"); | ||
} | ||
|
||
if (fs::exists(filePath)) | ||
{ | ||
auto fileText = llvm::MemoryBuffer::getFile(filePath); | ||
if(! fileText) | ||
return makeError(fileText.getError().message(), " when loading file '", filePath, "' "); | ||
llvm::yaml::Input yin(**fileText); | ||
|
||
std::vector<TestConfig> res; | ||
do | ||
{ | ||
yin >> res.emplace_back(); | ||
if (auto ec = yin.error()) | ||
return makeError(ec.message(), " when parsing file '", filePath, "' "); | ||
} | ||
while (yin.nextDocument()); | ||
return res; | ||
} | ||
return std::vector<TestConfig>{TestConfig{}}; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// This is a derivative work. originally part of the LLVM Project. | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// Copyright (c) 2023 Klemens D. Morgenstern | ||
// | ||
|
||
#ifndef MRDOX_TEST_CONFIG_HPP | ||
#define MRDOX_TEST_CONFIG_HPP | ||
|
||
#include <mrdox/Platform.hpp> | ||
|
||
#include <llvm/ADT/StringRef.h> | ||
#include <llvm/Support/Error.h> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace clang { | ||
namespace mrdox { | ||
|
||
struct TestConfig | ||
{ | ||
std::string cxxstd = "c++20"; | ||
std::vector<std::string> compile_flags; | ||
bool should_fail = false; | ||
std::string heuristics = "unit test"; | ||
|
||
MRDOX_DECL | ||
static | ||
llvm::Expected<std::vector<TestConfig>> | ||
loadForTest( | ||
llvm::StringRef dir, | ||
llvm::StringRef file); | ||
}; | ||
|
||
|
||
} | ||
} | ||
|
||
|
||
#endif //MRDOX_TEST_CONFIG_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cxxstd: c++20 | ||
... | ||
--- | ||
cxxstd: c++17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cxxstd: c++20 | ||
... | ||
--- | ||
cxxstd: c++17 |