generate.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections;
  3. using System.IO;
  4. using System.Text;
  5. using System.Xml;
  6. namespace MonoTests.oasis_xslt {
  7. public class Generator: IDisposable
  8. {
  9. #region test list fields
  10. ArrayList skipTargets = new ArrayList ();
  11. StreamWriter resultExceptionsWriter;
  12. #endregion
  13. #region IDisposable Members
  14. public void Dispose()
  15. {
  16. if (resultExceptionsWriter!=null)
  17. resultExceptionsWriter.Close ();
  18. resultExceptionsWriter = null;
  19. }
  20. #endregion
  21. public static int Main (string [] args) {
  22. using (Generator test = new Generator (args)) {
  23. test.Run ();
  24. }
  25. return 0;
  26. }
  27. string [] _args;
  28. Generator (string [] args)
  29. {
  30. _args = args;
  31. }
  32. void Run ()
  33. {
  34. string resultExceptionsFilename = Path.Combine (EnvOptions.OutputDir, "res-exceptions.lst");
  35. if (Directory.Exists (EnvOptions.OutputDir))
  36. Directory.Delete (EnvOptions.OutputDir, true);
  37. Directory.CreateDirectory (EnvOptions.OutputDir);
  38. Helpers.ReadStrings (skipTargets, "ignore.lst");
  39. resultExceptionsWriter = new StreamWriter (resultExceptionsFilename);
  40. XmlDocument catalog = new XmlDocument ();
  41. catalog.Load (@"testsuite/TESTS/catalog-fixed.xml");
  42. foreach (XmlElement testCase in catalog.SelectNodes ("test-suite/test-catalog/test-case")) {
  43. ProcessTestCase (testCase);
  44. }
  45. }
  46. void ProcessTestCase (XmlElement testCase) {
  47. string testid = testCase.GetAttribute ("id");
  48. Console.Out.WriteLine (testid);
  49. if (skipTargets.Contains (testid))
  50. return;
  51. CatalogTestCase ctc = new CatalogTestCase(EnvOptions.OutputDir, testCase);
  52. if (!ctc.Process ())
  53. return;
  54. SingleTestTransform stt = new SingleTestTransform (ctc);
  55. stt.RunTest ();
  56. if (stt.Succeeded)
  57. using (StreamWriter fw = new StreamWriter (ctc.OutFile, false, Encoding.UTF8))
  58. fw.Write (stt.Result);
  59. else
  60. resultExceptionsWriter.WriteLine ("{0}\t{1}", testid, stt.Exception.GetType ().ToString ());
  61. }
  62. }
  63. }