Example #1
0
        public static void ParseMessage(IFarmTaskInfo farmTaskInfo, string testNameAndNamespace, string message, string stackTrace, List <CorpDirTestInfo> resultList)
        {
            if (!message.StartsWith("Exception - NUnit.Framework.AssertionException"))
            {
                resultList.Add(CorpDirTestInfo.CreateError(farmTaskInfo, testNameAndNamespace, message, stackTrace));
                return;
            }
            List <string> themedResultPaths = message.Split(new[] { " - failed:" }, StringSplitOptions.RemoveEmptyEntries).ToList();

            foreach (var part in themedResultPaths)
            {
                ParseMessagePart(farmTaskInfo, testNameAndNamespace, part, resultList);
            }
        }
Example #2
0
        public static CorpDirTestInfoContainer LoadFromInfo(IFarmTaskInfo taskInfo, string realUrl)
        {
            List <CorpDirTestInfo> failedTests = new List <CorpDirTestInfo>();

            if (realUrl == null || !realUrl.Contains("ViewBuildReport.aspx"))
            {
                throw new NotSupportedException("Contact Petr Zinovyev, please.");
            }
            XmlDocument myXmlDocument = new XmlDocument();

            myXmlDocument.Load(realUrl.Replace("ViewBuildReport.aspx", "XmlBuildLog.xml"));
            List <Task <List <CorpDirTestInfo> > > failedTestsTasks = new List <Task <List <CorpDirTestInfo> > >();

            if (!IsSuccessBuild(myXmlDocument))
            {
                foreach (XmlElement testCaseXml in FindFailedTests(myXmlDocument))
                {
                    string  testNameAndNamespace = testCaseXml.GetAttribute("name");
                    XmlNode failureNode          = testCaseXml.FindByName("failure");
                    failedTestsTasks.Add(Task.Factory.StartNew <List <CorpDirTestInfo> >(() => {
                        XmlNode resultNode              = failureNode.FindByName("message");
                        XmlNode stackTraceNode          = failureNode.FindByName("stack-trace");
                        List <CorpDirTestInfo> localRes = new List <CorpDirTestInfo>();
                        ParseMessage(taskInfo, testNameAndNamespace, resultNode.InnerText, stackTraceNode.InnerText, localRes);
                        return(localRes);
                    }));
                }
                if (failedTestsTasks.Count > 0)
                {
                    Task.WaitAll(failedTestsTasks.ToArray());
                    failedTestsTasks.ForEach(t => failedTests.AddRange(t.Result));
                }
                else
                {
                    if (!taskInfo.Success)
                    {
                        failedTests.Add(CorpDirTestInfo.CreateError(taskInfo, "BuildError", "BuildError", "BuildError"));
                    }
                }
            }
            return(new CorpDirTestInfoContainer(failedTests, FindUsedFiles(myXmlDocument).ToList(), FindElapsedTimes(myXmlDocument), FindTeams(taskInfo.Repository.Version, myXmlDocument)));
        }