예제 #1
0
        /// <summary>
        /// This is called by every event handler for compat reasons -- see DDB #136924
        /// However it will skip after the first call
        /// </summary>
        private void InitializeBaseConsoleLogger()
        {
            if (consoleLogger == null)
            {
                bool useMPLogger = false;
                if (!string.IsNullOrEmpty(parameters))
                {
                    string [] parameterComponents = parameters.Split(BaseConsoleLogger.parameterDelimiters);
                    for (int param = 0; param < parameterComponents.Length; param++)
                    {
                        if (parameterComponents[param].Length > 0)
                        {
                            if (String.Equals(parameterComponents[param], "ENABLEMPLOGGING", StringComparison.OrdinalIgnoreCase))
                            {
                                useMPLogger = true;
                            }
                            if (String.Equals(parameterComponents[param], "DISABLEMPLOGGING", StringComparison.OrdinalIgnoreCase))
                            {
                                useMPLogger = false;
                            }
                        }
                    }
                }

                if (numberOfProcessors == 1 && !useMPLogger)
                {
                    consoleLogger = new SerialConsoleLogger(verbosity, write, colorSet, colorReset);
                }
                else
                {
                    consoleLogger = new ParallelConsoleLogger(verbosity, write, colorSet, colorReset);
                }

                if (!string.IsNullOrEmpty(parameters))
                {
                    consoleLogger.Parameters = parameters;
                    parameters = null;
                }

                if (showSummary != null)
                {
                    consoleLogger.ShowSummary = (bool)showSummary;
                }

                consoleLogger.SkipProjectStartedText = skipProjectStartedText;
            }
        }
예제 #2
0
        /// <summary>
        /// Create some items and log them
        /// </summary>
        /// <returns></returns>
        private void WriteAndValidateItems(BaseConsoleLogger cl, SimulatedConsole sc, bool expectToSeeLogging)
        {
            Hashtable items = new Hashtable();
            items.Add("type", (ITaskItem)new TaskItem("spec"));
            items.Add("type2", (ITaskItem)new TaskItem("spec2"));

            string item1type = string.Empty;
            string item2type = string.Empty;
            string item1spec = string.Empty;
            string item2spec = string.Empty;

            if (cl is SerialConsoleLogger)
            {
                SortedList itemList = ((SerialConsoleLogger)cl).ExtractItemList(items);
                ((SerialConsoleLogger)cl).WriteItems(itemList);
                item1spec = "spec" + Environment.NewLine;
                item2spec = "spec2" + Environment.NewLine;
            }
            else
            {
                BuildEventArgs buildEvent = new BuildErrorEventArgs("", "", "", 0, 0, 0, 0, "", "", "");
                buildEvent.BuildEventContext = new BuildEventContext(1, 2, 3, 4);
                ((ParallelConsoleLogger)cl).WriteItems(buildEvent, items);
                item1spec = Environment.NewLine + "    spec" + Environment.NewLine;
                item2spec = Environment.NewLine + "    spec2" + Environment.NewLine;
            }

            item1type = "type" + Environment.NewLine;
            item2type = "type2" + Environment.NewLine;
            
            string log = sc.ToString();

            Console.WriteLine("[" + log + "]");



            // Being careful not to make locale assumptions here, eg about sorting
            if (expectToSeeLogging)
            {
                Assertion.Assert(log.Contains(item1type));
                Assertion.Assert(log.Contains(item2type));
                Assertion.Assert(log.Contains(item1spec));
                Assertion.Assert(log.Contains(item2spec));
            }
            else
            {
                Assertion.Assert(!log.Contains(item1type));
                Assertion.Assert(!log.Contains(item2type));
                Assertion.Assert(!log.Contains(item1spec));
                Assertion.Assert(!log.Contains(item2spec));
            }
        }
예제 #3
0
        /// <summary>
        /// This is called by every event handler for compat reasons -- see DDB #136924
        /// However it will skip after the first call
        /// </summary>
        private void InitializeBaseConsoleLogger()
        {
            if (consoleLogger == null)
            {
                bool useMPLogger = false;
                if (!string.IsNullOrEmpty(parameters))
                {
                    string [] parameterComponents = parameters.Split(BaseConsoleLogger.parameterDelimiters);
                    for (int param = 0; param < parameterComponents.Length; param++)
                    {
                        if (parameterComponents[param].Length > 0)
                        {
                            if (0 == String.Compare(parameterComponents[param], "ENABLEMPLOGGING", StringComparison.OrdinalIgnoreCase))
                            {
                                useMPLogger = true;
                            }
                            if (0 == String.Compare(parameterComponents[param], "DISABLEMPLOGGING", StringComparison.OrdinalIgnoreCase))
                            {
                                useMPLogger = false;
                            }
                        }
                    }
                }

                if (numberOfProcessors == 1 && !useMPLogger)
                {
                    consoleLogger = new SerialConsoleLogger(verbosity, write, colorSet, colorReset);
                }
                else
                {
                    consoleLogger = new ParallelConsoleLogger(verbosity, write, colorSet, colorReset);
                }

                if(!string.IsNullOrEmpty(parameters))
                {
                    consoleLogger.Parameters = parameters;
                    parameters = null;
                }

                if (showSummary != null)
                {
                    consoleLogger.ShowSummary = (bool)showSummary;
                }

                consoleLogger.SkipProjectStartedText = skipProjectStartedText;
            }
        }
예제 #4
0
        /// <summary>
        /// Create some properties and log them
        /// </summary>
        /// <param name="cl"></param>
        /// <returns></returns>
        private void WriteAndValidateProperties(BaseConsoleLogger cl, SimulatedConsole sc, bool expectToSeeLogging)
        {

            Hashtable properties = new Hashtable();
            properties.Add("prop1", "val1");
            properties.Add("prop2", "val2");
            string prop1 = string.Empty;
            string prop2 = string.Empty;

            if (cl is SerialConsoleLogger)
            {
                ArrayList propertyList = ((SerialConsoleLogger) cl).ExtractPropertyList(properties);
                ((SerialConsoleLogger)cl).WriteProperties(propertyList);
                prop1 = String.Format(CultureInfo.CurrentCulture, "{0,-30} = {1}", "prop1", "val1");
                prop2 = String.Format(CultureInfo.CurrentCulture, "{0,-30} = {1}", "prop2", "val2");
            }
            else
            {
                BuildEventArgs buildEvent = new BuildErrorEventArgs("", "", "", 0, 0, 0, 0, "", "", "");
                buildEvent.BuildEventContext = new BuildEventContext(1, 2, 3, 4);
                ((ParallelConsoleLogger)cl).WriteProperties(buildEvent, properties);
                 prop1 = String.Format(CultureInfo.CurrentCulture, "{0} = {1}", "prop1", "val1");
                 prop2 = String.Format(CultureInfo.CurrentCulture, "{0} = {1}", "prop2", "val2");
            }
            string log = sc.ToString();

            Console.WriteLine("[" + log + "]");


            // Being careful not to make locale assumptions here, eg about sorting
            if (expectToSeeLogging)
            {
                Assertion.Assert(log.Contains(prop1));
                Assertion.Assert(log.Contains(prop2));
            }
            else
            {
                Assertion.Assert(!log.Contains(prop1));
                Assertion.Assert(!log.Contains(prop2));
            }
        }