Skip to content
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

Qute-Templates cannot be found in tests if directory "src/test/resources/templates" exist #40366

Closed
mzellho opened this issue Apr 30, 2024 · 9 comments · Fixed by #40400
Closed
Labels
area/qute The template engine kind/bug Something isn't working
Milestone

Comments

@mzellho
Copy link
Contributor

mzellho commented Apr 30, 2024

Describe the bug

As soon as there is a directory src/test/resources/templates, Qute Templates can no longer be found when executing tests, resulting in a No template matching the path foo/bar could be found for: org.acme.FooTemplates.bar.

For more discussion, see #40158

Expected behavior

The existence of a src/test/resources/templates should not break the resolution of the templates.

Actual behavior

No template matching the path foo/bar could be found for: org.acme.FooTemplates.bar when running tests.

How to Reproduce?

Reproducer project: https://github.com/mzellho/quarkus-quickstarts/tree/reproducer/40158

  • Run mvn test on qute-quickstart --> fail
  • Delete src/test/resources/templates --> success

Output of uname -a or ver

Linux xxxxx 6.5.0-28-generic #29-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 28 23:46:48 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "21.0.3" 2024-04-16 LTS OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)

Quarkus version or git rev

3.9.5

Build tool (ie. output of mvnw --version or gradlew --version)

Running /home/xxxxx/work/2/quarkus-quickstarts/mvnw...
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /home/xxxxx/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6
Java version: 21.0.3, vendor: Eclipse Adoptium, runtime: /home/xxxxx/.sdkman/candidates/java/21.0.3-tem
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "6.5.0-28-generic", arch: "amd64", family: "unix"

Additional information

No response

@mzellho mzellho added the kind/bug Something isn't working label Apr 30, 2024
@quarkus-bot quarkus-bot bot added the area/qute The template engine label Apr 30, 2024
Copy link

quarkus-bot bot commented Apr 30, 2024

/cc @mkouba (qute)

@mkouba
Copy link
Contributor

mkouba commented Apr 30, 2024

@aloubyansky Is it expected that MultiRootPathTree.accept(String, Consumer<PathVisit>) does not accept all roots; src/main/resources/templates and src/test/resources/templates in this particular case.

It seems to be a regression introduced in 6014d51.

We should definitely add a test with templates in the src/test/resources/templates directory.

@aloubyansky
Copy link
Member

Ah, I see, it should be considered a bug. If the path was a file, I think we would pick the first found (like it is right now) but if it's a directory, so the content should be merged I guess.

@mkouba
Copy link
Contributor

mkouba commented Apr 30, 2024

but if it's a directory, so the content should be merged I guess.

Yes, I would expect this behavior.

Would you care to send a fix?

@aloubyansky
Copy link
Member

Yes, i'll look into it

@aloubyansky
Copy link
Member

@mkouba i think #40400 should fix it.
Multi rooted path trees are walked over entirely. It's just the path object isn't a good to calculate the relative for all found template roots in this case.

So the accept call would be just a check whether a PathTree contains a template root and should be walked over to collect all the templates.

@aloubyansky
Copy link
Member

I'll add some other API to PathTree to make it more convenient for these use-cases.

@aloubyansky
Copy link
Member

The reproducer works with the linked PR

@aloubyansky
Copy link
Member

In the meantime, Stuart also opened this PR that adds PathTree.acceptAll(String relativePath, Consumer<PathVisit> func), which is kind of relevant to the original issue but not necessary for the PR I linked as the fix.

@quarkus-bot quarkus-bot bot added this to the 3.11 - main milestone May 2, 2024
@gsmet gsmet modified the milestones: 3.11 - main, 3.10.1 May 10, 2024
@gsmet gsmet modified the milestones: 3.10.1, 3.8.5 May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants