예제 #1
0
        public void RepoNotChangedOptimization()
        {
            CommitFile("file1", "user1", "message1");
            State.AddCheckpoint(DateTime.Now, "c8143034b60fbc51883eb11cd20592b92f7d3dfb");

            var prevIntegrationDate = DateTime.Now.AddDays(1);

            ExecAdapter(GETMODS, prevIntegrationDate.AddMinutes(1), prevIntegrationDate);

            Assert.IsTrue(LoggerOutput.Any(line => line.StartsWith("repo not changed")));
        }
예제 #2
0
        public void EmptyState()
        {
            CommitFile("file1", "x", "x");
            ExecAdapter(GETSOURCE, _targetDir, "(MAX)");

            CollectionAssert.Contains(LoggerOutput, "no tips known to date 9999-12-31T23:59:59, falling back to last known tip");
            CollectionAssert.Contains(LoggerOutput, "no tips known, fallback to branch(default)");
            Assert.IsTrue(LoggerOutput.Any(line => line.Contains("-r \"branch(default)\"")));
            Assert.IsFalse(LoggerOutput.Any(line => line.Contains("pull")));

            Assert.IsTrue(File.Exists(Path.Combine(_targetDir, "file1")));
        }
예제 #3
0
        /// <summary>
        ///   Logs the raw message to the LoggerOutput.
        /// </summary>
        /// <param name = "type">The type.</param>
        /// <param name = "message">The message.</param>
        /// <param name = "exception">The exception.</param>
        /// <param name = "parameters">The parameters.</param>
        private static void LogRawMessage(LogLevel type, string message, Exception exception, params object[] parameters)
        {
            var logLocation = FileLocationStack.Count > 0 ? FileLocationStack.Peek() : null;

            if (LoggerOutput == null)
            {
                Console.WriteLine("Warning, unable to log error. No LoggerOutput configured");
            }
            else
            {
                LoggerOutput.Log(type, logLocation, ContextAsText, message, exception, parameters);
            }
        }
예제 #4
0
        /// <summary>
        /// Exits the process.
        /// </summary>
        /// <param name="reason">The reason.</param>
        /// <param name="parameters">The parameters.</param>
        public static void Exit(string reason, params object[] parameters)
        {
            string message = string.Format(reason, parameters);

            if (ProgressReport != null)
            {
                ProgressReport.FatalExit(message);
            }

            if (LoggerOutput != null)
            {
                LoggerOutput.Exit(message, 1);
            }
        }
예제 #5
0
        public void InitialCheck()
        {
            CommitFile("file1", "user1", "message1");
            ExecAdapter(GETMODS, "(NOW)", DateTime.Now.AddMinutes(-1));

            CollectionAssert.Contains(LoggerOutput, "new checkpoint: c8143034b60fbc51883eb11cd20592b92f7d3dfb");
            CollectionAssert.Contains(LoggerOutput, "range: (c8143034b60fbc51883eb11cd20592b92f7d3dfb, c8143034b60fbc51883eb11cd20592b92f7d3dfb]");
            CollectionAssert.Contains(LoggerOutput, "range is empty or not defined");

            Assert.IsTrue(LoggerOutput.Any(line => line.Contains("-r \"max(branch(default))\"")), "query for tip");

            Assert.AreEqual(1, State.Checkpoints.Count);
            Assert.AreEqual(0, ParseModifications().Count());

            // NOTE initial check should not yield any modifications
            // Otherwise CCNet would trigger repeated builds when \\CISERVER\LocalProjects\ are cleared
        }
예제 #6
0
        public void RepoNotChangedOptimization_LockedRepo_Timeout()
        {
            CommitFile("file1", "user1", "message1");
            State.AddCheckpoint(DateTime.Now.AddMinutes(-5), "c8143034b60fbc51883eb11cd20592b92f7d3dfb");
            var waitCount = 0;

            var lockPath = Path.Combine(TempRepoDir, ".hg/store/lock");

            File.WriteAllText(lockPath, "user:123");
            try {
                ExecAdapter(GETMODS, DateTime.Now, DateTime.Now.AddMinutes(-1), $"--timeout={TimeSpan.FromSeconds(3).TotalMilliseconds}");
            } finally {
                File.Delete(lockPath);
            }
            waitCount = LoggerOutput.Count(line => line.Contains("transaction in progress"));
            Assert.IsTrue(waitCount < 4);
        }
예제 #7
0
        /// <summary>
        ///   Logs the raw message to the LoggerOutput.
        /// </summary>
        /// <param name = "type">The type.</param>
        /// <param name = "message">The message.</param>
        /// <param name = "exception">The exception.</param>
        /// <param name = "parameters">The parameters.</param>
        public override void LogRawMessage(LogLevel type, string code, string message, Exception exception, params object[] parameters)
        {
            var logLocation = FileLocationStack.Count > 0 ? FileLocationStack.Peek() : null;

            if (LoggerOutput == null)
            {
                Console.WriteLine("Warning, unable to log error. No LoggerOutput configured");
            }
            else
            {
                LoggerOutput.Log(type, logLocation, ContextAsText, code, message, exception, parameters);
            }

            if (type is LogLevel.Error or LogLevel.Fatal)
            {
                _errorCount++;
            }
        }
예제 #8
0
        public void HaveModifications(bool prevDateEqualsLastCheckpoint)
        {
            var thisDate = DateTime.Now;
            var prevDate = thisDate.AddMinutes(-1);

            var checkPointDate = prevDateEqualsLastCheckpoint
                                 // external source control case (prev date is prev integration date)
                ? prevDate
                                 // ISourceSafeDriver case (prev date is prev check date)
                : thisDate.AddHours(-1);

            CommitFile("file1", "user1", "message1");
            State.AddCheckpoint(checkPointDate, "c8143034b60fbc51883eb11cd20592b92f7d3dfb");

            CommitFile("file2", "user2", "message2");

            ExecAdapter(GETMODS, thisDate, prevDate);

            CollectionAssert.Contains(LoggerOutput, "new checkpoint: 003205be8d3be4da1db065404c7aa83eb35fe8dc");
            CollectionAssert.Contains(LoggerOutput, "range: (c8143034b60fbc51883eb11cd20592b92f7d3dfb, 003205be8d3be4da1db065404c7aa83eb35fe8dc]");
            CollectionAssert.Contains(LoggerOutput, "hg log entries: 1");

            Assert.IsTrue(
                LoggerOutput.Any(line => line.Contains("max((branch(default)) and (c8143034b60fbc51883eb11cd20592b92f7d3dfb:))")),
                "optimized query for tip"
                );

            Assert.IsTrue(
                LoggerOutput.Any(line => line.Contains("(branch(default)) and (c8143034b60fbc51883eb11cd20592b92f7d3dfb:003205be8d3be4da1db065404c7aa83eb35fe8dc - c8143034b60fbc51883eb11cd20592b92f7d3dfb)")),
                "query for changes in range"
                );

            Assert.AreEqual(2, State.Checkpoints.Count);

            var modifications = ParseModifications();

            Assert.AreEqual(1, modifications.Count());
            AssertModificationElement(modifications.First(), "003205be8d3b (A)", thisDate, "file2", "user2", "message2");
        }
예제 #9
0
        public void RepoNotChangedOptimization_LockedRepo()
        {
            CommitFile("file1", "user1", "message1");
            State.AddCheckpoint(DateTime.Now.AddMinutes(-5), "c8143034b60fbc51883eb11cd20592b92f7d3dfb");
            var waitCount = 0;

            var lockPath = Path.Combine(TempRepoDir, ".hg/store/lock");

            File.WriteAllText(lockPath, "user:123");
            new Thread(delegate() {
                while (true)
                {
                    waitCount = LoggerOutput.Count(line => line.Contains("transaction in progress"));
                    if (waitCount > 0)
                    {
                        break;
                    }
                }
                File.Delete(lockPath);
            }).Start();

            ExecAdapter(GETMODS, DateTime.Now, DateTime.Now.AddMinutes(-1));
            Assert.IsTrue(waitCount > 0);
        }
        private void showAllErrorsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoggerOutput _logger = new LoggerOutput();

            _logger.Show();
        }
예제 #11
0
        /// <summary>
        /// Read the config file and ajust the output accordingly
        /// </summary>
        private void ReadConfiguration()
        {
            try {
                XmlDocument doc = new XmlDocument();
                doc.Load(m_configFile);
                try
                {
                    XmlNode outFileNode = doc.FirstChild.SelectSingleNode("Logger/OutputFile");
                    if (outFileNode != null)
                    {
                        m_outputFile = outFileNode.InnerText;
                        m_outputFile.Replace("%APP_PATH%", Application.StartupPath);
                        //m_overriteLogFlag = outFileNode.Attributes["overrite"].Value.Equals("0") ? false : true;
                    }

                }
                catch (Exception ex_outFile) {
                    Console.WriteLine(ex_outFile.Message);
                }
                try
                {
                    XmlNode outputDirNode = doc.FirstChild.SelectSingleNode("Logger/OutputDirection");
                    if (outputDirNode != null)
                    {
                        switch (outputDirNode.InnerText.ToUpper()) {
                            case "FILE":
                                m_logOutput = LoggerOutput.FILE;
                                break;
                            case "CONSOLE":
                                m_logOutput = LoggerOutput.CONSOLE;
                                break;
                            case "FILECONSOLE":
                                m_logOutput = LoggerOutput.FILECONSOLE;
                                break;
                            default:
                                m_logOutput = LoggerOutput.FILE;
                                break;
                        }
                    }
                }
                catch (Exception ex_logOut) {
                    Console.WriteLine(ex_logOut.Message);
                }
                try {
                    XmlNode extendErrMsg = doc.FirstChild.SelectSingleNode("Logger/WriteExtendedErrorMessages");
                    if (extendErrMsg != null)
                    {
                        //m_writeExtendedMessage = bool.Parse(extendErrMsg.InnerText);
                        bool.TryParse(extendErrMsg.InnerText, out m_writeExtendedMessage);
                    }
                }
                catch (Exception ex_extendErr) {
                    m_writeExtendedMessage = true;
                    Console.WriteLine(ex_extendErr.Message);
                }

                try
                {
                    XmlNode debugNode = doc.FirstChild.SelectSingleNode("Logger/Debug");
                    if (debugNode != null)
                    {
                        //m_writeExtendedMessage = bool.Parse(extendErrMsg.InnerText);
                        bool.TryParse(debugNode.Attributes["active"].Value, out m_showDebugInfo);
                    }
                }
                catch (Exception ex_debug)
                {
                    m_showDebugInfo = false;
                    Console.WriteLine(ex_debug.Message);
                }

            }
            catch  {
                Console.WriteLine("Config file does not exist.");
            }
        }