blob: 76e89f69b1099267534793402e5ade8d78871ba3 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:fxtest/fxtest.dart';
class TestMatcher {
List<Checker> checkers;
TestMatcher({this.checkers});
bool matches(
TestDefinition testDefinition,
PermutatedTestsConfig testConfig, {
bool exactMatching,
}) {
var testNameGroup = testConfig.testNameGroup;
// Start by looping over all provided rules in this group
for (MatchableTestName matcher in testNameGroup) {
// To begin, each testName is declared as unmatched
bool hasMatchedTestName = false;
// Give each checker a chance to match against the rule
for (var checker in checkers) {
// When a checker matches a testName, mark it and break out of the inner
// loop, since additional matches for that testName are meaningless
if (checker.canHandle(
matcher?.testNameToken,
matcher?.matchType,
testConfig.flags,
testDefinition,
exactMatching: exactMatching,
)) {
hasMatchedTestName = true;
break;
}
}
// We found no checkers for this rule that matched against this filter,
// which means the provided filter is meant to exclude this test
if (!hasMatchedTestName) {
return false;
}
}
// All filters/test names were matched, which means this test should be
// run against the provided rules
return true;
}
}