#!/usr/bin/env bash # Self-test for bin/lint-unity-exit.sh. # # This exists because the scanner has been wrong twice in review, both times in a way that looked # fine by inspection: layered regexes cannot tokenise C++, so a `/*` inside a string literal flipped # comment state, a greedy `.*` swallowed code between two comments, `myexit(...)` matched the `exit` # exemption as a substring, and `==` matched the assignment exemption. Every one of those is pinned # below as a fixture, so the next rewrite has to keep them all passing. # # Each fixture is a snippet of C++ plus the exact diagnostics it must produce, as a comma-separated # list of : - empty for none. Asserting the locations rather than just "did it say # anything" is what catches a rule that reports the right number of findings in the wrong places, or # that collapses two findings on one line into one. # # Not a Unity suite and not a test_* directory, so outside the suite count run-tests.sh derives # from test/ - same arrangement as bin/test-state-check.sh, and for the same reason: it asserts # the behaviour of a process. # # Usage: ./bin/test-lint-unity-exit.sh (exit 0 = all fixtures behaved) set -uo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$ROOT_DIR" || exit 1 WORK="$(mktemp -d -t meshlintunity.XXXXXX)" trap 'rm -rf "$WORK"' EXIT mkdir -p "$WORK/test/probe" PASSES=0 FAILURES=0 # expect ":[,:...]"