saveWidget method
Future<void>
saveWidget(
- PubspecData pubspecData
)
Implementation
Future<void> saveWidget(PubspecData pubspecData) async {
wtLog.startSpinner("Getting ready...");
final dartServerRepository = DartServerRepository();
await dartServerRepository.initialize();
Iterable<FileSystemEntity> fileList = Directory(PathUtils.libPath)
.listSync(recursive: true)
.where((element) => element.path.endsWith(".dart"));
AnalysisContextCollection collection = AnalysisContextCollection(
includedPaths: [PathUtils.libPath],
resourceProvider: PhysicalResourceProvider.INSTANCE,
);
List<Future> saveFutures = [];
final testRunInfo = TestRunInfo.newRun();
for (FileSystemEntity file in fileList) {
saveFutures.add(
runSaveWidget(
file,
collection,
pubspecData,
dartServerRepository,
testRunInfo,
),
);
}
wtLog.startSpinner("Saving Widget Tests");
await Future.wait(saveFutures);
wtLog.stopSpinner(
message:
'✅ Succeeded. ${testRunInfo.updated} were saved.\nNote: Saving working tests helps improve future test generations. Keep it up!');
dartServerRepository.dispose();
}