tarpit 0.1.2
tarpit: ^0.1.2 copied to clipboard
Find widget-test code that can hang in FakeAsync, and fail a stalled testWidgets fast. An analyzer-based CLI (text, JSON, SARIF) plus a watchdog.
Changelog #
0.1.2 #
--test-function <name>(repeatable): also check bodies of customtestWidgetswrappers. The body is still the second positional argument and must be a function literal. Thanks @nahuel007ng (#5).
0.1.1 #
- Watchdog: a test whose body returns while the rest of the test waits on
a microtask nothing flushes now fails with a
TarpitStallinstead of hanging. Engine image work (toByteData,toImage,getNextFrame) awaited outsidetester.runAsyncas the body's last await did this (flutter/flutter#50783). The watchdog now runs until the test's tear-down, and the report says when the body had already returned (TarpitStall.bodyReturned). - Docs: engine image calls do not block the test isolate, and the watchdog
catches them; the README, doc/rules.md and the
engine-asynctext said otherwise.
0.1.0 #
First release.
tarpitcommand: checkstestWidgetsbodies with the Dart analyzer (resolved AST, not text matching) for code that stalls the FakeAsync zone. Code insidetester.runAsyncis skipped; the same patterns inside nested closures, or in files whose imports do not resolve, are reported as info.- Rules:
fake-delay,real-io,isolate-hop,engine-async(errors),blocking-sleep,endless-settle(warnings),asset-string(info), andbad-suppressionfor malformed suppression comments. - Suppressions with a required reason:
// tarpit:allow <rule-id> <reason>for one line,// tarpit:allow-file <rule-id> <reason>for a file. - Text, JSON (
tarpit-json,formatVersion: 1) and SARIF 2.1.0 output;--fail-on,--output,--rules; exit codes 0 / 1 / 2. - Watchdog (
package:tarpit/tarpit.dart):tarpitWidgets,watchTesterandTarpit.stallAfterfail a widget test that makes no progress (no pump, no frame) for 30 seconds with aTarpitStalldescribing the state it was stuck in, then let the next test run.package:tarpit/flutter_test.dartis flutter_test with thattestWidgets, for a one-line opt-in.