matrix library

The matrix of apps that the continuous integration of SMF generates with smf create and analyzes with Flutter: every app that the contract harness builds for a set of modules, and the apps with every module.

It serves the repository of SMF, and its API may change in any release.

Classes

MatrixApp
An app of the matrix: the modules to ask for, which name every module of the app so that no question is left, and the options of its roles.
MatrixAppTest
Tests that the matrix adds to the apps it generates and runs with flutter test: the files of a directory for the apps that appliesTo accepts.
MatrixCommands
The commands that runMatrix runs for each app, which tests of the matrix may replace; each left null is the real one.

Functions

addAppTests(List<MatrixAppTest> tests, {required MatrixApp app, required String directory, required String packageName, FileSystem fileSystem = const LocalFileSystem()}) → List<String>
Copies the files of tests into the app of the matrix app, generated in directory with the package packageName, with the placeholders of the files filled, and returns the paths of the files in the app; see MatrixAppTest.directory.
appTestCommands(List<MatrixAppTest> tests) → List<List<String>>
The flutter commands that run tests in an app once their files are in it: flutter pub add of their dev dependencies, if they have any; flutter analyze, since the tests follow the rules of the analysis of the app too; and flutter test, which runs every test of the app.
matrixCommand(List<String> arguments, String directory) → List<String>
The command that the matrix runs for flutter with arguments in directory: flutter with them, but for flutter analyze in a directory whose path has letters beyond ASCII, where flutter analyze of Flutter 3.44 and 3.47 fails on every system (https://github.com/flutter/flutter/pull/191377). There it is dart analyze --fatal-infos, which reports the same issues.
matrixOf(List<SmfModule> modules, {Map<String, String?> roleOptions = const {}}) → Future<({List<MatrixApp> apps, List<ContractResult> failed})>
The apps of the matrix of modules: every app that the contract harness builds for them, which covers every module and every provider with each subset of the roles it uses, and the apps with every module, one for each combination of the providers of roles that take one (see ContractHarness.casesOfAll).
runAppTests(GeneratedApp generated, MatrixApp app, List<MatrixAppTest> tests, {MatrixFlutter flutter = _flutter, FileSystem fileSystem = const LocalFileSystem()}) → Future<(int, String)>
Adds tests to generated, the app of the matrix app, with addAppTests, and runs the appTestCommands with flutter until one fails; returns its exit code and the output up to it, which says which command failed, or 0 and the output of all. A problem of the files of the tests is a failure too, with the exit code 1.
runMatrix(List<SmfModule> modules, {required String directory, Map<String, String?> roleOptions = const {}, List<MatrixAppTest> appTests = const [], Set<String>? only, void log(String line)?, MatrixCommands commands = const MatrixCommands()}) → Future<int>
Generates every app of the matrixOf of modules with roleOptions in directory, with the options of CI, analyzes each with flutter analyze, and, in an app that some of the appTests apply to, adds them and runs every test of the app with flutter test. Returns the exit code: 0 if every app was generated with every module and every step that the options of CI do not leave for later, has no issue and passes its tests, and each of the appTests applies to some app; 1 otherwise.

Typedefs

MatrixAnalyze = Future<(int, String)> Function(String directory)
Analyzes the app in directory and returns the exit code and output of the analyzer.
MatrixCreate = Future<int> Function(List<String> arguments, void onCreated(GeneratedApp app))
Generates the app of smf create with arguments and gives it to onCreated; returns the exit code.
MatrixFlutter = Future<(int, String)> Function(List<String> arguments, String directory)
Runs flutter with arguments in directory and returns the exit code and the output.
MatrixTest = Future<(int, String)> Function(GeneratedApp generated, MatrixApp app, List<MatrixAppTest> tests)
Adds tests to generated, the app of the matrix app, and runs them with flutter test; returns the exit code of the first command that fails and the output up to it, or 0 and the output of all.

Exceptions / Errors

MatrixAppTestException
A problem of the files of MatrixAppTests, which addAppTests finds before it copies them into an app.