appTestsFor function

List<MatrixAppTest> appTestsFor(
  1. MatrixApp app,
  2. List<MatrixAppTest> named,
  3. List<MatrixAppTest> all
)

The tests of all to add to app, an app of the matrix that smf create generated outside it, such as one that CI starts on a device, for the tests named: those, and, if one of them runs the probes of the tests of the app (MatrixAppTest.readsStartProbes), such as the start check, each other test of all with a probe (MatrixAppTest.startProbe) that applies to app, in the order of all. So the start check goes through the roles of the app, whichever they are, without the caller naming the tests of the roles.

Throws a MatrixAppTestException if a test of named does not apply to app: its files would not fit the app.

Implementation

List<MatrixAppTest> appTestsFor(
  MatrixApp app,
  List<MatrixAppTest> named,
  List<MatrixAppTest> all,
) {
  for (final test in named) {
    if (!test.appliesTo(app)) {
      throw MatrixAppTestException(
        'The tests of ${test.directory} do not apply to ${app.name}.',
      );
    }
  }
  return [
    ...named,
    if (named.any((test) => test.readsStartProbes))
      for (final test in all)
        if (test.startProbe != null &&
            !named.contains(test) &&
            test.appliesTo(app))
          test,
  ];
}