runFailingAppTests function

Future<(List<String>, String)> runFailingAppTests(
  1. GeneratedApp generated,
  2. MatrixApp app,
  3. List<MatrixAppTest> tests,
  4. List<MatrixExpectedFailure> failures, {
  5. MatrixEnv? env,
  6. MatrixFlutter flutter = _flutter,
  7. FileSystem fileSystem = const LocalFileSystem(),
})

Adds tests to generated, the app of the matrix app, with their dev dependencies and the values that they give the app in the file of env, and runs them with flutter test --reporter json and the tool arguments of env through flutter once the app with the tests passes flutter analyze: the tests of failures must fail as they expect, and the other tests of the app must pass (see expectedFailureProblems).

Returns the problems, and the output with a line for each test that ran (see testRunSummary). When a command before the tests fails, or the files of the tests have a problem, the problem is the last line of the output, and no test runs.

Implementation

Future<(List<String>, String)> runFailingAppTests(
  GeneratedApp generated,
  MatrixApp app,
  List<MatrixAppTest> tests,
  List<MatrixExpectedFailure> failures, {
  MatrixEnv? env,
  MatrixFlutter flutter = _flutter,
  FileSystem fileSystem = const LocalFileSystem(),
}) async {
  final (code, output) = await _addAndRun(
    (generated: generated, app: app),
    tests,
    [
      ..._pubAdd(tests),
      const ['analyze'],
    ],
    env: env,
    valuesOf: () => _envValuesOf(tests, app, env, generated.path, fileSystem),
    machine: (flutter: flutter, fileSystem: fileSystem),
  );
  if (code != 0) return ([output.trim().split('\n').last], output);
  final (_, report) = await flutter(
    ['test', ...?env?.toolArguments(app), '--reporter', 'json'],
    generated.path,
  );
  final summary = testRunSummary(report, directory: generated.path);
  return (
    expectedFailureProblems(report, failures, directory: generated.path),
    [output, ...summary].join('\n'),
  );
}