示例#1
0
        public void WhenBeginAndEndScopeOnThread_StartAndEndTimeAreWithinMainThreadScope()
        {
            BuildLog log = new BuildLog();

            using (log.ScopedStep(LogLevel.Info, "TestStep", true))
            {
                var t = new Thread(() =>
                {
                    Thread.Sleep(1);
                    log.AddEntry(LogLevel.Info, "ThreadedMsg1");
                    Thread.Sleep(1);
                    using (log.ScopedStep(LogLevel.Info, "ThreadedStep"))
                        Thread.Sleep(2);
                    Thread.Sleep(1);
                });
                t.Start();
                t.Join();
            }

            double testStepStart        = log.Root.Children[0].StartTime;
            double threadedMessageStart = log.Root.Children[0].Entries[0].Time;
            double threadedScopeStart   = log.Root.Children[0].Children[0].StartTime;
            double threadedScopeEnd     = threadedScopeStart + log.Root.Children[0].Children[0].DurationMS;
            double testStepEnd          = testStepStart + log.Root.Children[0].DurationMS;

            Assert.Less(testStepStart, threadedMessageStart);
            Assert.Less(threadedMessageStart, threadedScopeStart);
            Assert.Less(threadedScopeStart, threadedScopeEnd);
            Assert.Less(threadedScopeEnd, testStepEnd);
        }
示例#2
0
        public void WhenAddMessage_EntryIsCreated()
        {
            BuildLog log = new BuildLog();

            using (log.ScopedStep(LogLevel.Info, "TestStep"))
                log.AddEntry(LogLevel.Info, "TestEntry");
            Assert.AreEqual("TestEntry", log.Root.Children[0].Entries[0].Message);
        }
        public void AddEntry(LogLevel level, string msg)
        {
            m_Builtin.AddEntry(level, msg);

            if (level != LogLevel.Verbose || ScriptableBuildPipeline.useDetailedBuildLog)
            {
                m_Output.WriteLine(msg);
            }
        }
示例#4
0
        public void WhenConvertingToTraceEventFormat_BackslashesAreEscaped()
        {
            BuildLog log = new BuildLog();

            using (log.ScopedStep(LogLevel.Info, "TestStep\\AfterSlash"))
                log.AddEntry(LogLevel.Info, "TestEntry\\AfterSlash");
            string text = log.FormatAsTraceEventProfiler();

            StringAssert.Contains("TestStep\\\\AfterSlash", text);
            StringAssert.Contains("TestStep\\\\AfterSlash", text);
        }
示例#5
0
        public void WhenScopeIsThreaded_AndThreadAddsNode_NodeEnteredInThreadedScope()
        {
            BuildLog log = new BuildLog();

            using (log.ScopedStep(LogLevel.Info, "TestStep", true))
            {
                var t = new Thread(() =>
                {
                    log.AddEntry(LogLevel.Info, "ThreadedMsg1");
                    using (log.ScopedStep(LogLevel.Info, "ThreadedStep"))
                    {
                        log.AddEntry(LogLevel.Info, "ThreadedMsg2");
                    }
                });
                t.Start();
                t.Join();
            }
            Assert.AreEqual("ThreadedMsg1", log.Root.Children[0].Entries[0].Message);
            Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, log.Root.Children[0].Entries[0].ThreadId);
            Assert.AreEqual("ThreadedStep", log.Root.Children[0].Children[0].Name);
            Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, log.Root.Children[0].Children[0].ThreadId);
            Assert.AreEqual("ThreadedMsg2", log.Root.Children[0].Children[0].Entries[0].Message);
            Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, log.Root.Children[0].Children[0].Entries[0].ThreadId);
        }