ScriptCanvasTestVerify.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Source/Framework/ScriptCanvasTestVerify.h>
  9. namespace ScriptCanvasTests
  10. {
  11. ScriptCanvasEditor::UnitTestResult VerifyReporterEditor(const ScriptCanvasEditor::Reporter& reporter)
  12. {
  13. ScriptCanvasEditor::UnitTestResult result = ScriptCanvasEditor::UnitTestResult::AssumeFailure();
  14. AZStd::string details;
  15. if (!reporter.IsCompiled())
  16. {
  17. details = "Graph did not compile.\n";
  18. }
  19. else if (reporter.IsReportFinished())
  20. {
  21. result.m_compiled = true;
  22. const auto& successes = reporter.GetSuccess();
  23. for (const auto& success : successes)
  24. {
  25. details += "SUCCESS - ";
  26. details += success.data();
  27. details += "\n";
  28. }
  29. if (!reporter.IsActivated())
  30. {
  31. details += "Graph did not activate\n";
  32. }
  33. if (!reporter.IsDeactivated())
  34. {
  35. // \todo track this more aggressively, graphs should deactivate
  36. details += "Graph did not deactivate\n";
  37. }
  38. if (!reporter.IsErrorFree())
  39. {
  40. details += "Graph had errors\n";
  41. }
  42. const auto& failures = reporter.GetFailure();
  43. for (const auto& failure : failures)
  44. {
  45. details += "FAILURE - ";
  46. details += failure.data();
  47. details += "\n";
  48. }
  49. if (!reporter.IsComplete())
  50. {
  51. details += "Graph was not marked complete\n";
  52. }
  53. const auto& checkpoints = reporter.GetCheckpoints();
  54. if (checkpoints.empty())
  55. {
  56. details += "No checkpoints or other unit test nodes found, using them can help parse graph test failures\n";
  57. }
  58. else
  59. {
  60. AZStd::string checkpointPath = "Checkpoint Path:\n";
  61. int i = 0;
  62. for (const auto& checkpoint : checkpoints)
  63. {
  64. checkpointPath += AZStd::string::format("%2d: %s\n", ++i, checkpoint.data());
  65. }
  66. details += checkpointPath.data();
  67. }
  68. if (reporter.IsComplete() && failures.empty())
  69. {
  70. result.m_completed = true;
  71. result.m_consoleOutput = "SUCCEEDED, COMPLETE!\n";
  72. result.m_consoleOutput += details;
  73. return result;
  74. }
  75. }
  76. else
  77. {
  78. result.m_compiled = true;
  79. details += "Graph report did not finish\n";
  80. }
  81. result.m_consoleOutput = "FAILED!\n";
  82. result.m_consoleOutput += details;
  83. return result;
  84. }
  85. }