-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preprocessor: take statement doc comments into account in cache key
In https://cuelang.org/cl/1176702 we added support for the first statement directives, in that case adding a directive to apply an ellipsis sanitiser. This means that directives in doc comments need to be considered as part of the cache key for a multi-step script (directives are not yet supported in code blocks... we need to consolidate that code). Strictly speaking only directives need to participate as part of the cache key. However for now, in the interests of expediency, we add the entire statement doc comment to be part of the cache key. Fixes cue-lang/cue#2814 Preprocessor-No-Write-Cache: true Signed-off-by: Paul Jolly <[email protected]> Change-Id: Id80a8e3916f4b5f0c89f960094ac7bdc949b2b69 Dispatch-Trailer: {"type":"trybot","CL":1176999,"patchset":2,"ref":"refs/changes/99/1176999/2","targetBranch":"alpha"}
- Loading branch information
Showing
3 changed files
with
69 additions
and
1 deletion.
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
67 changes: 67 additions & 0 deletions
67
internal/cmd/preprocessor/cmd/testdata/execute_doc_comment_change.txtar
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,67 @@ | ||
# Verify that changing a doc comment in any way causes a cache miss | ||
|
||
unquote content/dir/en.md content/dir/en.md.doc_comment | ||
|
||
# Run the preprocessor | ||
exec preprocessor execute | ||
|
||
# Verify that we generated the expected output | ||
cmp hugo/content/en/dir/index.md golden/hugo/content/en/dir/index.md | ||
|
||
# Re-run the preprocessor and ensure we have a cache hit | ||
exec preprocessor execute --debug=all | ||
stderr $WORK${/}'content'${/}'dir'${/}'en.md: cache hit for multi-step script; not running' | ||
|
||
# Verify that we still generated the expected output | ||
cmp hugo/content/en/dir/index.md golden/hugo/content/en/dir/index.md | ||
|
||
# Modify the doc comment alone and verify we get a cache miss | ||
cp content/dir/en.md.doc_comment content/dir/en.md | ||
exec preprocessor execute --debug=all | ||
stderr $WORK${/}'content'${/}'dir'${/}'en.md: cache miss for multi-step script' | ||
|
||
# Verify that we generated the expected output with a doc comment | ||
cmp hugo/content/en/dir/index.md golden/hugo/content/en/dir/index_doc_comment.md | ||
|
||
-- hugo/.keep -- | ||
-- content/site.cue -- | ||
package site | ||
-- content/dir/page.cue -- | ||
package site | ||
|
||
content: dir: page: { | ||
leftDelim: "{{{" | ||
rightDelim: "}}}" | ||
} | ||
-- content/dir/en.md -- | ||
>--- | ||
>title: A page | ||
>--- | ||
>{{{with script "en" "run-the-cue"}}} | ||
>echo hello | ||
>{{{end}}} | ||
-- content/dir/en.md.doc_comment -- | ||
>--- | ||
>title: A page | ||
>--- | ||
>{{{with script "en" "run-the-cue"}}} | ||
># This is a doc comment | ||
>echo hello | ||
>{{{end}}} | ||
-- golden/hugo/content/en/dir/index.md -- | ||
--- | ||
title: A page | ||
--- | ||
```text { title="TERMINAL" codeToCopy="ZWNobyBoZWxsbwo=" } | ||
$ echo hello | ||
hello | ||
``` | ||
-- golden/hugo/content/en/dir/index_doc_comment.md -- | ||
--- | ||
title: A page | ||
--- | ||
```text { title="TERMINAL" codeToCopy="ZWNobyBoZWxsbwo=" } | ||
# This is a doc comment | ||
$ echo hello | ||
hello | ||
``` |
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