private BaseTest[] BuildSolutionFileList(string dirProjPath) { // Scan build.dirproj to generate the test list. //List<string> staticList = new List<string>(); ArrayList test_list = new ArrayList(); if (m_isStaticList) { foreach (string file in File.ReadAllLines(m_staticList)) { //staticList.Add(file.ToLower()); test_list.Add(file.ToLower()); } } else { test_list = BuildTestList(dirProjPath, new ArrayList()); // Add the DPWS fixture tests which are built by the build system to the test list. string dpwsFixtureTestPath = ""; string flav = Environment.GetEnvironmentVariable("FLAVOR"); if (string.IsNullOrEmpty(flav)) { flav = "Release"; } dpwsFixtureTestPath = string.Format(@"{0}\BuildOutput\public\{1}\test\server\dpws", Environment.GetEnvironmentVariable("SPOCLIENT"), flav); if (!Directory.Exists(dpwsFixtureTestPath)) { if (flav.ToLower() == "debug") flav = "Release"; else flav = "Debug"; dpwsFixtureTestPath = string.Format(@"{0}\BuildOutput\public\{1}\test\server\dpws", Environment.GetEnvironmentVariable("SPOCLIENT"), flav); } if (Directory.Exists(dpwsFixtureTestPath)) { FileInfo[] dpwsSlnFiles = new DirectoryInfo(dpwsFixtureTestPath).GetFiles("*.sln"); foreach (FileInfo dpwsSlnFile in dpwsSlnFiles) { test_list.Add(dpwsSlnFile.FullName); } } } // Copy the contents of the local arraylist to the string array. BaseTest[] list = new BaseTest[test_list.Count * m_runCount]; for (int rc = 0; rc < m_runCount; rc++) { for (int i = 0; i < list.Length; i++) { //if (m_isStaticList) //{ // string test = Path.GetFileName(test_list[i].ToString()); // if (!staticList.Contains(test)) // continue; //} if (m_isProfilerRun) { list[i] = new ProfilerTest(); } else { list[i] = new MicroFrameworkTest(); } list[i].Name = test_list[i].ToString(); list[i].Location = test_list[i].ToString(); } } return list; }
private BaseTest[] BuildTestList(bool runTestsIndividually) { DirectoryInfo[] dirs; BaseTest[] list; if (runTestsIndividually) { list = new BaseTest[m_runCount]; for (int i = 0; i < m_runCount; i++) { if (m_isProfilerRun) { list[i] = new ProfilerTest(); } else { list[i] = new MicroFrameworkTest(); } list[i].Name = m_test; list[i].Location = m_test; } } else { // The machine is a test box with the sdk installation and not a dev box. if (!IsDevEnvironment) { if (m_isProfilerRun) { dirs = new DirectoryInfo(string.Format("{0}ManagedProfilerTests", InstallRoot)).GetDirectories(); } else { dirs = new DirectoryInfo(string.Format("{0}TestCases", InstallRoot)).GetDirectories(); } list = BuildSolutionFileList(dirs); } else { // The machine is a dev box. if (m_isProfilerRun) { dirs = new DirectoryInfo(string.Format(@"{0}Tests\Performance\ProfilerTests", InstallRoot)).GetDirectories(); list = BuildSolutionFileList(dirs); } else { list = BuildSolutionFileList(InstallRoot + "build.dirproj"); } } } return list; }
private void AddTest(ref BaseTest[] list, ref int index, string slnPath) { if (m_isProfilerRun) { list[index] = new ProfilerTest(); } else { list[index] = new MicroFrameworkTest(); } list[index].Name = slnPath; list[index++].Location = slnPath; }
private static void WriteTestData(TestSystem ts, StreamWriter w) { for (int i = 0; i < ts.TestResultList.Count; i++) { if (ts.TestResultList[i] is MicroFrameworkTest) { MicroFrameworkTest test = ts.TestResultList[i] as MicroFrameworkTest; char[] splitChar = { '|' }; string bgColor = string.Empty; try { if (string.Compare(test.Result, "pass", true) == 0) { bgColor = "#99FF99"; } else if (string.Compare(test.Result, "fail", true) == 0) { bgColor = "#FE1B42"; } else if (string.Compare(test.Result, "skip", true) == 0) { bgColor = "#CFCFCF"; } else if (string.Compare(test.Result, "knownfailure", true) == 0) { bgColor = "#99FF90"; } else { bgColor = "white"; } } catch { bgColor = "#FE1B42"; test.Result = "fail"; } w.WriteLine("<tr bgcolor=\"" + bgColor + "\">"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"18%\">"); w.WriteLine("<font size=\"2\">"); // If a UNC path is not specified, do not hyperlink the sln file. Assume that // the test is being run locally and keep all the links local. if (string.IsNullOrEmpty(ts.ResultsFolder)) { w.WriteLine("<a href="); if (ts.IsDevEnvironment) { // The test path already contains the local drive information. if (test.Name.Contains(@":\")) { w.WriteLine("\"" + test.Name + "\""); } else { // The test path is relative from the platform tests root. w.WriteLine("\"" + TestSystem.RunMFTests.InstallRoot + @"Tests" + test.Name + "\""); } } else { w.WriteLine("\"" + TestSystem.RunMFTests.InstallRoot + @"\TestCases\" + test.Name + "\""); } int idx = test.Name.LastIndexOf(@"\"); w.WriteLine("><b><font color=\"black\">" + test.Name.Substring(idx + 1) + "</font></b></a>"); } else { w.WriteLine("<b><u>" + test.Name + "</u></b>"); } w.WriteLine("</font></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"4%\"><b>"); w.WriteLine("<font size=\"2\">"); string result; try { if (test.EmulatorCrashed) { result = test.Result + " (DEVICE CRASH)"; } else if (test.TimedOut) { result = test.Result + " (TIMED OUT)"; } else { result = test.Result; } } catch { result = "Fail"; } w.WriteLine(result); w.WriteLine("</font></b></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"8%\"><b>"); w.WriteLine("<font size=\"2\">"); w.WriteLine(test.TotalTestCases); w.WriteLine("</font></b></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"8%\"><b>"); w.WriteLine("<font size=\"2\">"); w.WriteLine(test.TestMethodPassCount); w.WriteLine("</font></b></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"8%\"><b>"); w.WriteLine("<font size=\"2\">"); w.WriteLine(test.TestMethodFailCount); w.WriteLine("</font></b></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"8%\"><b>"); w.WriteLine("<font size=\"2\">"); w.WriteLine(test.TestMethodSkipCount); w.WriteLine("</font></b></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"14%\"><b>"); w.WriteLine("<font size=\"2\">"); w.WriteLine(test.TestMethodKnownFailureCount); w.WriteLine("</font></b></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"6%\">"); w.WriteLine("<font size=\"2\">"); w.WriteLine("<a href="); // If a UNC path is not specified, assume that the test is being run locally // and keep all the links local. if (!string.IsNullOrEmpty(ts.ResultsFolder)) { w.WriteLine("file:" + ts.ResultsFolder.Replace('\\', '/').TrimEnd('/').Replace(" ", " ") + "/" + test.LogFile); } else { w.WriteLine(test.LogFile); } w.WriteLine("><b>" + "Open log" + "</b></a>"); w.WriteLine("</font></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"12%\"><b>"); w.WriteLine("<font size=\"2\">"); w.WriteLine(test.StartTime); w.WriteLine("</font></b></td>"); w.WriteLine("<td align=\"center\" bordercolor=\"white\" width = \"12%\"><b>"); w.WriteLine("<font size=\"2\">"); w.WriteLine(test.EndTime); w.WriteLine("</font></b></td>"); w.WriteLine("</tr>"); } } w.WriteLine("</table>"); w.WriteLine("</html>"); w.Close(); }