[clang-tools-extra] [clang-doc] Add HTMLMustacheGenerator methods (PR #138061)
Daniel Thornburgh via cfe-commits
cfe-commits at lists.llvm.org
Fri May 16 12:03:31 PDT 2025
================
@@ -40,13 +42,43 @@ getClangDocContext(std::vector<std::string> UserStylesheets = {},
return CDCtx;
}
+static void verifyFileContents(const Twine &Path, StringRef Contents) {
+ auto Buffer = MemoryBuffer::getFile(Path);
+ ASSERT_TRUE((bool)Buffer);
+ StringRef Data = Buffer.get()->getBuffer();
+ ASSERT_EQ(Data, Contents);
+}
+
TEST(HTMLMustacheGeneratorTest, createResources) {
auto G = getHTMLMustacheGenerator();
ASSERT_THAT(G, NotNull()) << "Could not find HTMLMustacheGenerator";
ClangDocContext CDCtx = getClangDocContext();
+ EXPECT_THAT_ERROR(G->createResources(CDCtx), Failed())
+ << "Empty UserStylesheets or JsScripts should fail!";
+
+ unittest::TempDir RootTestDirectory("createResourcesTest", /*Unique=*/true);
+ CDCtx.OutDirectory = RootTestDirectory.path();
+
+ unittest::TempFile CSS("clang-doc-mustache", "css", "CSS");
+ unittest::TempFile JS("mustache", "js", "JavaScript");
+
+ CDCtx.UserStylesheets[0] = CSS.path();
+ CDCtx.JsScripts[0] = JS.path();
EXPECT_THAT_ERROR(G->createResources(CDCtx), Succeeded())
- << "Failed to create resources.";
+ << "Failed to create resources with valid UserStylesheets and JsScripts";
+ {
+ SmallString<256> PathBuff;
----------------
mysterymath wrote:
nit: I don't know that I've ever come across `Buff`; `Buf` is typical abbreviation in my experience.
https://github.com/llvm/llvm-project/pull/138061
More information about the cfe-commits
mailing list