doRunTests method
Implementation
bool doRunTests(String projectRootPath,
{required String? tags, required String? excludeTags}) {
if (which('critical_test').notfound) {
print(blue('Installing dart package critical_test'));
'dart pub global activate critical_test'
.start(progress: Progress.printStdErr());
}
if (which('critical_test').notfound) {
printerr(
red('Please install the dart package critical_test and try again. '
'"dart pub global activate critical_test"'));
exit(1);
}
// critical_test generates a file to track failed tests
// add it to .gitignore so it doesn't look like an uncommitted
// file.
Git(projectRootPath).addGitIgnore('.failed_tracker');
var success = true;
if (!exists(join(projectRootPath, 'test'))) {
print(orange('No tests found in ${relative(projectRootPath)} skipping'));
} else {
final progress = startFromArgs(
exeName('critical_test'),
[
if (Settings().isVerbose) '-v',
if (tags != null) '--tags=$tags',
if (excludeTags != null) '--exclude-tags=$excludeTags',
],
terminal: true,
workingDirectory: projectRootPath,
nothrow: true);
/// exitCode 5 means no test ran.
success = progress.exitCode == 0 || progress.exitCode == 5;
if (success) {
print(green('All unit tests passed.'));
}
}
return success;
}