Skip to content

docs: Improve documentation for writing and running tests #17301

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andrewleech
Copy link
Contributor

Summary

I wanted to use some LLM assitance to create new unit tests. To aid in this process, it helps to have comprehensive docs to inform the LLM's how best to write and run unit tests, so I started with that.

These updates were mostly written with Google's gemini-2.5-pro-exp-03-25 though some final review and cleanup was done with Anthropic Claude 3.7

The updated documentation provides:

  • More detailed explanation of the test directory structure and key runner scripts.
  • Clearer instructions on writing simple tests, including the use of print() and .exp files.
  • Expanded coverage of run-tests.py options for targeting specific devices, filtering tests, and handling failures.
  • An overview of how run-tests.py works internally (feature detection, skipping, execution, comparison).
  • Guidance on writing advanced tests (skipping, unittest, special handling, float/endian considerations).
  • Introduction to multi-instance testing with run-multitests.py, including how to write tests with instanceN() functions and use the multitest helper for coordination.
  • Examples of running multi-instance tests with different instance types.

Testing

Just manual review of the content.

Copy link

codecov bot commented May 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (3d19a8b) to head (ef5d948).
Report is 250 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17301   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files         169      169           
  Lines       21898    21898           
=======================================
  Hits        21579    21579           
  Misses        319      319           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@agatti
Copy link
Contributor

agatti commented May 23, 2025

Not sure if it's important enough to be featured in that document, but maybe it'd be useful to document the special test file name prefixes/suffixes recognised by tests/run-tests.py that act as rudimentary feature checks to skip certain tests?

For example, test files whose name starts with native_ or viper_ will be automatically skipped if @micropython.native or @micropython.viper support was not detected in the target interpreter, and so on. There's a dozen or so of those tags so maybe it's not worth documenting them all, but again, the LLM may sort all that stuff out by itself :)

@Josverl
Copy link
Contributor

Josverl commented May 23, 2025

I think that is a good addition

@andrewleech
Copy link
Contributor Author

special test file name prefixes/suffixes

Yeah I do think it'd be helpful to have these itemised somewhere as it's certainly not abvious for new developers!

I'm not too sure about how best to divide what does in the rst docs and what goes in the readme here... I kinda think the readme is perhaps better for "internals" things like that which are maybe of more interest to low level developers, with the rst docs more focussing on "end users" interested in running tests?

@agatti
Copy link
Contributor

agatti commented May 26, 2025

I personally use the README files as a quickstart guide myself, always favouring explicit documentation if it's available. It used to be like that back then, when dinosaurs still roamed freely and whatnot, so maybe somebody from a younger demographics should weigh in on this.

Considering the users/developers split, I wonder if this possible TOC for three (or two) documents - names are generic on purpose - can be a starting point for a discussion on this:

  • "Quickstart"/"End users"
    • Standard tests
      • How to run tests (simplified version, no need to bring emitters and mpy in, f.ex.)
      • How a successful run should look like
      • Where to look for failure info to send back to a developer
    • Performance benchmarks
      • How to run benchmarks (simplified version)
      • How to read output and compare with previous runs
  • "Developers"
    • How to run tests (what's left to document)
    • Standard tests (almost everything that's in writingtests.rst for standard tests, maybe skip more niche sub-topics)
    • Multi-instance tests
    • SSL tests
    • Performance benchmarks (what's left to document)
  • "Internals" (fold this into "Developers" if needed)
    • How run-tests.py enumerates tests and how it decides which ones to skip
    • Natmod tests
    • Internal benchmarks
    • Everything else that's not in "Developers" ?

I can help out on the natmod tests bit if needed, as long as somebody else fixes the grammar :)

@Josverl
Copy link
Contributor

Josverl commented May 27, 2025

for context : I just got an inflatable Dino for my birthday.
There is no need to settle on just a single topilogy
With Sphinx & MyST it is simple to pull in the Readme.MD and other markdown docs into the online documentation.
That allows the information to be found and accessed va different ways and personal preferences , without increasing the effort to maintain it.
( possibly that is also a way to pull in some of the information in the Wiki , which is rather hard to search )

This commit reorganizes the test suite documentation to provide clearer
separation between end-user and developer information:

* tests/README.md: Simplified to serve as a quick start guide focusing
  on essential commands for running tests and understanding results.

* docs/develop/writingtests.rst: Converted to an index page that links
  to the two new detailed guides below.

* docs/develop/test_quickstart.rst: New guide for end users covering:
  - Running standard tests with run-tests.py
  - Understanding test results and handling failures
  - Basic performance benchmarking
  - Multi-instance test basics
  - SSL/TLS test setup

* docs/develop/test_developers.rst: New comprehensive guide for developers
  covering:
  - Test suite organization and structure
  - Writing different types of tests
  - Advanced run-tests.py usage
  - Detailed filename pattern documentation for automatic test skipping
  - Multi-instance test development
  - Native module and internal benchmark testing

The new structure eliminates duplication and makes it easier for both
end users and developers to find the information they need.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
@andrewleech
Copy link
Contributor Author

Thanks for the suggestions, I've restructured the content in the latest push. I haven't got the rst docs importing the readme, not sure how much adjusting would be needed in the sphinx stuff to support that?
The readme includes links to the rst docs which would need to be stripped out or handled differently if it was included directly?
I don't think there's too much duplication there really...

@agatti
Copy link
Contributor

agatti commented May 28, 2025

The content looks pretty streamlined now, that's great. I'm not much of a sphinx user so I can't comment on how rst inclusion/handling can be improved - but content-wise it's really good!

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

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy