/// <summary>
            ///    Получение команды запуска plugin'а для процесса Visual Studio, devenv.exe
            /// </summary>
            /// <param name="slnInfo">Информация о vs-решении</param>
            /// <param name="logFileName">Лог для записи диагностик</param>
            /// <returns>Команда запуска plugin'а для процесса Visual Studio, devenv.exe</returns>
            public static string GetPluginCommand(TestSolutionInfo slnInfo, string logFileName)
            {
                var slnFileName  = slnInfo.AbsSolutionFileName;
                var platform     = slnInfo.Platform.ToString();
                var configName   = slnInfo.ConfigurationMode.ToString();
                var preprocessor = slnInfo.PreprocessorType.ToString();

                return(string.Format("\"{0}\" /command \"PVSStudio.CheckSolution {1}|{2}|{3}||{4}\"", slnFileName, platform,
                                     configName, logFileName, preprocessor));
            }
示例#2
0
        /// <summary>
        ///    Записывает сообщение в системный журнал событий
        /// </summary>
        /// <param name="totalElapsed">Время потраченное на анализ</param>
        /// <param name="startup">Версия VS для запуска</param>
        /// <param name="testSolutionInfo">Сущность для тестирования</param>
        /// <param name="entryType">Тип сообщения</param>
        public static void Log(TimeSpan totalElapsed, StartupConfigurationMode startup, TestSolutionInfo testSolutionInfo,
                               EventLogEntryType entryType = EventLogEntryType.Information)
        {
            if (!SelfTesterSourceExists)
            {
                return;
            }

            var logDocument = new XDocument();
            var rootElement = new XElement("Root",
                                           new XElement("Elapsed", totalElapsed.ToString(@"hh\:mm\:ss")),
                                           new XElement("StartupMode", startup.ToString()),
                                           new XElement("SolutionInfo",
                                                        new XElement("Solution", testSolutionInfo.AbsSolutionFileName),
                                                        new XElement("ConfigMode", testSolutionInfo.ConfigurationMode.ToString()),
                                                        new XElement("Platform", testSolutionInfo.Platform),
                                                        new XElement("PreprocessorType", testSolutionInfo.PreprocessorType)));

            logDocument.Add(rootElement);
            using (var selfTesterEventLog = new EventLog(SelfTesterEventLogName, ".", SelfTesterSourceName))
            {
                selfTesterEventLog.WriteEntry(logDocument.ToString(), entryType);
            }
        }
示例#3
0
 /// <summary>
 ///    Получение файла-лога
 /// </summary>
 /// <param name="currentTestingDir">Текущая директория запуска</param>
 /// <param name="testSolutionInfo">Тестируемое решение</param>
 /// <returns>Файл-лога</returns>
 public static string GetLogFileName(string currentTestingDir, TestSolutionInfo testSolutionInfo)
 {
     return(currentTestingDir + Path.DirectorySeparatorChar +
            Path.GetFileNameWithoutExtension(testSolutionInfo.AbsSolutionFileName) +
            CoreExtensions.EtalonLogExt);
 }
 public AnalysisSolutionWrapper(string visualStudioPath, TestSolutionInfo solutionInfo, string plog)
 {
     _plog             = plog;
     _solutionInfo     = solutionInfo;
     _visualStudioPath = visualStudioPath;
 }
示例#5
0
        /// <summary>
        ///    Извлекает решения для тестовых запусков
        /// </summary>
        /// <param name="xmlSettingsFileName">Абсолютный путь к файлу конфигурации</param>
        /// <param name="selfTesterRootPath">Корневой путь к директории тестера</param>
        /// <returns>Список сущностей для тестируемых файлов решений</returns>
        /// <exception cref="InvalidSettingsException">Если узел [TestedFilesListNodeName] не был найден в конфигурации</exception>
        private static IEnumerable <TestSolutionInfo> RetrieveTestedSolutions(string xmlSettingsFileName,
                                                                              string selfTesterRootPath)
        {
            if (_cachedTestedSolutions == null)
            {
                if (!File.Exists(xmlSettingsFileName))
                {
                    throw new FileNotFoundException(string.Format("File {0} is not found", xmlSettingsFileName),
                                                    xmlSettingsFileName);
                }

                var settingsDocument = XDocument.Load(xmlSettingsFileName);

                // Получим данные для тестов в "сыром" виде
                var testedFileListElement = settingsDocument.Descendants(TestedFilesListNodeName).FirstOrDefault();
                if (testedFileListElement == null)
                {
                    throw new InvalidSettingsException("TestedFilesListNodeName node is not exists");
                }

                var rawTestedEntities = from testedSlnFile in testedFileListElement.Descendants(TestedFileNodeName)
                                        let slnFileName = testedSlnFile.Element(SolutionFileNameNodeName)
                                                          let configMode = testedSlnFile.Element(ConfigNameNodeName)
                                                                           let platform = testedSlnFile.Element(PlatformNodeName)
                                                                                          let preprocessor = testedSlnFile.Element(PreprocessorNodeName)
                                                                                                             let fixedVsVersion = testedSlnFile.Element(FixedVsVersionNodeName)
                                                                                                                                  select new
                {
                    SolutionFileName  = slnFileName == null ? string.Empty : slnFileName.Value,
                    ConfigurationMode = configMode == null ? string.Empty : configMode.Value,
                    PlatformType      = platform == null ? string.Empty : platform.Value,
                    PreprocessorType  = preprocessor == null ? string.Empty : preprocessor.Value,
                    FixedVsVersion    = fixedVsVersion == null ? string.Empty : fixedVsVersion.Value
                };

                // Преобразуем "сырые" данные к формату данных модели
                var testSolutionInfoList = new List <TestSolutionInfo>();
                var readOrder            = 0;
                foreach (var rawTestedEntity in rawTestedEntities)
                {
                    ConfigurationMode configMode;
                    if (!Enum.TryParse(rawTestedEntity.ConfigurationMode, true, out configMode))
                    {
                        configMode = TestSolutionInfo.DefaultConfigurationMode;
                    }

                    PlatformType platformType;
                    if (!Enum.TryParse(rawTestedEntity.PlatformType, true, out platformType))
                    {
                        platformType = TestSolutionInfo.DefaultPlatformType;
                    }

                    PreprocessorType preprocessorType;
                    if (!Enum.TryParse(rawTestedEntity.PreprocessorType, true, out preprocessorType))
                    {
                        preprocessorType = TestSolutionInfo.DefaultPreprocessorType;
                    }

                    int vsVersionInt;
                    var startupConfigurationMode =
                        !int.TryParse(rawTestedEntity.FixedVsVersion, out vsVersionInt)
                     ? TestSolutionInfo.DefaultVisualStudioVersions
                     : GetConfigurationModeByVsNumber(vsVersionInt);

                    var testSolutionInfo = new TestSolutionInfo
                    {
                        AbsSolutionFileName = selfTesterRootPath + rawTestedEntity.SolutionFileName,
                        ConfigurationMode   = configMode,
                        Platform            = platformType,
                        PreprocessorType    = preprocessorType,
                        StartupMode         = startupConfigurationMode,
                        ReadOrder           = ++readOrder
                    };

                    testSolutionInfoList.Add(testSolutionInfo);
                }

                _cachedTestedSolutions = testSolutionInfoList;
            }

            return(_cachedTestedSolutions);
        }