alltest.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Collections;
  3. using System.IO;
  4. using System.Xml;
  5. using System.Xml.Xsl;
  6. using System.Xml.XPath;
  7. namespace simpleTests
  8. {
  9. class TestRunner
  10. {
  11. static ArrayList excludedTests = new ArrayList (new string [] {
  12. "Keys_PerfRepro3",
  13. "Keys__91834",
  14. "Keys__91835",
  15. "Keys__91836",
  16. });
  17. static void Process (string id, string path, string data,
  18. string stylesheet, string output, string resDirName)
  19. {
  20. string dirToCheck = Path.Combine(resDirName, path);
  21. if (!Directory.Exists (dirToCheck))
  22. Directory.CreateDirectory(dirToCheck);
  23. string resFileName = Path.Combine ("../..", Path.Combine(dirToCheck, id + ".rst"));
  24. // hacky!
  25. if (path [0] >= 'a')
  26. Directory.SetCurrentDirectory (Path.Combine ("Xalan_Conformance_Tests", path));
  27. else
  28. Directory.SetCurrentDirectory (Path.Combine ("MSFT_Conformance_Tests", path));
  29. XslTransform xslt = new XslTransform();
  30. StreamWriter strWr = new StreamWriter (resFileName, false, System.Text.Encoding.UTF8);
  31. XmlTextWriter wr = new XmlTextWriter (strWr);
  32. try {
  33. XmlDocument xml = new XmlDocument();
  34. xml.Load (data);
  35. xslt.Load (stylesheet);
  36. xslt.Transform (xml, null, wr, null);
  37. } catch(Exception x) {
  38. strWr.Close();
  39. strWr = new StreamWriter (resFileName, false, System.Text.Encoding.UTF8);
  40. strWr.Write("<exception>{0}</exception>", x.GetType().ToString());
  41. }
  42. strWr.Flush();
  43. strWr.Close();
  44. Directory.SetCurrentDirectory ("../..");
  45. }
  46. static void Main(string[] args)
  47. {
  48. string topdir = "Results";
  49. bool noExclude = false;
  50. foreach (string arg in args) {
  51. switch (arg) {
  52. case "--noexc":
  53. noExclude = true;
  54. continue;
  55. default:
  56. topdir = arg;
  57. break;
  58. }
  59. }
  60. Console.WriteLine ("Setting topdir as {0}", topdir);
  61. if (!noExclude) {
  62. foreach (string s_ in new StreamReader ("ignore.lst").ReadToEnd ().Split ("\n".ToCharArray ())) {
  63. string s = s_.Trim ();
  64. if (s.Length > 0)
  65. excludedTests.Add (s);
  66. }
  67. }
  68. string pathPrefix = "testsuite/TESTS";
  69. Directory.SetCurrentDirectory (pathPrefix);
  70. XmlDocument catalog = new XmlDocument ();
  71. catalog.Load ("catalog-out.xml");
  72. XmlNodeList list = catalog.SelectNodes ("//tests/test");
  73. foreach (XmlNode node in list) {
  74. if (node.SelectSingleNode ("@ignore")!=null)
  75. continue;
  76. string id = node.SelectSingleNode ("@id").InnerText;
  77. // check if the test is excluded.
  78. if (excludedTests.Contains (id))
  79. continue;
  80. string path = node.SelectSingleNode ("path").InnerText;
  81. string data = node.SelectSingleNode ("data").InnerText;
  82. string stylesheet = node.SelectSingleNode ("stylesheet").InnerText;
  83. string output = node.SelectSingleNode ("output").InnerText;
  84. Console.Write ("Processing {0} ...", id);
  85. Process (id, path, data, stylesheet, output, topdir);
  86. Console.WriteLine ();
  87. }
  88. }
  89. }
  90. }