prepareBridges method
Generate bridges once for a project without running any script.
This method:
- Deletes the existing binary to verify regeneration
- Generates bridges using the in-memory generator
- Compiles the test runner to a native binary
Use this in setUpAll to prepare once, then call runScriptOnly
for each test script.
Returns true if generation and compilation succeeded, false otherwise.
On failure, the errors are stored and can be retrieved from subsequent
runScriptOnly calls (which will return a failed result immediately).
Example:
setUpAll(() async {
final ok = await tester.prepareBridges(config);
expect(ok, isTrue, reason: 'Bridge generation failed');
});
test('feature X', () async {
final result = await tester.runScriptOnly(config, 'test/x.dart');
_expectSuccess(result, 'feature X');
});
Holds the project's fixture lock for the whole pipeline (see
withFixtureLock): suites that share a fixture project run concurrently
under dart test, and one must not resolve, generate or compile while
another is rewriting the same tree.
Implementation
Future<bool> prepareBridges(BridgeConfig config) => withFixtureLock(
p.join(projectPath, '.dart_tool', 'd4rt_prepare_bridges.lock'),
() => _prepareBridges(config),
);