Skip to content

Rust: wasm-bindgen tests run by wasm-pack test; maturin's and two release actions are read - #526

Merged
lefticus merged 11 commits into
cpp-best-practices:mainfrom
leftibot:wasm-tests
Dec 2, 2026
Merged

lefticus merged 11 commits into
cpp-best-practices:mainfrom
leftibot:wasm-tests

Conversation

@leftibot

@leftibot leftibot commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #525 — merge after it; until then this diff includes its commits.

Part of #482: the ast-grep row. The PR it is stacked on is #525, on #524.

What changes

  • wasm-bindgen tests. ast-grep's crates/wasm tests are #[wasm_bindgen_test] functions in tests/web.rs. CI runs them with wasm-pack test --node, through yarn test. Rust's test files now include #[wasm_bindgen_test], and wasm-pack test runs them, as the same runner as cargo test.
  • Actions that hid whether tests run. ast-grep's wheel and release jobs consist only of actions of other repositories, so whether CI runs the tests was unknown (ERROR). They are now read:
    • PyO3/maturin-action runs maturin <command> (default build) with its args.
    • katyo/publish-crates runs cargo publish.
    • taiki-e/upload-rust-binary-action runs cargo build --release.
    • taiki-e/create-gh-release-action and heinrichreimer/action-github-changelog-generator are added to the release group of policy/inert_actions.toml.

Corpus, before → after

These are the 10 corpus projects that use wasm-pack or one of the actions above.

Project Score Change
ast-grep 51.01 → 51.52 crates/wasm Rust tests now run, by wasm-pack test. Seventeen checks go from ERROR to their real verdict, because the actions no longer hide what the jobs run. tests-run goes ERROR → FAIL: crates/pyo3 has no Rust tests (see below), and one npm package's tests aren't run by CI. Before, the unknown hid that second finding.
ruff 51.64 → 51.64 crates/ruff_wasm and crates/ty_wasm count their own #[wasm_bindgen_test] file. Before, only the integration-test crates' files counted for them.
tokio 65.98 → 65.98 one more test file (280)
rmk 65.63 → 65.95 rynk/rynk-wasm: no tests found → run by cargo test. tests-run stays ERROR for other reasons.

tinymist, pydantic, PyO3, rumdl, sqlfluff and portable-atomic: unchanged.

Existing tests and snapshots changed

None. New tests are in tests/checks/test_tests_run.py.

Left for the maintainer

The crates/pyo3 unit still says "no tests found (#[test] functions)". It is a PyO3 binding, tested only by the Python tests in the same crate, which pytest runs. Whether Rust code tested through another language's tests counts is a policy question.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt

@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.46%. Comparing base (3dbe391) to head (66b0181).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #526      +/-   ##
==========================================
+ Coverage   99.44%   99.46%   +0.02%     
==========================================
  Files         374      379       +5     
  Lines       27339    28380    +1041     
  Branches     3440     3630     +190     
==========================================
+ Hits        27188    28229    +1041     
  Misses        151      151              

☔ View full report in Codecov by Harness.
📢 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.

@lefticus

lefticus commented Dec 1, 2026

Copy link
Copy Markdown
Member

Yes, tests run through another language should count. It's common for python fixtures to be used for C++, for example

leftibot added a commit to leftibot/project_validator that referenced this pull request Dec 1, 2026
…st-practices#526)

The maintainer: "tests run through another language should count. It's
common for python fixtures to be used for C++." A unit with no tests of
a language that builds a native module Python imports is tested by the
Python tests that import the module, run as CI runs them:

- A crate that depends on PyO3 builds the module its [lib] names (else
  its package, `-` as `_`): ast-grep's crates/pyo3, ast_grep_py, whose
  pytest tests now test its Rust.
- CMake's pybind11_add_module(name ...) and nanobind_add_module build
  the C++ module `name`; when a variable the evaluation does not know
  names it, whether it has tests is unknown (an error, as ever).

Python tests that import nothing of the module test nothing of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
leftibot and others added 4 commits December 1, 2026 14:39
…make check tests

Autotools projects (jq, tmux, curl, libzmq) had no C build system, so their
warning flags and `make check` tests were missed, and every make command CI
ran was unknown ("the makefile: none is found where make runs"): configure
writes the makefile, so it is not in the checkout.

- configure.ac is evaluated without running m4 or the shell
  (build_systems/autotools/configure_syntax.py, configure.py): macro calls
  and shell statements, `if`/`case` branches, AS_IF, AS_CASE, AC_ARG_ENABLE,
  AC_ARG_WITH, the flag macros (AX_CHECK_COMPILE_FLAG, AX_APPEND_COMPILE_FLAGS,
  AX_APPEND_FLAG, gl_WARN_ADD) where the compiler accepts the flag, macros
  the file defines, AC_SUBST and AM_CONDITIONAL. `test "x$GCC" = xyes` is
  the GCC-like compilers; any other test is a requirement as written.
  tmux's LTO probe, which sets -Werror for one compile check and restores
  CFLAGS, leaves no -Werror.
- Each Makefile.am is read with the configure.ac above it (automake.py):
  AM_CFLAGS, AM_CXXFLAGS, AM_CPPFLAGS and each built target's own flags,
  through Automake conditionals, with configure's substitutions expanded.
- Autotools (Makefile.am) is a build system of C and C++; `make check`,
  `distcheck` or `recheck` where a Makefile.am is (or in a build tree
  outside the checkout) runs the tests TESTS and check_PROGRAMS name.
- Where no makefile is in the checkout but a Makefile.am is, make reads the
  Makefile.am's rules, and Automake's own targets (policy/automake.toml) are
  known, not unknown.

Part of cpp-best-practices#470

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…ctices#470)

Brackets around a shell test (an m4 quote, stripped), several assignments
on a line, a case pattern on a line of its own, AS_IF and AS_CASE without
their last branch, AC_SUBST with a value, unquoted arguments holding
parentheses, a body-less AC_DEFUN, a stray else or fi, an assignment no
build reaches, a configure.ac past the bound on conditions, and a
Makefile.am variable set only where it is not used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
)

Like configure.ac's most_defined_calls, how deep a Makefile.am reference
is followed is a limit, not a constant in the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…ystem (cpp-best-practices#470)

The maintainer asked that the message read the same for every build
system: "warnings are not treated as errors in CI configuration or the
build files", rather than listing CMake files, presets and meson.build
(leaving out configure.ac), or fpm's flags for Fortran. The hints, which
say how in each build system, are unchanged, as is CMake's own presets
finding. test_warnings_as_errors' SEARCHED and the bare_c, bare_cpp,
bare_fortran and buildable snapshots change to match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
leftibot added a commit to leftibot/project_validator that referenced this pull request Dec 1, 2026
…st-practices#526)

The maintainer: "tests run through another language should count. It's
common for python fixtures to be used for C++." A unit with no tests of
a language that builds a native module Python imports is tested by the
Python tests that import the module, run as CI runs them:

- A crate that depends on PyO3 builds the module its [lib] names (else
  its package, `-` as `_`): ast-grep's crates/pyo3, ast_grep_py, whose
  pytest tests now test its Rust.
- CMake's pybind11_add_module(name ...) and nanobind_add_module build
  the C++ module `name`; when a variable the evaluation does not know
  names it, whether it has tests is unknown (an error, as ever).

Python tests that import nothing of the module test nothing of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
leftibot and others added 7 commits December 1, 2026 18:20
…pp-best-practices#470)

Conditions are kept for the whole process, so a second reading of the
same configure.ac builds no new nodes and never reaches the lowered
bound. mutmut runs the suite more than once in one process, so the test
failed in its clean run on cpp-best-practices#532 and cpp-best-practices#533. Each reading now gets names of
its own, and the test reads twice to hold that in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
pybind11 defines its C++ tests only as executables of tests/ that custom
targets run (`add_custom_target(cpptest COMMAND $<TARGET_FILE:test_with_catch>)`),
and CI builds the targets; luanti builds its unit tests into the engine and
CI runs `./bin/luanti --run-unittests`. CMake's add_executable and
target_sources are now read: an executable with a source in a test
directory, or named as a test (`test_ban.cpp`), is a test executable, unless
CTest's tests already run it. A run of one, by a custom target's command or
by CI naming the built file, runs its tests; one built with the product's
sources too runs them only when an option asks for them (policy/tests.toml).

Part of cpp-best-practices#482.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…t; a container may hold the project

pi-hole's CI runs `test/run.sh`, which picks its container runtime with
`if …; then RUNTIME="docker"; elif …; then RUNTIME="podman"; else exit 1; fi`,
cds into `"${SCRIPT_DIR}"`, and runs bats in a container of the image it
builds from the checkout: `"${RUNTIME}" run … bash -euo pipefail -c 'cd
/etc/.pihole/test; exec libs/bats/bin/bats "$@"'`. None of it was followed.

- facts/shell_values.py follows a script's syntax tree along every path
  (if, case, loops, functions where they are called, nothing after exit)
  and gives each command the values of the assignments that reach it; a
  variable is known only when every one of them is. It replaces the
  set-once constants: a command naming a variable of several values is a
  command for each, up to policy/limits.toml's new `most_values`. A
  function's body is followed where it is called, once per set of values,
  four at most; `"$@"` is what the script file was run with, until a shift
  (SwiftFormat's `./format.sh --lint`).
- Expanders that read none of the project's files (launchers, a shell's
  command string, docker run) run in a directory the project does not
  hold too, such as one a variable names.
- docker run's command runs in a container: it carries `container` in its
  environment (as podman sets it), and an absolute `cd` there moves to the
  container's own directory (IN_CONTAINER), not out of the project: a run
  there covers the project heuristically, as one in a directory a variable
  names does.
- `bash -euo pipefail -c '…'` is a command string: an option cluster that
  ends in `o` takes the next word.

Part of cpp-best-practices#482.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
… code (cpp-best-practices#482)

Tests: values put together past most_values (three systems by three
architectures), nothing after exit, an array declared without a value, a
function called again with the same values, one that always exits, and a
local that leaves the caller's value as it was.

_Analysis.value was never called; it is removed. A loop starts from a
state, so what it holds is never None: join is split so that the loop
uses `extended` (a state joined with a path that may have ended), and the
check for None after its passes, which nothing could reach, is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…pp-best-practices#482)

Beside most_values, the times a loop's body is followed and the sets of
values a function's body is followed with are limits, not constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…ease actions are read

ast-grep's crates/wasm tests are `#[wasm_bindgen_test]` functions, which
CI runs with `wasm-pack test --node` through `yarn test`: they now count as
is an action no longer hide whether the tests run: PyO3/maturin-action runs
`maturin build` with its args, katyo/publish-crates runs `cargo publish`,
taiki-e/upload-rust-binary-action runs `cargo build --release`, and
taiki-e/create-gh-release-action and
heinrichreimer/action-github-changelog-generator release, running none of
the project's code (policy/inert_actions.toml).

Part of cpp-best-practices#482.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…st-practices#526)

The maintainer: "tests run through another language should count. It's
common for python fixtures to be used for C++." A unit with no tests of
a language that builds a native module Python imports is tested by the
Python tests that import the module, run as CI runs them:

- A crate that depends on PyO3 builds the module its [lib] names (else
  its package, `-` as `_`): ast-grep's crates/pyo3, ast_grep_py, whose
  pytest tests now test its Rust.
- CMake's pybind11_add_module(name ...) and nanobind_add_module build
  the C++ module `name`; when a variable the evaluation does not know
  names it, whether it has tests is unknown (an error, as ever).

Python tests that import nothing of the module test nothing of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
@lefticus
lefticus merged commit 0bd2f9c into cpp-best-practices:main Dec 2, 2026
35 checks passed
@lefticus
lefticus deleted the wasm-tests branch December 2, 2026 05:06
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

Successfully merging this pull request may close these issues.

2 participants