| Message ID | 20260701074030.1090807-2-twoerner@gmail.com |
|---|---|
| State | New |
| Headers | show |
| Series | tests: standalone test-suite framework plus the first unit test | expand |
On Wed, 2026-07-01 at 03:40 -0400, Trevor Woerner via lists.yoctoproject.org wrote: > wic currently has no test mechanism of its own; it relies on the > oe-selftest from oe-core for all its testing, which means a full > bitbake build is needed to exercise even pure-Python logic. This > commit lays the groundwork for a small standalone suite that runs > from a plain checkout with nothing but pytest, so that logic can be > pinned down and kept stable as the code evolves. > > This commit adds the skeleton only; it does not add any tests. > > What this adds: > > - pyproject.toml: a "tests" optional-dependency group (pytest only) > so that "pip install -e .[tests]" pulls in what the suite needs, > plus a [tool.pytest.ini_options] section. The pytest options keep > a test's scratch directory only when that test fails, so repeated > runs do not accumulate leftover files. > > - tests/unit/ and tests/docs/: the directories that hold the > in-process unit suites and the suite documentation. Git cannot > track an empty directory, so a placeholder .gitkeep is committed > in each to create it. The .gitkeep files have no content and are > removed once real files land in those directories. > > - .gitignore: ignore the .pytest_cache/ directory that pytest > writes at the top of the checkout. > > - README.md: a Testing section pointing at the suite and at > tests/docs/, and a tests/* entry in the project layout list. > > AI-Generated: codex/claude-opus 4.7 (xhigh) > Signed-off-by: Trevor Woerner <twoerner@gmail.com> Reviewed-by: Paul Barker <paul@pbarker.dev> Best regards,
diff --git a/.gitignore b/.gitignore index eeb8a6ec4087..07992096c0fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ **/__pycache__ + +# pytest cache +/.pytest_cache/ diff --git a/README.md b/README.md index 75229421763c..497ebb1de0f0 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,20 @@ environment file or folder (generated via `bitbake -c rootfs_wicenv - `src/wic/*`: core engine, plugins, and helpers. - `src/bb/*`: various bitbake helpers that were brought along and used in other parts of wic. - `src/oe/*`: various oe-core helpers that were brought along and used in other parts of wic. +- `tests/*`: the standalone test suite and its documentation (see Testing below). + +## Testing + +wic ships a standalone test suite under `tests/` that runs from a plain +checkout, with no bitbake and no OpenEmbedded build required. The test +extras pull in everything the suite needs: + +``` +pip install -e ".[tests]" +``` + +See [tests/docs/](tests/docs/) for how to run the suite and the +conventions it follows. ## Contributing diff --git a/pyproject.toml b/pyproject.toml index fdc1ce0f5ece..d660e39007c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,11 @@ classifiers = [ Homepage = "https://git.yoctoproject.org/wic" Repository = "https://git.yoctoproject.org/wic" +[project.optional-dependencies] +tests = [ + "pytest >= 7.0", +] + [project.scripts] wic = "wic.cli:main" @@ -36,3 +41,10 @@ build-backend = "hatchling.build" [tool.hatch.version] path = "src/wic/cli.py" + +[tool.pytest.ini_options] +# Keep a test's scratch directory only when it fails; a passing test's +# tmp_path is removed automatically so repeated runs do not accumulate +# leftover files under the pytest base temp directory. +tmp_path_retention_policy = "failed" +tmp_path_retention_count = 1 diff --git a/tests/docs/.gitkeep b/tests/docs/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/unit/.gitkeep b/tests/unit/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1
wic currently has no test mechanism of its own; it relies on the oe-selftest from oe-core for all its testing, which means a full bitbake build is needed to exercise even pure-Python logic. This commit lays the groundwork for a small standalone suite that runs from a plain checkout with nothing but pytest, so that logic can be pinned down and kept stable as the code evolves. This commit adds the skeleton only; it does not add any tests. What this adds: - pyproject.toml: a "tests" optional-dependency group (pytest only) so that "pip install -e .[tests]" pulls in what the suite needs, plus a [tool.pytest.ini_options] section. The pytest options keep a test's scratch directory only when that test fails, so repeated runs do not accumulate leftover files. - tests/unit/ and tests/docs/: the directories that hold the in-process unit suites and the suite documentation. Git cannot track an empty directory, so a placeholder .gitkeep is committed in each to create it. The .gitkeep files have no content and are removed once real files land in those directories. - .gitignore: ignore the .pytest_cache/ directory that pytest writes at the top of the checkout. - README.md: a Testing section pointing at the suite and at tests/docs/, and a tests/* entry in the project layout list. AI-Generated: codex/claude-opus 4.7 (xhigh) Signed-off-by: Trevor Woerner <twoerner@gmail.com> --- changes in v3: - no change in this revision. changes in v2: - v1 submitted the entire test suite as a single commit; v2 breaks the work into a reviewable series, and this patch is one step of it. --- .gitignore | 3 +++ README.md | 14 ++++++++++++++ pyproject.toml | 12 ++++++++++++ tests/docs/.gitkeep | 0 tests/unit/.gitkeep | 0 5 files changed, 29 insertions(+) create mode 100644 tests/docs/.gitkeep create mode 100644 tests/unit/.gitkeep