Skip to content

Code Snippet Testing #52

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

Open
Tracked by #56
bmorelli25 opened this issue Nov 11, 2024 · 4 comments
Open
Tracked by #56

Code Snippet Testing #52

bmorelli25 opened this issue Nov 11, 2024 · 4 comments

Comments

@bmorelli25
Copy link
Member

Summary

Support the ability to test code snippets.

See https://github.com/elastic/elasticsearch/tree/main/docs#test-code-snippets for more information.

Related issue that describes functionality in Asciidoc system: elastic/docs#2867

Partially related to #7.

@leemthompo
Copy link
Contributor

Re https://elastic.slack.com/archives/CJE3WCFEH/p1741162012377709?thread_ts=1741124580.043689&cid=CJE3WCFEH

I guess we'll need snippet testing in the elasticsearch repo and docs-content at the very least. Elasticsearch should be back online as soon as the test comments are restored.

@lcawl
Copy link
Contributor

lcawl commented Mar 6, 2025

There's a thread about some automated testing that was occurring in the ECK docs too here: https://elastic.slack.com/archives/C05PP2LEC1X/p1741273388324539

@leemthompo
Copy link
Contributor

Current state of play for elasticsearch snippets:

To restore the existing snippet testing framework to the elasticsearch repo, we'll need the @elastic/es-delivery team to update the parsing logic to parse .md files using the new comment syntax.

As @szabosteve mentioned elsewhere this probably just requires some minimal updates to the MDX logic added for a previous docs migration test.

@brianseeders
Copy link

I've started work on making the markdown docs work with snippet testing for Elasticsearch using the markdown from elastic/elasticsearch#124283. I'm not familiar with how this stuff works, so am learning as I go.

I discovered an issue related to the fact that the docs content was also re-organized as part of the markdown conversion.

https://github.com/elastic/elasticsearch/blob/v9.0.0-beta1/docs/reference/vectors/vector-functions.asciidoc?plain=1#L73

See this TESTSETUP comment. TESTSETUP has to be used on the first snippet in a file, like it is here, to denote setup for all of the snippets in the file.

https://github.com/elastic/elasticsearch/blob/d0f24003a84eb8139144feab44b0a1ca46d74104/docs/reference/query-languages/query-dsl-script-score-query.md?plain=1#L373

This is the new location of that content. It's been merged with other content/snippets in a new file. This results in the following error message when trying to run the tests:

TESTSETUP: wasn't first. TESTSETUP can only be used in the first snippet of a document.

So, moving these snippets around is basically like taking test cases out of their test suites and putting them into other ones, it doesn't really work.

Not sure what the solution is or just how big the impact is at the moment, just wanted to get a note here as it's close to the end of my day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants