prepareOptimizedFilesFromDirs method

Iterable<PackageToTest> prepareOptimizedFilesFromDirs(
  1. List<String> testDirs,
  2. Map<String, DetermineFlutterOrDart> dirTools
)

Implementation

Iterable<PackageToTest> prepareOptimizedFilesFromDirs(
  List<String> testDirs,
  Map<String, DetermineFlutterOrDart> dirTools,
) sync* {
  final glob = Glob(path.join('**_test.dart'));

  for (final testDir in testDirs) {
    final tool = dirTools[testDir];
    if (tool == null) continue;

    final packageToTest = PackageToTest(
      tool: tool,
      packagePath: testDir,
    );

    if (tool.isFlutter) {
      yield packageToTest;
      continue;
    }

    final allTestFiles =
        glob.listFileSystemSync(fs, followLinks: false, root: testDir);

    final testFiles = omitOptimizedTest(allTestFiles);

    if (testFiles.isEmpty) {
      continue;
    }

    final optimizedPath = writeOptimizedFile(
      testFiles,
      testDir: testDir,
    );

    packageToTest.optimizedPath = optimizedPath;

    yield packageToTest;
  }
}