Example #1
0
        public bool Parse(string logFile = null, bool parseOnlyNoXmlOut = false)
        {
            logFile = logFile ?? GetLatestLog();
            if (logFile == null)
            {
                return(false);
            }
            var log = File.ReadAllText(logFile);

            // Extract all test lines.
            var testCount = ParseTests(log);

            // Extract failures.
            ParseFailures(log);

            // Extract leaks.
            ParseLeaks(log);

            var hasPerftests = log.Contains("# Perf tests");

            _nightly["id"] = Environment.MachineName;
            _nightly["os"] = Environment.OSVersion;
            var buildroot = ParseBuildRoot(log);

            _nightly["revision"] = GetRevision(buildroot);
            _nightly["start"]    = _startTime;
            _nightly["duration"] = (int)_duration.TotalMinutes;
            _nightly["testsrun"] = testCount;
            _nightly["failures"] = _failures.Count;
            _nightly["leaks"]    = _leaks.Count;

            // Save XML file.
            if (!parseOnlyNoXmlOut)
            {
                var xmlFile = Path.ChangeExtension(logFile, ".xml");
                File.WriteAllText(xmlFile, _nightly.ToString());
            }
            return(hasPerftests);
        }
Example #2
0
        public RunMode Parse(string logFile = null, bool parseOnlyNoXmlOut = false)
        {
            if (logFile == null)
            {
                logFile = GetLatestLog();
            }
            if (logFile == null || !File.Exists(logFile))
            {
                throw new Exception(string.Format("cannot locate {0}", logFile ?? "current log"));
            }
            var log = File.ReadAllText(logFile);

            // Extract log start time from log contents
            var reStartTime   = new Regex(@"\n\# Nightly started (.*)\r\n", RegexOptions.Compiled); // As in "# Nightly started Thursday, May 12, 2016 8:00 PM"
            var reStoppedTime = new Regex(@"\n\# Stopped (.*)\r\n");
            var stMatch       = reStartTime.Match(log);

            if (stMatch.Success)
            {
                var dateTimeStr = stMatch.Groups[1].Value;
                DateTime.TryParse(dateTimeStr, out _startTime);
            }
            var endMatch = reStoppedTime.Match(log);

            if (endMatch.Success)
            {
                var      dateTimeEnd = endMatch.Groups[1].Value;
                DateTime endTime;
                if (DateTime.TryParse(dateTimeEnd, out endTime))
                {
                    _duration = (endTime - _startTime).Duration();
                }
            }

            // Extract all test lines.
            var testCount = ParseTests(log);

            // Extract failures.
            ParseFailures(log);

            // Extract leaks.
            ParseLeaks(log);

            var hasPerftests  = log.Contains("# Perf tests");
            var isIntegration = new Regex(@"git\.exe.*clone.*-b").IsMatch(log);
            var isTrunk       = !isIntegration && !log.Contains("Testing branch at");

            var machineName = Environment.MachineName;
            // Get machine name from logfile name, in case it's not from this machine
            var reMachineName = new Regex(@"(.*)_\d+\-\d+\-\d+_\d+\-\d+\-\d+\.\w+", RegexOptions.Compiled); // As in "NATBR-LAB-PC_2016-05-12_20-00-19.log"
            var mnMatch       = reMachineName.Match(Path.GetFileName(logFile));

            if (mnMatch.Success)
            {
                machineName = mnMatch.Groups[1].Value.ToUpperInvariant();
            }

            // See if we can parse revision info from the log
            string revisionInfo = null;
            string gitHash      = null;
            // Checked out revision 9708.
            var reRevision = new Regex(@"\nChecked out revision (.*)\.\r\n", RegexOptions.Compiled); // As in "Checked out revision 9708."
            var revMatch   = reRevision.Match(log);

            if (revMatch.Success)
            {
                revisionInfo = revMatch.Groups[1].Value;
                gitHash      = "(svn)";
            }
            else // Look for log message where we emit our build ID
            {
                // look for build message like "ProteoWizard 3.0.18099.a0147f2 x64 AMD64"
                reRevision = new Regex(@"\nProteoWizard \d+\.\d+\.([^ ]*)\.([^ ]*).*\r\n", RegexOptions.Compiled);
                revMatch   = reRevision.Match(log);
                if (revMatch.Success)
                {
                    revisionInfo = revMatch.Groups[1].Value;
                    gitHash      = revMatch.Groups[2].Value;
                }
            }

            _nightly["id"] = machineName;
            _nightly["os"] = Environment.OSVersion;
            var buildroot = ParseBuildRoot(log);

            _nightly["revision"] = revisionInfo ?? GetRevision(buildroot);
            _nightly["git_hash"] = gitHash ?? string.Empty;
            _nightly["start"]    = _startTime;
            int durationMinutes = (int)_duration.TotalMinutes;

            // Round down or up by 1 minute to report even hours in this common case
            if (durationMinutes % 60 == 1)
            {
                durationMinutes--;
            }
            else if (durationMinutes % 60 == 59)
            {
                durationMinutes++;
            }
            _nightly["duration"] = durationMinutes;
            _nightly["testsrun"] = testCount;
            _nightly["failures"] = _failures.Count;
            _nightly["leaks"]    = _leaks.Count;

            // Save XML file.
            if (!parseOnlyNoXmlOut)
            {
                var xmlFile = Path.ChangeExtension(logFile, ".xml");
                File.WriteAllText(xmlFile, _nightly.ToString());
            }
            return(isTrunk
                ? (hasPerftests ? RunMode.perf : RunMode.trunk)
                : (isIntegration ? RunMode.integration :  (hasPerftests ? RunMode.release_perf : RunMode.release)));
        }
Example #3
0
        public RunMode Parse(string logFile = null, bool parseOnlyNoXmlOut = false)
        {
            if (logFile == null)
            {
                logFile = GetLatestLog();
            }
            if (logFile == null || !File.Exists(logFile))
            {
                throw new Exception(string.Format("cannot locate {0}", logFile ?? "current log"));
            }
            var log = File.ReadAllText(logFile);

            // Extract log start time from log contents
            var reStartTime = new Regex(@"\n\# Nightly started (.*)\r\n", RegexOptions.Compiled); // As in "# Nightly started Thursday, May 12, 2016 8:00 PM"
            var stMatch     = reStartTime.Match(log);

            if (stMatch.Success)
            {
                var dateTimeStr = stMatch.Groups[1].Value;
                DateTime.TryParse(dateTimeStr, out _startTime);
            }

            // Extract all test lines.
            var testCount = ParseTests(log);

            // Extract failures.
            ParseFailures(log);

            // Extract leaks.
            ParseLeaks(log);

            var hasPerftests  = log.Contains("# Perf tests");
            var isIntegration = log.Contains(GIT_INTEGRATION_BRANCH_URL);
            var isTrunk       = !isIntegration && !log.Contains("Testing branch at");

            var machineName = Environment.MachineName;
            // Get machine name from logfile name, in case it's not from this machine
            var reMachineName = new Regex(@"(.*)_\d+\-\d+\-\d+_\d+\-\d+\-\d+\.\w+", RegexOptions.Compiled); // As in "NATBR-LAB-PC_2016-05-12_20-00-19.log"
            var mnMatch       = reMachineName.Match(Path.GetFileName(logFile));

            if (mnMatch.Success)
            {
                machineName = mnMatch.Groups[1].Value.ToUpperInvariant();
            }

            // See if we can parse revision info from the log
            string revisionInfo = null;
            // Checked out revision 9708.
            var reRevision = new Regex(@"\nChecked out revision (.*)\.\r\n", RegexOptions.Compiled); // As in "Checked out revision 9708."
            var revMatch   = reRevision.Match(log);

            if (revMatch.Success)
            {
                revisionInfo = revMatch.Groups[1].Value;
            }

            _nightly["id"] = machineName;
            _nightly["os"] = Environment.OSVersion;
            var buildroot = ParseBuildRoot(log);

            _nightly["revision"] = revisionInfo ?? GetRevision(buildroot);
            _nightly["start"]    = _startTime;
            _nightly["duration"] = (int)_duration.TotalMinutes;
            _nightly["testsrun"] = testCount;
            _nightly["failures"] = _failures.Count;
            _nightly["leaks"]    = _leaks.Count;

            // Save XML file.
            if (!parseOnlyNoXmlOut)
            {
                var xmlFile = Path.ChangeExtension(logFile, ".xml");
                File.WriteAllText(xmlFile, _nightly.ToString());
            }
            return(isTrunk
                ? (hasPerftests ? RunMode.perf : RunMode.trunk)
                : (isIntegration ? RunMode.integration :  (hasPerftests ? RunMode.release_perf : RunMode.release)));
        }