earnsBadge function

bool earnsBadge(
  1. List<PluginCheckOutcome> outcomes, {
  2. String suite = conformanceSuiteVersion,
})

Whether outcomes earn the badge of suite: every check of that suite ran, every one passed and none declined; every check an outcome PluginCheckOutcome.requires — the render checks of a plugin that draws — passed on the software backend, cpu, and was not declined there; and no render check failed on any backend.

Implementation

bool earnsBadge(
  List<PluginCheckOutcome> outcomes, {
  String suite = conformanceSuiteVersion,
}) {
  final checks = conformanceSuites[suite];
  if (checks == null) {
    throw ArgumentError.value(
      suite,
      'suite',
      'is not a conformance suite; there are ${conformanceSuites.keys.join(', ')}',
    );
  }
  final ran = outcomes.where((o) => checks.contains(o.check)).toList();
  final required = <String>{for (final o in ran) ...o.requires};
  return ran.isNotEmpty &&
      checks.every((name) => ran.any((o) => o.check == name)) &&
      ran.every((o) => o.passed && !o.declined) &&
      required.every(
        (name) => outcomes.any(
          (o) =>
              o.check == name &&
              o.backend == renderBadgeBackend &&
              o.passed &&
              !o.declined,
        ),
      ) &&
      !outcomes.any(
        (o) => o.check.startsWith('render.') && !o.passed && !o.declined,
      );
}