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
nullis 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
testsinto the app of the matrixapp, generated indirectorywith the packagepackageName, 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
fluttercommands that runtestsin an app once their files are in it:flutter pub addof their dev dependencies, if they have any;flutter analyze, since the tests follow the rules of the analysis of the app too; andflutter test, which runs every test of the app. -
matrixCommand(
List< String> arguments, String directory) → List<String> -
The command that the matrix runs for
flutterwithargumentsindirectory:flutterwith them, but forflutter analyzein a directory whose path has letters beyond ASCII, whereflutter analyzeof Flutter 3.44 and 3.47 fails on every system (https://github.com/flutter/flutter/pull/191377). There it isdart 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 (seeContractHarness.casesOfAll). -
runAppTests(
GeneratedApp generated, MatrixApp app, List< MatrixAppTest> tests, {MatrixFlutter flutter = _flutter, FileSystem fileSystem = const LocalFileSystem()}) → Future<(int, String)> -
Adds
teststogenerated, the app of the matrixapp, with addAppTests, and runs the appTestCommands withflutteruntil 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
moduleswithroleOptionsindirectory, with the options of CI, analyzes each withflutter analyze, and, in an app that some of theappTestsapply to, adds them and runs every test of the app withflutter 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 theappTestsapplies to some app; 1 otherwise.
Typedefs
-
MatrixAnalyze
= Future<
(int, String)> Function(String directory) -
Analyzes the app in
directoryand 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 createwithargumentsand gives it toonCreated; returns the exit code. -
MatrixFlutter
= Future<
(int, String)> Function(List<String> arguments, String directory) -
Runs
flutterwithargumentsindirectoryand returns the exit code and the output. -
MatrixTest
= Future<
(int, String)> Function(GeneratedApp generated, MatrixApp app, List<MatrixAppTest> tests) -
Adds
teststogenerated, the app of the matrixapp, and runs them withflutter 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.