-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: fix template global class generation in the dev mode #45771
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
8 changes: 8 additions & 0 deletions
8
...yment/src/test/java/io/quarkus/qute/deployment/devmode/QuteDummyTemplateGlobalMarker.java
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,8 @@ | ||
package io.quarkus.qute.deployment.devmode; | ||
|
||
/** | ||
* Marker interface for {@link TemplateGlobalDevModeTest}. | ||
*/ | ||
public interface QuteDummyTemplateGlobalMarker { | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...eployment/src/test/java/io/quarkus/qute/deployment/devmode/TemplateGlobalDevModeTest.java
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,45 @@ | ||
package io.quarkus.qute.deployment.devmode; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
/** | ||
* Test that template globals added in the dev mode are generated correctly after live reload. | ||
* <p> | ||
* The {@link QuteDummyTemplateGlobalMarker} is used to identify an application archive where a dummy built-in class with | ||
* template globals is added. | ||
*/ | ||
public class TemplateGlobalDevModeTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(TestRoute.class, QuteDummyTemplateGlobalMarker.class) | ||
.addAsResource(new StringAsset( | ||
"{quteDummyFoo}:{testFoo ?: 'NA'}"), | ||
"templates/test.html")); | ||
|
||
@Test | ||
public void testTemplateGlobals() { | ||
given().get("test") | ||
.then() | ||
.statusCode(200) | ||
.body(Matchers.equalTo("bar:NA")); | ||
|
||
// Add application globals - the priority sequence should be automatically | ||
// increased before it's used for TestGlobals | ||
config.addSourceFile(TestGlobals.class); | ||
|
||
given().get("test") | ||
.then() | ||
.statusCode(200) | ||
.body(Matchers.equalTo("bar:baz")); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/devmode/TestGlobals.java
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,11 @@ | ||
package io.quarkus.qute.deployment.devmode; | ||
|
||
import io.quarkus.qute.TemplateGlobal; | ||
|
||
@TemplateGlobal | ||
public class TestGlobals { | ||
|
||
public static String testFoo() { | ||
return "baz"; | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FroMage ok, so I've added this test. It's a bit hacky but the build step that generates a dummy global is only executed in the dev mode and if
QuteDummyTemplateGlobalMarker
is present.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can add custom build steps in your test, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, it's only for ProdMode tests. Well… I suppose we could add that to dev mode tests too…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in
QuarkusUnitTest
...I have no idea how complicated this could be 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely some work, up to you, I don't mind your build step :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, it's out of scope of this PR. We could file a new issue and revisit the test later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI #45811