Skip to content

Conversation

@evelez7
Copy link
Member

@evelez7 evelez7 commented Sep 23, 2025

Resource creation not using the correct path after the patch that placed
HTML files into their own directory.

Copy link
Member Author

evelez7 commented Sep 23, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@evelez7 evelez7 marked this pull request as ready for review September 23, 2025 18:37
@llvmbot
Copy link
Member

llvmbot commented Sep 23, 2025

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

Author: Erick Velez (evelez7)

Changes

Resource creation not using the correct path after the patch that placed
HTML files into their own directory.


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

2 Files Affected:

  • (modified) clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp (+3-2)
  • (modified) clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp (+2-2)
diff --git a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
index 1ab40aacbfe09..b37dc272ea156 100644
--- a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
@@ -274,11 +274,12 @@ Error MustacheHTMLGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
 }
 
 Error MustacheHTMLGenerator::createResources(ClangDocContext &CDCtx) {
+  std::string ResourcePath(CDCtx.OutDirectory + "/html");
   for (const auto &FilePath : CDCtx.UserStylesheets)
-    if (Error Err = copyFile(FilePath, CDCtx.OutDirectory))
+    if (Error Err = copyFile(FilePath, ResourcePath))
       return Err;
   for (const auto &FilePath : CDCtx.JsScripts)
-    if (Error Err = copyFile(FilePath, CDCtx.OutDirectory))
+    if (Error Err = copyFile(FilePath, ResourcePath))
       return Err;
   return Error::success();
 }
diff --git a/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp
index 602058f5d9eb8..66575d85380f8 100644
--- a/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp
@@ -75,14 +75,14 @@ TEST(HTMLMustacheGeneratorTest, createResources) {
       << "Failed to create resources with valid UserStylesheets and JsScripts";
   {
     SmallString<256> PathBuf;
-    llvm::sys::path::append(PathBuf, RootTestDirectory.path(),
+    llvm::sys::path::append(PathBuf, RootTestDirectory.path(), "html",
                             "clang-doc-mustache.css");
     verifyFileContents(PathBuf, "CSS");
   }
 
   {
     SmallString<256> PathBuf;
-    llvm::sys::path::append(PathBuf, RootTestDirectory.path(), "mustache.js");
+    llvm::sys::path::append(PathBuf, RootTestDirectory.path(), "html", "mustache.js");
     verifyFileContents(PathBuf, "JavaScript");
   }
 }

@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-fix-resource-paths branch from e6c68b9 to 4e6e429 Compare September 23, 2025 18:39
Copy link
Member Author

evelez7 commented Sep 23, 2025

This fix has to delete the HTML Mustache unit tests because I don't think it's possible to create nested temporary directories like what the unit test was doing. We'd need a temp HTML dir inside the temp createResourcesTest dir. I'm not sure if this also aligns with the previous "anti-pattern" of creating/checking files during unit tests.

I could avoid deleting the unit test if the resource files were placed one level above the HTML dir (so in the context RootDir), but then the templates would need to refer to ../clang-doc.css, etc. That would mean the HTML dir cant be moved around easily.

Here's a link for the basic test output from this patch and here's one for current main which shows the broken CSS.

@ilovepi
Copy link
Contributor

ilovepi commented Sep 23, 2025

Why do you have to delete the unit test? the basic error paths can still be checked there, right? even if you can't plumb in the right paths for template stuff, I'd think the basics of startup and when the generator error out would be testable.

Next, its possible to control the behavior w/ options or by making the interfaces more easily testable by putting some interfaces into a header that the tests can include.

@ilovepi
Copy link
Contributor

ilovepi commented Sep 23, 2025

for now, I'm OK w/ dropping the template buisness, and keeping the basic error checking, since its very cheap.

@evelez7 evelez7 force-pushed the users/evelez7/clang-doc-fix-resource-paths branch from 4e6e429 to 6e0207f Compare September 23, 2025 20:18
Copy link
Member Author

evelez7 commented Sep 24, 2025

Merge activity

  • Sep 24, 12:54 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Sep 24, 12:56 AM UTC: @evelez7 merged this pull request with Graphite.

@evelez7 evelez7 merged commit e7515ee into main Sep 24, 2025
9 checks passed
@evelez7 evelez7 deleted the users/evelez7/clang-doc-fix-resource-paths branch September 24, 2025 00:56
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 24, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve2-vla running on linaro-g4-02 while building clang-tools-extra at step 7 "ninja check 1".

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

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'lit :: shtest-readfile.py' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 3
env LIT_USE_INTERNAL_SHELL=1  not env -u FILECHECK_OPTS "/usr/bin/python3.10" /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit.py -j1 --order=lexical -a -v Inputs/shtest-readfile | FileCheck -match-full-lines -DTEMP_PATH=/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/utils/lit/tests/Inputs/shtest-readfile/Output /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/utils/lit/tests/shtest-readfile.py
# executed command: env LIT_USE_INTERNAL_SHELL=1 not env -u FILECHECK_OPTS /usr/bin/python3.10 /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit.py -j1 --order=lexical -a -v Inputs/shtest-readfile
# executed command: FileCheck -match-full-lines -DTEMP_PATH=/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/utils/lit/tests/Inputs/shtest-readfile/Output /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/utils/lit/tests/shtest-readfile.py
# .---command stderr------------
# | /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/utils/lit/tests/shtest-readfile.py:20:10: error: CHECK: expected string not found in input
# | # CHECK: echo hello bye
# |          ^
# | <stdin>:73:52: note: scanning from here
# | FAIL: shtest-readfile :: two-same-line.txt (4 of 4)
# |                                                    ^
# | <stdin>:84:19: note: possible intended match here
# | # executed command: echo -n bye
# |                   ^
# | 
# | Input file: <stdin>
# | Check file: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/utils/lit/tests/shtest-readfile.py
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            68: # error: command failed with exit status: 1 
# |            69:  
# |            70: -- 
# |            71:  
# |            72: ******************** 
# |            73: FAIL: shtest-readfile :: two-same-line.txt (4 of 4) 
# | check:20'0                                                        X error: no match found
# |            74: ******************** TEST 'shtest-readfile :: two-same-line.txt' FAILED ******************** 
# | check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            75: Exit Code: 1 
# | check:20'0     ~~~~~~~~~~~~~
# |            76:  
# | check:20'0     ~
# |            77: Command Output (stdout): 
# | check:20'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |            78: -- 
# | check:20'0     ~~~
# |            79: # RUN: at line 3 
# | check:20'0     ~~~~~~~~~~~~~~~~~
# |            80: echo -n "hello" > /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.1 
...

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.

5 participants