runAppTests function
Future<(int, String)>
runAppTests(
- GeneratedApp generated,
- MatrixApp app,
- List<
MatrixAppTest> tests, { - MatrixFlutter flutter = _flutter,
- FileSystem fileSystem = const LocalFileSystem(),
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.
Implementation
Future<(int, String)> runAppTests(
GeneratedApp generated,
MatrixApp app,
List<MatrixAppTest> tests, {
MatrixFlutter flutter = _flutter,
FileSystem fileSystem = const LocalFileSystem(),
}) async {
final List<String> added;
try {
added = addAppTests(
tests,
app: app,
directory: generated.path,
packageName: generated.name,
fileSystem: fileSystem,
);
} on MatrixAppTestException catch (error) {
return (1, error.message);
}
final output = StringBuffer('Added the tests ${added.join(', ')}.\n');
for (final arguments in appTestCommands(tests)) {
final (code, text) = await flutter(arguments, generated.path);
output.write(text);
if (code != 0) {
output.write('\nflutter ${arguments.join(' ')} exited with $code.');
return (code, '$output');
}
}
return (0, '$output');
}