Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CleanupVerificationTask.cs 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
  8. {
  9. internal class CleanupVerificationTask : FileCleanupVerifierTaskBase
  10. {
  11. private const string k_Indent = " ";
  12. internal Action<object> logAction = Debug.LogWarning;
  13. public override IEnumerator Execute(TestJobData testJobData)
  14. {
  15. var currentFiles = GetAllFilesInAssetsDirectory();
  16. var existingFiles = testJobData.existingFiles;
  17. if (currentFiles.Length != existingFiles.Length)
  18. {
  19. var existingFilesHashSet = new HashSet<string>(existingFiles);
  20. var newFiles = currentFiles.Where(file => !existingFilesHashSet.Contains(file)).ToArray();
  21. LogWarningForFilesIfAny(newFiles);
  22. }
  23. yield return null;
  24. }
  25. private void LogWarningForFilesIfAny(string[] filePaths)
  26. {
  27. if (filePaths.Length == 0)
  28. {
  29. return;
  30. }
  31. var stringWriter = new StringWriter();
  32. stringWriter.WriteLine("Files generated by test without cleanup.");
  33. stringWriter.WriteLine(k_Indent + "Found {0} new files.", filePaths.Length);
  34. foreach (var filePath in filePaths)
  35. {
  36. stringWriter.WriteLine(k_Indent + filePath);
  37. }
  38. logAction(stringWriter.ToString());
  39. }
  40. }
  41. }