All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trevor Woerner <twoerner@gmail.com>
To: yocto-patches@lists.yoctoproject.org
Subject: [wic][PATCH v4 1/6] tests: add the standalone unit-test suite skeleton
Date: Mon,  6 Jul 2026 18:28:59 -0400	[thread overview]
Message-ID: <20260706222904.664863-2-twoerner@gmail.com> (raw)
In-Reply-To: <20260706222904.664863-1-twoerner@gmail.com>

wic has no test mechanism of its own; it relies on the oe-selftest from
oe-core, which needs a full bitbake build to exercise even pure-Python
logic. This starts a small standalone suite that runs from a plain
checkout, with no BitBake and no OpenEmbedded build.

This is the skeleton only and adds no tests. It gives pyproject.toml a
"tests" extra (pytest and the just command runner) and a pytest config
section, adds a justfile with default and tests recipes, creates
tests/unit/ with a placeholder .gitkeep, ignores .pytest_cache/, and
adds a README Testing section covering install and how to run the suite.

AI-Generated: codex/claude-opus 4.8 (xhigh)
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
changes in v4:
- drop the tests/docs/ documentation tree; the suite now ships with
  a short README Testing section only.
- add a justfile as the command runner and drop the run-tests.sh
  wrapper; just joins the tests extra.
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          |  1 +
 README.md           | 15 +++++++++++++++
 justfile            | 10 ++++++++++
 pyproject.toml      | 14 ++++++++++++++
 tests/unit/.gitkeep |  0
 5 files changed, 40 insertions(+)
 create mode 100644 justfile
 create mode 100644 tests/unit/.gitkeep

diff --git a/.gitignore b/.gitignore
index eeb8a6ec4087..a0f016bc5823 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 **/__pycache__
+.pytest_cache/
diff --git a/README.md b/README.md
index 75229421763c..c9c38eb5e98a 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,21 @@ environment file or folder (generated via `bitbake -c rootfs_wicenv
 - `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.
 
+## Testing
+
+wic's test suite lives under `tests/` and runs from a plain checkout
+with nothing but `pytest`; it needs no BitBake and no OpenEmbedded
+build. Install the test extras and run it:
+
+```
+pip install -e ".[tests]"
+just tests
+```
+
+The test extras include [just](https://just.systems/), the command
+runner used to drive the suite; run `just` on its own to list the
+available recipes.
+
 ## Contributing
 
 Please send all patches, comments, or questions to the yocto-patches
diff --git a/justfile b/justfile
new file mode 100644
index 000000000000..41a9d3d236f4
--- /dev/null
+++ b/justfile
@@ -0,0 +1,10 @@
+# wic test-suite command runner. Run `just` to list recipes.
+
+# List the available recipes.
+default:
+    @just --list
+
+# Run the test suite. Extra args pass through to pytest
+# (e.g. `just tests -k <expr>` or `just tests tests/unit`).
+tests *args:
+    pytest {{args}}
diff --git a/pyproject.toml b/pyproject.toml
index fdc1ce0f5ece..e60c4fcc1595 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,6 +21,12 @@ classifiers = [
 Homepage = "https://git.yoctoproject.org/wic"
 Repository = "https://git.yoctoproject.org/wic"
 
+[project.optional-dependencies]
+tests = [
+    "pytest >= 9.1.1",
+    "rust-just >= 1.55.1",
+]
+
 [project.scripts]
 wic = "wic.cli:main"
 
@@ -36,3 +42,11 @@ build-backend = "hatchling.build"
 
 [tool.hatch.version]
 path = "src/wic/cli.py"
+
+[tool.pytest.ini_options]
+testpaths = ["tests"]
+# Keep a test's scratch directory only when that test fails, and keep
+# just the most recent failing session, so repeated runs do not pile up
+# leftover directories under the pytest base temp directory.
+tmp_path_retention_policy = "failed"
+tmp_path_retention_count  = 1
diff --git a/tests/unit/.gitkeep b/tests/unit/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
-- 
2.50.0.173.g8b6f19ccfc3a



  reply	other threads:[~2026-07-06 22:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 22:28 [wic][PATCH v4 0/6] tests: standalone test-suite framework plus the first unit test Trevor Woerner
2026-07-06 22:28 ` Trevor Woerner [this message]
2026-07-06 22:29 ` [wic][PATCH v4 2/6] tests: add conftest with a wic-import preflight and session banner Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 3/6] tests: add optional coverage reporting Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 4/6] add ruff linting Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 5/6] bb/utils: import errno so mkdirhier's OSError handler works Trevor Woerner
2026-07-06 22:29 ` [wic][PATCH v4 6/6] tests/unit/test_bb_utils: cover mkdirhier() Trevor Woerner
2026-07-08 14:27 ` [yocto-patches] [wic][PATCH v4 0/6] tests: standalone test-suite framework plus the first unit test Paul Barker
2026-07-09  3:50 ` Trevor Woerner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260706222904.664863-2-twoerner@gmail.com \
    --to=twoerner@gmail.com \
    --cc=yocto-patches@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.