Repository navigation
Shell: a variable takes the values of every assignment that reaches it; a container may hold the project - #525
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #525 +/- ##
==========================================
+ Coverage 99.44% 99.46% +0.01%
==========================================
Files 374 379 +5
Lines 27339 28286 +947
Branches 3440 3622 +182
==========================================
+ Hits 27188 28135 +947
Misses 151 151 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
leftibot
force-pushed
the
container-tests
branch
2 times, most recently
from
December 1, 2026 19:49
3730164 to
2ae88a3
Compare
…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
force-pushed
the
container-tests
branch
from
December 1, 2026 22:23
2ae88a3 to
36b10b0
Compare
…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
leftibot
force-pushed
the
container-tests
branch
from
December 2, 2026 01:51
36b10b0 to
a7c9613
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #524 — merge after it; until then this diff includes its commits.
Part of #482: the pi-hole row. The PR it is stacked on is #524.
What blocked pi-hole
CI runs
DISTRO=… bash test/run.sh, and that script was already followed. The script:if …; then RUNTIME="docker"; elif …; then RUNTIME="podman"; else …; exit 1; fi;"${SCRIPT_DIR}";"${RUNTIME}" run … bash -euo pipefail -c 'cd /etc/.pihole/test; exec libs/bats/bin/bats "$@"'.Three things stopped this from counting:
"${RUNTIME}"was never resolved.bash -euo pipefail -cwasn't read as a command string.cd /etc/.pihole/testwent outside the project.What changes
Variable values from every assignment that reaches a command (
facts/shell_values.py, new). The analysis walks a script's syntax tree along every path:if, and each arm of acase(plus no arm, unless a*)arm exists);localvariables kept to it;exit, and a function's own path ends atreturn;A variable is known only when every assignment that reaches it is known: text, other known variables, or the value the command running the script gives it. A command substitution,
read,getopts,mapfile,printf -v,unset,let, arithmetic,${X:=…}, arrays,for,eval,sourceor.leave it unknown. A command that names a variable with several values becomes one command per value (docker and podman), up tomost_valuesinpolicy/limits.toml(new[shell]table entry; 8). A function body is followed once per set of values it is called with, four at most; after that, what it assigns is unknown."$@"is the script file's own arguments (./format.sh --lint), until ashiftorset, and not inside functions. This replaces the old set-once constants (_Constants), which were unsound across branches:if x; then A=1; fi; $AresolvedAto 1.Expanders that read no project files run in any directory (
CommandExpander.anywhere: launchers, xargs,find -exec, shell command strings,docker run). Expanders that read project files (makefiles, package scripts) still run only in the project's own directories.Containers.
docker run/podman runalready launched their command in the directory where they ran. That command now also getscontainer=<engine>in its environment, as podman sets it. An absolutecdinside the container moves to the container's own directory (IN_CONTAINER,$(container)/etc/.pihole/test) instead of out of the project. A run there covers the project heuristically, like one in a directory a variable names.bash -euo pipefail -c '…': a short-option cluster that ends inotakes the next word.Corpus, before → after (61 projects: pi-hole, every corpus project whose workflows use
docker run, and 30 that run shell scripts)./format.sh --lintruns"$FORMAT_DIR/$ASSET" . --cache ignore "$@", withASSETset in eachcasearm and"$@"=--lint. The check stays FAIL for Ruby and Shell.benchmark/run-benchmark benchmark/go/runis followed through$@togo build, so the auxiliary Go benchmark has 2 OSes. Still WARN.The other 58 projects are unchanged, including nvm, whose
nvm.shcalls its functions from everywhere (run time is the same as on the base, about 1.5 minutes).Existing tests and snapshots changed
tests/test_unread_runners.py:docker run's launched command carriescontainerin its environment (test_an_image_named_by_an_expression…now expects it).tests/test_policy.py: the limits table test now covers[shell].tests/test_expansion.py::test_a_variable_assigned_twice_or_from_a_command_is_not_resolvedis unchanged and still passes. WithT=ruff; T=black; $T,$Tnow resolves toblack, which is correct, so it is still neverruff.For the maintainer
ADDs the checkout to/etc/.pihole.SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"is still not resolved. It is a command substitution, so the directory stays unknown. Launchers now work there, but makefiles and package scripts in it are not read.Coverage
codecov/patch was 98.66%.
tests/test_shell_values.pyaddsShellValuesPathTests, which covers:most_values(three systems by three architectures)exitlocalthat leaves the caller's value as it wasTwo pieces of dead code are removed:
_Analysis.value, which nothing called.Nonestate after its passes. A loop always starts from a state, so the check could never be true.joinis split so that the loop usesextended(a state joined with a path that may have ended).The loop pass count and function call count are now
policy/limits.toml'sshell.loop_passesandshell.function_calls, following #517's change. Patch coverage locally: 334/334 for this PR's own diff, 1137/1137 for the stack against main.🤖 Generated with Claude Code
https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt