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

x/pkgsite: "// Output:" matcher for test Examples is noncanonical #65450

Open
adonovan opened this issue Feb 2, 2024 · 0 comments
Open

x/pkgsite: "// Output:" matcher for test Examples is noncanonical #65450

adonovan opened this issue Feb 2, 2024 · 0 comments

Comments

@adonovan
Copy link
Member

adonovan commented Feb 2, 2024

The standard logic for extracting "// Output:" comments in example tests is here:
https://cs.opensource.google/go/go/+/master:src/go/doc/example.go;l=113;drc=28f1bf61b7383bd4079d77090e67b3198b75be12
Observe that it has a ^ anchor so that it matches only the start of the comment text.
By contrast, pksite uses this regexp:
https://cs.opensource.google/go/x/pkgsite/+/master:internal/godoc/dochtml/internal/render/render.go;l=24;drc=7431aa5932c48bce425bf3f2dc368c5b1fed6e2c
which lacks the anchor. The consequence is that an example such as this one:

func Example() {
    // A
    // B This Example does not have an "// Output:" comment so it will not run.
    // C
}

is considered executable by pkgsite, and its rendering of the example is abruptly cut off at line C.

@gopherbot gopherbot added this to the Unreleased milestone Feb 2, 2024
@adonovan adonovan changed the title x/pkgsite: "// Output:" matcher in test Examples is noncanonical x/pkgsite: "// Output:" matcher for test Examples is noncanonical Feb 2, 2024
@findleyr findleyr modified the milestones: Unreleased, pkgsite/backlog Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants