Skip to content

[clang-doc] Add helpers for Template config #138062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

Conversation

ilovepi
Copy link
Contributor

@ilovepi ilovepi commented May 1, 2025

This patch adds or fills in some helper functions related to template
setup when initializing the mustache backend. It was split from #133161.

Co-authored-by: Peter Chou [email protected]

@llvmbot
Copy link
Member

llvmbot commented May 1, 2025

@llvm/pr-subscribers-clang-tools-extra

Author: Paul Kirth (ilovepi)

Changes

This patch adds or fills in some helper functions related to template
setup when initializing the mustache backend. It was split from #133161.

Co-authored-by: Peter Chou <[email protected]>


Full diff: https://github.com/llvm/llvm-project/pull/138062.diff

1 Files Affected:

  • (modified) clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp (+34)
diff --git a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
index 1288e4fbbc983..593d5d1221f44 100644
--- a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
@@ -61,7 +61,41 @@ static std::unique_ptr<MustacheTemplateFile> NamespaceTemplate = nullptr;
 
 static std::unique_ptr<MustacheTemplateFile> RecordTemplate = nullptr;
 
+static Error
+setupTemplate(std::unique_ptr<MustacheTemplateFile> &Template,
+              StringRef TemplatePath,
+              std::vector<std::pair<StringRef, StringRef>> Partials) {
+  auto T = MustacheTemplateFile::createMustacheFile(TemplatePath);
+  if (auto EC = T.getError())
+    return createFileError("cannot open file", EC);
+  Template = std::move(T.get());
+  for (const auto [Name, FileName] : Partials) {
+    if (auto Err = Template->registerPartialFile(Name, FileName))
+      return Err;
+  }
+  return Error::success();
+}
+
 static Error setupTemplateFiles(const clang::doc::ClangDocContext &CDCtx) {
+  std::string NamespaceFilePath =
+      CDCtx.MustacheTemplates.lookup("namespace-template");
+  std::string ClassFilePath = CDCtx.MustacheTemplates.lookup("class-template");
+  std::string CommentFilePath =
+      CDCtx.MustacheTemplates.lookup("comments-template");
+  std::string FunctionFilePath =
+      CDCtx.MustacheTemplates.lookup("function-template");
+  std::string EnumFilePath = CDCtx.MustacheTemplates.lookup("enum-template");
+  std::vector<std::pair<StringRef, StringRef>> Partials = {
+      {"Comments", CommentFilePath},
+      {"FunctionPartial", FunctionFilePath},
+      {"EnumPartial", EnumFilePath}};
+
+  if (Error Err = setupTemplate(NamespaceTemplate, NamespaceFilePath, Partials))
+    return Err;
+
+  if (Error Err = setupTemplate(RecordTemplate, ClassFilePath, Partials))
+    return Err;
+
   return Error::success();
 }
 

@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from 77bb241 to 516f2b2 Compare May 6, 2025 21:33
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-generators branch from 57c7cf8 to 5b34441 Compare May 6, 2025 21:33
Copy link

github-actions bot commented May 6, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-generators branch from 5b34441 to 10fe47d Compare May 6, 2025 22:51
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from 516f2b2 to 50755c0 Compare May 6, 2025 22:51
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-generators branch from 10fe47d to 48e9893 Compare May 7, 2025 01:59
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from 50755c0 to 1ef8e3c Compare May 7, 2025 01:59
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-generators branch from 48e9893 to dd0bf73 Compare May 7, 2025 03:23
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from 1ef8e3c to 0ec149d Compare May 7, 2025 03:23
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-generators branch from dd0bf73 to b67b6ac Compare May 7, 2025 03:25
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from 0ec149d to f8205f7 Compare May 7, 2025 03:25
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-generators branch from b67b6ac to ffafdb7 Compare May 7, 2025 03:26
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from f8205f7 to 1079b7d Compare May 7, 2025 03:26
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from 6d311cf to fb0db52 Compare May 16, 2025 23:38
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-generators branch from 1925647 to de0222f Compare May 16, 2025 23:38
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from fb0db52 to e918ff1 Compare May 17, 2025 00:14
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-generators branch from de0222f to 187b130 Compare May 17, 2025 00:14
Base automatically changed from users/ilovepi/clang-doc-mustache-generators to main May 17, 2025 00:30
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch 2 times, most recently from 442fe2f to 3d87071 Compare May 17, 2025 05:42
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from 3d87071 to 7f91d87 Compare May 20, 2025 18:26
This patch adds or fills in some helper functions related to template
setup when initializing the mustache backend. It was split from #133161.

Co-authored-by: Peter Chou <[email protected]>
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-templete-helper branch from 7f91d87 to 86dc2be Compare May 22, 2025 21:18
Copy link
Contributor Author

ilovepi commented May 22, 2025

Merge activity

  • May 22, 9:19 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 22, 9:20 PM UTC: @ilovepi merged this pull request with Graphite.

@ilovepi ilovepi merged commit 97dee78 into main May 22, 2025
6 of 9 checks passed
@ilovepi ilovepi deleted the users/ilovepi/clang-doc-mustache-templete-helper branch May 22, 2025 21:20
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 22, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64le-linux-multistage running on ppc64le-clang-multistage-test while building clang-tools-extra at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/9814

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
...
[77/85] Generating POWERPC64LELinuxConfig/Asan-powerpc64le-inline-Noinst-Test
[78/85] Generating ASAN_NOINST_TEST_OBJECTS.gtest-all.cc.powerpc64le-calls.o
[79/85] Generating POWERPC64LELinuxConfig/Asan-powerpc64le-calls-Noinst-Test
[80/85] Generating ASAN_INST_TEST_OBJECTS.gtest-all.cc.powerpc64le-calls.o
[81/85] Generating POWERPC64LELinuxDynamicConfig/Asan-powerpc64le-calls-Dynamic-Test
[82/85] Generating POWERPC64LELinuxConfig/Asan-powerpc64le-calls-Test
[83/85] Generating ASAN_INST_TEST_OBJECTS.gtest-all.cc.powerpc64le-inline.o
[84/85] Generating POWERPC64LELinuxDynamicConfig/Asan-powerpc64le-inline-Dynamic-Test
[85/85] Generating POWERPC64LELinuxConfig/Asan-powerpc64le-inline-Test
[1209/1214] Linking CXX executable tools/clang/tools/extra/unittests/clang-doc/ClangDocTests
FAILED: tools/clang/tools/extra/unittests/clang-doc/ClangDocTests 
: && /usr/lib64/ccache/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-noexcept-type -Wno-unnecessary-virtual-specifier -Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG -Wl,--gc-sections tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/BitcodeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/ClangDocTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/GeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLMustacheGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/MDGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/MergeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/SerializeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/YAMLGeneratorTest.cpp.o -o tools/clang/tools/extra/unittests/clang-doc/ClangDocTests  -Wl,-rpath,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/lib  -lpthread  lib/libllvm_gtest_main.so.21.0git  -lpthread  lib/libclangDoc.so.21.0git  lib/libLLVMTestingSupport.so.21.0git  lib/libclangTooling.so.21.0git  lib/libclangFormat.so.21.0git  lib/libclangFrontend.so.21.0git  lib/libclangSerialization.so.21.0git  lib/libclangToolingCore.so.21.0git  lib/libclangRewrite.so.21.0git  lib/libclangASTMatchers.so.21.0git  lib/libclangAST.so.21.0git  lib/libclangBasic.so.21.0git  lib/libLLVMFrontendOpenMP.so.21.0git  lib/libLLVMBitstreamReader.so.21.0git  lib/libllvm_gtest.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/lib && :
/usr/bin/ld: tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLMustacheGeneratorTest.cpp.o: undefined reference to symbol '_Z20getMustacheHtmlFilesN4llvm9StringRefERN5clang3doc15ClangDocContextE'
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/lib/libclangDocSupport.so.21.0git: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Step 11 (ninja check 2) failure: stage 2 checked (failure)
...
2 warning(s) in tests

Testing Time: 179.69s

Total Discovered Tests: 4404
  Skipped          :    9 (0.20%)
  Unsupported      : 1184 (26.88%)
  Passed           : 3169 (71.96%)
  Expectedly Failed:   42 (0.95%)
[1148/1214] Linking CXX executable tools/clang/tools/extra/unittests/clang-doc/ClangDocTests
FAILED: tools/clang/tools/extra/unittests/clang-doc/ClangDocTests 
: && /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1.install/bin/clang++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wno-unnecessary-virtual-specifier -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -Wl,--gc-sections tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/BitcodeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/ClangDocTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/GeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLMustacheGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/MDGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/MergeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/SerializeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/YAMLGeneratorTest.cpp.o -o tools/clang/tools/extra/unittests/clang-doc/ClangDocTests  -Wl,-rpath,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage2/lib  -lpthread  lib/libllvm_gtest_main.so.21.0git  -lpthread  lib/libclangDoc.so.21.0git  lib/libLLVMTestingSupport.so.21.0git  lib/libclangTooling.so.21.0git  lib/libclangFormat.so.21.0git  lib/libclangFrontend.so.21.0git  lib/libclangSerialization.so.21.0git  lib/libclangToolingCore.so.21.0git  lib/libclangRewrite.so.21.0git  lib/libclangASTMatchers.so.21.0git  lib/libclangAST.so.21.0git  lib/libclangBasic.so.21.0git  lib/libLLVMFrontendOpenMP.so.21.0git  lib/libLLVMBitstreamReader.so.21.0git  lib/libllvm_gtest.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage2/lib && :
/usr/bin/ld: tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLMustacheGeneratorTest.cpp.o: undefined reference to symbol '_Z20getMustacheHtmlFilesN4llvm9StringRefERN5clang3doc15ClangDocContextE'
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage2/lib/libclangDocSupport.so.21.0git: error adding symbols: DSO missing from command line
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[1205/1214] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
[1207/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/ASTMatchers/ASTMatchersTraversalTest.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented May 22, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64le-rhel running on ppc64le-clang-rhel-test while building clang-tools-extra at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/7205

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
0.197 [1/3/2] Building CXX object compiler-rt/lib/ubsan/CMakeFiles/RTUbsan_dynamic_version_script_dummy.powerpc64le.dir/dummy.cpp.o
0.428 [0/3/3] Linking CXX shared library /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.ubsan_standalone.so
0.452 [0/2/4] Linking CXX shared library /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.asan.so
1.148 [0/1/5] Generating /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/compile_commands.json
25.587 [4/2/1212] cd /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/runtimes/runtimes-bins && /home/buildbots/llvm-external-buildbots/cmake-3.31.2/bin/cmake --build /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/runtimes/runtimes-bins/ --target runtimes-test-depends --config Release
ninja: no work to do.
25.655 [3/2/1213] No install step for 'runtimes'
25.681 [2/2/1215] Completed 'runtimes'
33.403 [2/1/1216] Building CXX object tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLMustacheGeneratorTest.cpp.o
33.462 [1/1/1217] Linking CXX executable tools/clang/tools/extra/unittests/clang-doc/ClangDocTests
FAILED: tools/clang/tools/extra/unittests/clang-doc/ClangDocTests 
: && /home/buildbots/llvm-external-buildbots/clang.19.1.7/bin/clang++ --gcc-toolchain=/gcc-toolchain/usr -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -Wl,--color-diagnostics     -Wl,--gc-sections  -Xlinker --dependency-file=tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/link.d tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/BitcodeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/ClangDocTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/GeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLMustacheGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/MDGeneratorTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/MergeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/SerializeTest.cpp.o tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/YAMLGeneratorTest.cpp.o -o tools/clang/tools/extra/unittests/clang-doc/ClangDocTests  -Wl,-rpath,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib  lib/libllvm_gtest_main.so.21.0git  -lpthread  lib/libclangDoc.so.21.0git  lib/libLLVMTestingSupport.so.21.0git  lib/libclangTooling.so.21.0git  lib/libclangFormat.so.21.0git  lib/libclangFrontend.so.21.0git  lib/libclangSerialization.so.21.0git  lib/libclangToolingCore.so.21.0git  lib/libclangRewrite.so.21.0git  lib/libclangASTMatchers.so.21.0git  lib/libclangAST.so.21.0git  lib/libclangBasic.so.21.0git  lib/libLLVMFrontendOpenMP.so.21.0git  lib/libLLVMBitstreamReader.so.21.0git  lib/libllvm_gtest.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib && :
ld.lld: error: undefined symbol: getMustacheHtmlFiles(llvm::StringRef, clang::doc::ClangDocContext&)
>>> referenced by HTMLMustacheGeneratorTest.cpp
>>>               tools/clang/tools/extra/unittests/clang-doc/CMakeFiles/ClangDocTests.dir/HTMLMustacheGeneratorTest.cpp.o:(HTMLMustacheGeneratorTest_generateDocs_Test::TestBody())
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

@nico
Copy link
Contributor

nico commented May 23, 2025

Reading files from unit tests is a bit of an anti-pattern: It requires putting the absolute path to the tests somewhere (you're doing this with a config file here), and it means you easily run tests on a different machine than the one you're building on. Could you restructure this test to not read a file? Or, if you need to run a file, can you do that from a lit test, where the path from build artifacts and test inputs is abstracted away enough that the build/test separation still works?

nico added a commit that referenced this pull request May 23, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request May 23, 2025
@ilovepi
Copy link
Contributor Author

ilovepi commented May 23, 2025

Reading files from unit tests is a bit of an anti-pattern: It requires putting the absolute path to the tests somewhere (you're doing this with a config file here), and it means you easily run tests on a different machine than the one you're building on. Could you restructure this test to not read a file? Or, if you need to run a file, can you do that from a lit test, where the path from build artifacts and test inputs is abstracted away enough that the build/test separation still works?

I also don't really love the way this is shaped. We're trying to land functionality we want/need in clang-doc that a contributor more or less abandoned. Support to run the tool as a whole is further up the stack. I think it may be hard to reorder the patches to speed that up. As an alternative, we could disable the unit tests for the new feature, since its expected to be experimental for some time, and move the testing into lit tests.

ilovepi added a commit that referenced this pull request May 23, 2025
In #138062 it was brought up that this was an anti-pattern. We'll need
to Migrate all of the mustache unittests to lit tests, and disable them
until tool support lands.
@nico
Copy link
Contributor

nico commented May 23, 2025

As an alternative, we could disable the unit tests for the new feature, since its expected to be experimental for some time, and move the testing into lit tests.

That sounds like a good way forward to me :)

ilovepi added a commit that referenced this pull request May 23, 2025
In #138062 it was brought up that this was an anti-pattern. We'll need
to Migrate all of the mustache unittests that need to read template 
files to lit tests, and disable them until tool support lands.
@ilovepi
Copy link
Contributor Author

ilovepi commented May 23, 2025

#141269 should fix the issue for now. I'll clean up the rest of the stack to avoid reintroducing this problem.

sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
This patch adds or fills in some helper functions related to template
setup when initializing the mustache backend. It was split from llvm#133161.

Co-authored-by: Peter Chou <[email protected]>
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
In llvm#138062 it was brought up that this was an anti-pattern. We'll need
to Migrate all of the mustache unittests that need to read template 
files to lit tests, and disable them until tool support lands.
ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
This patch adds or fills in some helper functions related to template
setup when initializing the mustache backend. It was split from llvm#133161.

Co-authored-by: Peter Chou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants