appTestsReport function
What the checks of the repository need to know of each of tests, as
JSON, which the matrix tools print with --app-tests --json
(tools/app_tests_test.dart):
directory, the directory of its files;modules, the ids of the modules of the matrix that the package whoseapp_testsholds the directory declares, bypackages, the package of each module of the matrix, such assmf_home_flutterforhome;appliesWithout, the names of the apps of the matrix that it applies to once those modules are taken out of their modules, and out of their MatrixApp.everyModuleWith, with the same name, role options and hook;uses, the modules of the matrix whose ids it uses: those that, with another id in their place in an app of the matrix, change whether it applies to the app, the values of its files there, the files it generates there or the values it gives the app there (see MatrixAppTest.envValues). Each has the id of the module (module), its package (package) and the names of those apps (apps), in the order of the apps;roles, the ids of the roles whose contract it checks (MatrixAppTest.roles), such asrouter;roleFunctionUses, the uses, in its Dart files, of the functions of the roles ofmodules, the modules of the matrix, that an app can have several providers of. Each has the path of the file from the directory and the function (use), such astest/a_test.dart: createCrashReporter() of lib/core/crash_reporting/crash_reporter.dart, and the id of the role of the function (role), such ascrash_reporting;envKeys, the keys that it gives the apps of the matrix values of (MatrixAppTest.envValues), each with the module that gives the app the key (module) and its package (package), or else the id of the role whose template gives it (role), asenvtells them (see MatrixEnv.keys), allnullwhere nothing in the app gives the key, and the names of those apps (apps), in the order of the apps and of the keys;answer, the answer of CI that its probe asks for (MatrixStartProbe.answer), only if it has one, so that the checks of the repository find an answer that a workflow gives the script that starts the apps and that no probe asks for, which the script would skip in every app.
The app tests that a package of modules keeps test its modules, so they
apply only to the apps that have one of them, whichever other modules
the matrix has: a check of the start of every app that the provider of
the app entry kept would reach no app with another provider. And what
they depend on of the other modules of an app comes from its roles
(MatrixApp.hook), not from the ids of its modules: the screen that an
app starts on is the choice of the router role, which a second feature
that can start the app, or --start, changes while the app keeps the
modules it had. apps gives the apps of the matrix, which it builds
once, if there are tests.
An app test of a module runs in every app with its module, whatever else
the app has, so it uses no function of a role that reaches every
provider of the role, such as createCrashReporter(), whose reporter
reports to all of them: what another provider does, only the tests of
its own module know. A test of the contract of such a role calls them,
since what the role does with every provider is its contract, and looks
only at what reaches the providers that it knows; the checks of the
repository tell it from the others by its roles and the role of each
use. Such functions are the public top-level functions of the files of
the interface of each role that an app can have several providers of,
in the app of each of its providers that the contract harness renders
first, and a use is a call or a tear-off through an import of their
file as package:{{app_name}}/..., with a prefix or without. Throws a
StateError if the harness renders no such app, or one without a file
of the interface of the role.
Implementation
Future<List<Map<String, Object>>> appTestsReport(
List<MatrixAppTest> tests, {
required List<SmfModule> modules,
required Map<ModuleId, String> packages,
required Future<List<MatrixApp>> Function() apps,
MatrixEnv? env,
FileSystem fileSystem = const LocalFileSystem(),
}) async {
final appTests = {
for (final package in {...packages.values})
package: await appTestsDirectoryOf(package),
};
final functions = await _roleFunctionsOf(modules);
List<MatrixApp>? all;
final report = <Map<String, Object>>[];
for (final test in tests) {
final matrix = all ??= await apps();
final ids = _modulesKeeping(test, packages, appTests);
report.add({
'directory': test.directory,
'modules': [for (final id in ids) id.value],
'appliesWithout':
ids.isEmpty ? const <String>[] : _appliesWithout(test, ids, matrix),
'uses': _usesReportOf(test, matrix, packages),
'roles': [for (final role in test.roles) role.id],
'roleFunctionUses': _roleFunctionUses(
test.directory,
functions,
fileSystem,
),
'envKeys': _envKeysGivenBy(test, matrix, env, packages),
if (test.startProbe?.answer case final answer?) 'answer': answer,
});
}
return report;
}