Program.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. using System;
  4. using System.Globalization;
  5. using System.Threading.Tasks;
  6. namespace HelixTestRunner;
  7. class Program
  8. {
  9. static async Task Main(string[] args)
  10. {
  11. try
  12. {
  13. var runner = new TestRunner(HelixTestRunnerOptions.Parse(args));
  14. var keepGoing = runner.SetupEnvironment();
  15. if (keepGoing)
  16. {
  17. keepGoing = await runner.InstallDotnetToolsAsync();
  18. }
  19. if (keepGoing)
  20. {
  21. if (runner.Options.InstallPlaywright)
  22. {
  23. keepGoing = runner.InstallPlaywright();
  24. }
  25. else
  26. {
  27. ProcessUtil.PrintMessage("Playwright install skipped.");
  28. }
  29. }
  30. runner.DisplayContents();
  31. if (keepGoing)
  32. {
  33. if (!await runner.CheckTestDiscoveryAsync())
  34. {
  35. ProcessUtil.PrintMessage("RunTest stopping due to test discovery failure.");
  36. Environment.Exit(1);
  37. return;
  38. }
  39. ProcessUtil.PrintMessage("Start running tests");
  40. var exitCode = await runner.RunTestsAsync();
  41. ProcessUtil.PrintMessage("Running tests complete");
  42. ProcessUtil.PrintMessage("Uploading test results");
  43. runner.UploadResults();
  44. ProcessUtil.PrintMessage("Test results uploaded");
  45. ProcessUtil.PrintMessage($"Completed Helix job with exit code '{exitCode}'");
  46. Environment.Exit(exitCode);
  47. }
  48. ProcessUtil.PrintMessage("Tests were not run due to previous failures. Exit code=1");
  49. Environment.Exit(1);
  50. }
  51. catch (Exception e)
  52. {
  53. ProcessUtil.PrintMessage($"HelixTestRunner uncaught exception: {e.ToString()}");
  54. Environment.Exit(1);
  55. }
  56. }
  57. }