public void Roslyn_Settings_ValidSetup() { // Arrange BuildLogger logger = new BuildLogger(); ProjectRootElement projectRoot = CreateValidProjectSetup(null); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.OverrideRoslynAnalysisTarget); // Assert logger.AssertTargetExecuted(TargetConstants.OverrideRoslynAnalysisTarget); logger.AssertTargetExecuted(TargetConstants.SetRoslynAnalysisPropertiesTarget); logger.AssertTaskNotExecuted(TargetConstants.MergeResultSetsTask); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.OverrideRoslynAnalysisTarget); // Check the intermediate working properties have the expected values BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarQubeRoslynRulesetExists", "True"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarQubeRoslynAssemblyExists", "True"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarLintFound", "true"); // Check the error log and ruleset properties are set string targetDir = result.ProjectStateAfterBuild.GetPropertyValue(TargetProperties.TargetDir); string expectedErrorLog = Path.Combine(targetDir, ErrorLogFileName); AssertExpectedAnalysisProperties(result, expectedErrorLog, GetDummyRulesetFilePath()); AssertExpectedAnalyzersExists(result, GetSonarLintAnalyzerFilePaths()); }
public void Roslyn_Settings_Analyzer_AssemblyDoesNotExist() { // Arrange BuildLogger logger = new BuildLogger(); ProjectRootElement projectRoot = CreateValidProjectSetup(null); this.DeleteDummySonarLintFiles(); // The downloaded SonarLint.dll could not be found so any existing settings should be preserved projectRoot.AddItem(TargetProperties.AnalyzerItemType, "analyzer1.dll"); projectRoot.AddItem(TargetProperties.AnalyzerItemType, "c:\\myfolder\\analyzer2.dll"); projectRoot.AddItem(TargetProperties.AnalyzerItemType, "c:\\myfolder\\sonarlint.dll"); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.OverrideRoslynAnalysisTarget); // Assert logger.AssertTargetExecuted(TargetConstants.OverrideRoslynAnalysisTarget); logger.AssertTargetExecuted(TargetConstants.SetRoslynAnalysisPropertiesTarget); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.OverrideRoslynAnalysisTarget); // Check the intermediate working properties have the expected values BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarQubeRoslynRulesetExists", "True"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarLintFound", "false"); // Check the analyzer properties are set as expected AssertExpectedAnalyzersExists(result, "analyzer1.dll", "c:\\myfolder\\analyzer2.dll", "c:\\myfolder\\sonarlint.dll"); }
public void StyleCop_TargetExecutionOrder() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); WellKnownProjectProperties properties = new WellKnownProjectProperties(); properties.SonarQubeTempPath = rootInputFolder; properties.SonarQubeOutputPath = rootInputFolder; properties.SonarQubeConfigPath = rootOutputFolder; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, properties); // Add some settings we expect to be ignored AddAnalysisSetting("sonar.other.setting", "other value", projectRoot); AddAnalysisSetting("sonar.other.setting.2", "other value 2", projectRoot); projectRoot.Save(); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.DefaultBuildTarget); // Assert logger.AssertTargetExecuted(TargetConstants.SetStyleCopSettingsTarget); logger.AssertExpectedTargetOrdering(TargetConstants.SetStyleCopSettingsTarget, TargetConstants.WriteProjectDataTarget); AssertExpectedStyleCopSetting(projectRoot.ProjectFileLocation.File, result); }
public void Roslyn_Settings_RuleSetDoesNotExist() { // Arrange BuildLogger logger = new BuildLogger(); WellKnownProjectProperties properties = new WellKnownProjectProperties(); properties.ResolvedCodeAnalysisRuleset = "pre-existing.ruleset"; properties.ErrorLog = "pre-existing.log"; ProjectRootElement projectRoot = CreateValidProjectSetup(properties); this.DeleteDummyRulesetFile(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.OverrideRoslynAnalysisTarget); // Assert logger.AssertTargetExecuted(TargetConstants.OverrideRoslynAnalysisTarget); logger.AssertTargetExecuted(TargetConstants.SetRoslynAnalysisPropertiesTarget); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.OverrideRoslynAnalysisTarget); // Check the intermediate working properties have the expected values BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarQubeRoslynRulesetExists", "False"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarQubeRoslynAssemblyExists", "True"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarLintFound", "false"); AssertExpectedAnalysisProperties(result, "pre-existing.log", "pre-existing.ruleset"); }
public void E2E_FxCop_OutputFolderNotSet() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); // Don't set the output folder WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); // Clear all of the variables that could be used to look up the output path // (necessary so the test works correctly when run under TeamBuild on a machine // that has the integration targets installed) preImportProperties.SonarQubeOutputPath = ""; preImportProperties.TeamBuild2105BuildDirectory = ""; preImportProperties.TeamBuildLegacyBuildDirectory = ""; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); BuildLogger logger = new BuildLogger(); // 1. No code analysis properties BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertTargetNotExecuted(TargetConstants.OverrideFxCopSettingsTarget); logger.AssertTargetNotExecuted(TargetConstants.SetFxCopResultsTarget); AssertFxCopNotExecuted(logger); ProjectInfoAssertions.AssertNoProjectInfoFilesExists(rootOutputFolder); }
public void Roslyn_Settings_ErrorLogAlreadySet() { // Arrange BuildLogger logger = new BuildLogger(); WellKnownProjectProperties properties = new WellKnownProjectProperties(); properties[TargetProperties.ErrorLog] = "already.set.txt"; ProjectRootElement projectRoot = CreateValidProjectSetup(properties); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.OverrideRoslynAnalysisTarget); // Assert logger.AssertTargetExecuted(TargetConstants.OverrideRoslynAnalysisTarget); logger.AssertTargetExecuted(TargetConstants.SetRoslynAnalysisPropertiesTarget); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.OverrideRoslynAnalysisTarget); // Check the intermediate working properties have the expected values BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarQubeRoslynRulesetExists", "True"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarQubeRoslynAssemblyExists", "True"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, "SonarLintFound", "true"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, TargetProperties.ErrorLog, "already.set.txt"); }
public void E2E_FxCop_TempFolderIsNotSet() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeOutputPath = rootOutputFolder; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); BuildLogger logger = new BuildLogger(); // 1. No code analysis properties BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertTargetNotExecuted(TargetConstants.OverrideFxCopSettingsTarget); logger.AssertTargetNotExecuted(TargetConstants.SetFxCopResultsTarget); AssertFxCopNotExecuted(logger); ProjectInfoAssertions.AssertNoProjectInfoFilesExists(rootOutputFolder); }
public void Roslyn_Settings_TempFolderIsNotSet() { // Arrange BuildLogger logger = new BuildLogger(); WellKnownProjectProperties properties = new WellKnownProjectProperties { ErrorLog = "pre-existing.log", ResolvedCodeAnalysisRuleset = "pre-existing.ruleset", WarningsAsErrors = "CS101", TreatWarningsAsErrors = "true" }; ProjectRootElement projectRoot = CreateValidProjectSetup(properties); projectRoot.AddProperty(TargetProperties.SonarQubeTempPath, string.Empty); // needs to overwritten once the valid project has been created // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.OverrideRoslynAnalysisTarget); // Assert logger.AssertTargetNotExecuted(TargetConstants.OverrideRoslynAnalysisTarget); logger.AssertTargetNotExecuted(TargetConstants.SetRoslynAnalysisPropertiesTarget); // Existing properties should not be changed AssertExpectedErrorLog(result, "pre-existing.log"); AssertExpectedResolvedRuleset(result, "pre-existing.ruleset"); BuildAssertions.AssertExpectedItemGroupCount(result, TargetProperties.AnalyzerItemType, 0); BuildAssertions.AssertExpectedItemGroupCount(result, TargetProperties.AdditionalFilesItemType, 0); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, TargetProperties.TreatWarningsAsErrors, "true"); BuildAssertions.AssertExpectedPropertyValue(result.ProjectStateAfterBuild, TargetProperties.WarningsAsErrors, "CS101"); }
public void ImportsBefore_SonarQubeTargetsPathNotSet() { // 1. Prebuild // Arrange string dummyAnalysisTargetsDir = this.EnsureDummyIntegrationTargetsFileExists(); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTargetsPath = ""; preImportProperties.TeamBuild2105BuildDirectory = ""; preImportProperties.TeamBuildLegacyBuildDirectory = ""; // Act ProjectInstance projectInstance = this.CreateAndEvaluateProject(preImportProperties); // Assert BuildAssertions.AssertPropertyDoesNotExist(projectInstance, TargetProperties.SonarQubeTargetFilePath); AssertAnalysisTargetsAreNotImported(projectInstance); // 2. Now build -> succeeds. Info target not executed BuildLogger logger = new BuildLogger(); BuildResult result = BuildUtilities.BuildTargets(projectInstance, logger); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertTargetNotExecuted(TargetConstants.ImportBeforeInfoTarget); logger.AssertExpectedErrorCount(0); }
public void ImportsBefore_MissingAnalysisTargets() { // 1. Prebuild // Arrange WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTempPath = "nonExistentPath"; preImportProperties.MSBuildExtensionsPath = "nonExistentPath"; preImportProperties.TeamBuild2105BuildDirectory = ""; preImportProperties.TeamBuildLegacyBuildDirectory = ""; // Act ProjectInstance projectInstance = this.CreateAndEvaluateProject(preImportProperties); // Assert BuildAssertions.AssertExpectedPropertyValue(projectInstance, TargetProperties.SonarQubeTargetsPath, @"nonExistentPath\bin\targets"); BuildAssertions.AssertExpectedPropertyValue(projectInstance, TargetProperties.SonarQubeTargetFilePath, @"nonExistentPath\bin\targets\SonarQube.Integration.targets"); AssertAnalysisTargetsAreNotImported(projectInstance); // Targets should not be imported // 2. Now build -> fails with an error message BuildLogger logger = new BuildLogger(); BuildResult result = BuildUtilities.BuildTargets(projectInstance, logger); BuildAssertions.AssertTargetFailed(result, TargetConstants.DefaultBuildTarget); logger.AssertTargetExecuted(TargetConstants.ImportBeforeInfoTarget); logger.AssertExpectedErrorCount(1); string projectName = Path.GetFileName(projectInstance.FullPath); Assert.IsTrue(logger.Errors[0].Message.Contains(projectName), "Expecting the error message to contain the project file name"); }
public void E2E_FxCop_NotExecutedOnCppProjects() { string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTempPath = rootOutputFolder; preImportProperties.SonarQubeOutputPath = rootOutputFolder; preImportProperties.SonarQubeConfigPath = rootInputFolder; preImportProperties["Language"] = "C++"; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); BuildAssertions.AssertPropertyDoesNotExist(result.ProjectStateAfterBuild, "RunCodeAnalysisOnce"); AssertFxCopNotExecuted(logger); }
public void E2E_FxCop_FailIfEnabledButNotInstalled() { string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTempPath = rootOutputFolder; preImportProperties.SonarQubeOutputPath = rootOutputFolder; preImportProperties.SonarQubeConfigPath = rootInputFolder; // FxCop's targets is imported when Visual Studio is installed, see Microsoft.Common.CurrentVersion.targets preImportProperties["CodeAnalysisTargets"] = Path.Combine(rootInputFolder, "non-existing.targets"); CreateValidFxCopRuleset(rootInputFolder, string.Format(TargetProperties.SonarQubeRulesetFormat, "cs")); ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetFailed(result, TargetConstants.DefaultBuildTarget); logger.AssertExpectedTargetOrdering( TargetConstants.DetectFxCopRulesetTarget, TargetConstants.FailIfFxCopNotInstalledTarget); AssertFxCopNotExecuted(logger); }
/// <summary> /// Creates and builds a new Sonar-enabled project using the supplied descriptor. /// The method will check the build succeeded and that a single project output file was created. /// </summary> /// <returns>The full path of the project-specsific directory that was created during the build</returns> private string CreateAndBuildSonarProject(ProjectDescriptor descriptor, string rootOutputFolder, WellKnownProjectProperties preImportProperties) { ProjectRootElement projectRoot = BuildUtilities.CreateInitializedProjectRoot(this.TestContext, descriptor, preImportProperties); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); // We expect the compiler to warn if there are no compiler inputs int expectedWarnings = (descriptor.ManagedSourceFiles == null || !descriptor.ManagedSourceFiles.Any()) ? 1 : 0; logger.AssertExpectedErrorCount(0); logger.AssertExpectedWarningCount(expectedWarnings); logger.AssertExpectedTargetOrdering(TargetConstants.CoreCompileTarget, TargetConstants.CalculateSonarQubeFileListsTarget, TargetConstants.DefaultBuildTarget, TargetConstants.WriteProjectDataTarget); // Check expected folder structure exists CheckRootOutputFolder(rootOutputFolder); // Check expected project outputs Assert.AreEqual(1, Directory.EnumerateDirectories(rootOutputFolder).Count(), "Only expecting one child directory to exist under the root analysis output folder"); ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); return(Directory.EnumerateDirectories(rootOutputFolder).Single()); }
public void E2E_FxCop_OutputFolderSet_SonarRulesetNotSpecified() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); // Set the output folder but not the config folder string fxCopLogFile = Path.Combine(rootInputFolder, "FxCopResults.xml"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTempPath = rootOutputFolder; // FIXME preImportProperties.SonarQubeOutputPath = rootOutputFolder; preImportProperties.SonarQubeConfigPath = rootInputFolder; preImportProperties.RunCodeAnalysis = "TRUE"; preImportProperties.CodeAnalysisLogFile = fxCopLogFile; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertTargetExecuted(TargetConstants.OverrideFxCopSettingsTarget); // output folder is set so this should be executed logger.AssertTargetNotExecuted(TargetConstants.SetFxCopResultsTarget); AssertFxCopNotExecuted(logger); Assert.IsFalse(File.Exists(fxCopLogFile), "FxCop log file should not have been produced"); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); ProjectInfoAssertions.AssertAnalysisResultDoesNotExists(projectInfo, AnalysisType.FxCop.ToString()); }
public void StyleCop_ValueAlreadySet() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); WellKnownProjectProperties properties = new WellKnownProjectProperties(); properties.SonarQubeTempPath = rootInputFolder; properties.SonarQubeOutputPath = rootInputFolder; properties.SonarQubeConfigPath = rootOutputFolder; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, properties); // Apply some SonarQubeSettings, one of which specifies the StyleCop setting AddAnalysisSetting("sonar.other.setting", "other value", projectRoot); AddAnalysisSetting(TargetConstants.StyleCopProjectPathItemName, "xxx.yyy", projectRoot); AddAnalysisSetting("sonar.other.setting.2", "other value 2", projectRoot); projectRoot.Save(); BuildLogger logger = new BuildLogger(); BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.SetStyleCopSettingsTarget); // Assert logger.AssertTargetExecuted(TargetConstants.SetStyleCopSettingsTarget); AssertExpectedStyleCopSetting("xxx.yyy", result); }
public void ImportsBefore_BuildingInsideVS_NotImported() { // 1. Pre-build // Arrange var dummySonarTargetsDir = EnsureDummyIntegrationTargetsFileExists(); var preImportProperties = new WellKnownProjectProperties { SonarQubeTempPath = Path.GetTempPath(), SonarQubeTargetsPath = Path.GetDirectoryName(dummySonarTargetsDir), BuildingInsideVS = "tRuE" // should not be case-sensitive }; // Act var projectInstance = CreateAndEvaluateProject(preImportProperties); // Assert BuildAssertions.AssertExpectedPropertyValue(projectInstance, TargetProperties.SonarQubeTargetFilePath, dummySonarTargetsDir); AssertAnalysisTargetsAreNotImported(projectInstance); // 2. Now build -> succeeds var logger = new BuildLogger(); var result = BuildUtilities.BuildTargets(projectInstance, logger); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertTargetNotExecuted(TargetConstants.ImportBeforeInfoTarget); logger.AssertExpectedErrorCount(0); }
public void ImportsBefore_TargetsExist() { // 1. Pre-build // Arrange string dummySonarTargetsDir = this.EnsureDummyIntegrationTargetsFileExists(); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties { SonarQubeTempPath = Path.GetTempPath(), SonarQubeTargetsPath = Path.GetDirectoryName(dummySonarTargetsDir), TeamBuild2105BuildDirectory = "", TeamBuildLegacyBuildDirectory = "" }; // Act ProjectInstance projectInstance = this.CreateAndEvaluateProject(preImportProperties); // Assert BuildAssertions.AssertExpectedPropertyValue(projectInstance, TargetProperties.SonarQubeTargetFilePath, dummySonarTargetsDir); AssertAnalysisTargetsAreImported(projectInstance); // 2. Now build -> succeeds BuildLogger logger = new BuildLogger(); BuildResult result = BuildUtilities.BuildTargets(projectInstance, logger); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertTargetExecuted(TargetConstants.ImportBeforeInfoTarget); logger.AssertExpectedErrorCount(0); }
/// <summary> /// Executes the WriteProjectInfoFile target in the the supplied project. /// The method will check the build succeeded and that a single project /// output file was created. /// </summary> /// <returns>The project info file that was created during the build</returns> private ProjectInfo ExecuteWriteProjectInfo(ProjectRootElement projectRoot, string rootOutputFolder, bool noWarningOrErrors = true) { projectRoot.Save(); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, // The "write" target depends on a couple of other targets having executed first to set properties appropriately TargetConstants.CategoriseProjectTarget, TargetConstants.CalculateFilesToAnalyzeTarget, TargetConstants.CreateProjectSpecificDirs, TargetConstants.WriteProjectDataTarget); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.CalculateFilesToAnalyzeTarget); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.CreateProjectSpecificDirs); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.WriteProjectDataTarget); logger.AssertTargetExecuted(TargetConstants.WriteProjectDataTarget); if (noWarningOrErrors) { logger.AssertNoWarningsOrErrors(); } // Check expected project outputs Assert.AreEqual(1, Directory.EnumerateDirectories(rootOutputFolder).Count(), "Only expecting one child directory to exist under the root analysis output folder"); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); return(projectInfo); }
public void Roslyn_SetResults_ResultsFileExists() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string resultsFile = TestUtils.CreateTextFile(rootInputFolder, "error.report.txt", "dummy report content"); WellKnownProjectProperties properties = new WellKnownProjectProperties { SonarQubeTempPath = rootInputFolder }; properties[TargetProperties.ErrorLog] = resultsFile; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, properties); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.CreateProjectSpecificDirs, TargetConstants.SetRoslynResultsTarget); string projectSpecificOutDir = result.ProjectStateAfterBuild.GetPropertyValue(TargetProperties.ProjectSpecificOutDir); // Assert logger.AssertTargetExecuted(TargetConstants.CreateProjectSpecificDirs); logger.AssertTargetExecuted(TargetConstants.SetRoslynResultsTarget); BuildAssertions.AssertExpectedAnalysisSetting(result, RoslynAnalysisResultsSettingName, resultsFile); BuildAssertions.AssertExpectedAnalysisSetting(result, AnalyzerWorkDirectoryResultsSettingName, projectSpecificOutDir); }
public void E2E_FxCop_AllConditionsMet_VB() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); string fxCopLogFile = Path.Combine(rootInputFolder, "FxCopResults.xml"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTempPath = rootOutputFolder; // FIXME preImportProperties.SonarQubeOutputPath = rootOutputFolder; preImportProperties.RunCodeAnalysis = "false"; preImportProperties.CodeAnalysisLogFile = fxCopLogFile; preImportProperties.CodeAnalysisRuleset = "specifiedInProject.ruleset"; preImportProperties[TargetProperties.SonarQubeConfigPath] = rootInputFolder; CreateValidFxCopRuleset(rootInputFolder, string.Format(TargetProperties.SonarQubeRulesetFormat, "vbnet")); ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties, isVBProject: true); string itemPath = TestUtils.CreateTextFile(rootInputFolder, "my.vb", @"Public Class Class1 Public Sub DoStuff() End Sub End Class"); projectRoot.AddItem(TargetProperties.ItemType_Compile, itemPath); projectRoot.Save(); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertExpectedTargetOrdering( TargetConstants.DetectFxCopRulesetTarget, TargetConstants.CategoriseProjectTarget, TargetConstants.OverrideFxCopSettingsTarget, TargetConstants.FxCopTarget, TargetConstants.SetFxCopResultsTarget, TargetConstants.DefaultBuildTarget, TargetConstants.CalculateFilesToAnalyzeTarget, TargetConstants.WriteProjectDataTarget); AssertAllFxCopTargetsExecuted(logger); Assert.IsTrue(File.Exists(fxCopLogFile), "FxCop log file should have been produced"); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); ProjectInfoAssertions.AssertAnalysisResultExists(projectInfo, AnalysisType.FxCop.ToString(), fxCopLogFile); }
public void Roslyn_Settings_ValidSetup() { // Arrange BuildLogger logger = new BuildLogger(); // Set the config directory so the targets know where to look for the analysis config file string confDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "config"); // Create a valid config file containing analyzer settings string[] expectedAssemblies = new string[] { "c:\\data\\config.analyzer1.dll", "c:\\config2.dll" }; string[] expectedAdditionalFiles = new string[] { "c:\\config.1.txt", "c:\\config.2.txt" }; AnalysisConfig config = new AnalysisConfig(); AnalyzerSettings analyzerSettings = new AnalyzerSettings(); analyzerSettings.Language = "cs"; analyzerSettings.RuleSetFilePath = "d:\\my.ruleset"; analyzerSettings.AnalyzerAssemblyPaths = expectedAssemblies.ToList(); analyzerSettings.AdditionalFilePaths = expectedAdditionalFiles.ToList(); config.AnalyzersSettings = new List <AnalyzerSettings>(); config.AnalyzersSettings.Add(analyzerSettings); string configFilePath = Path.Combine(confDir, FileConstants.ConfigFileName); config.Save(configFilePath); // Create the project WellKnownProjectProperties properties = new WellKnownProjectProperties(); properties.SonarQubeConfigPath = confDir; properties.ResolvedCodeAnalysisRuleset = "c:\\should.be.overridden.ruleset"; ProjectRootElement projectRoot = CreateValidProjectSetup(properties); projectRoot.AddItem(TargetProperties.AnalyzerItemType, "should.be.removed.analyzer1.dll"); projectRoot.AddItem(TargetProperties.AnalyzerItemType, "c:\\should.be.removed.analyzer2.dll"); projectRoot.AddItem(TargetProperties.AdditionalFilesItemType, "should.be.removed.additional1.txt"); projectRoot.AddItem(TargetProperties.AdditionalFilesItemType, "should.be.removed.additional2.txt"); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.OverrideRoslynAnalysisTarget); // Assert logger.AssertTargetExecuted(TargetConstants.OverrideRoslynAnalysisTarget); logger.AssertTargetExecuted(TargetConstants.SetRoslynAnalysisPropertiesTarget); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.OverrideRoslynAnalysisTarget); // Check the error log and ruleset properties are set AssertErrorLogIsSetBySonarQubeTargets(result); AssertExpectedResolvedRuleset(result, "d:\\my.ruleset"); AssertExpectedItemValuesExists(result, TargetProperties.AdditionalFilesItemType, expectedAdditionalFiles); AssertExpectedItemValuesExists(result, TargetProperties.AnalyzerItemType, expectedAssemblies); BuildAssertions.AssertWarningsAreNotTreatedAsErrorsNorIgnored(result); }
public void E2E_FxCop_NoFilesToAnalyse() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); string fxCopLogFile = Path.Combine(rootInputFolder, "FxCopResults.xml"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTempPath = rootOutputFolder; // FIXME preImportProperties.SonarQubeOutputPath = rootOutputFolder; preImportProperties.RunCodeAnalysis = "false"; preImportProperties.CodeAnalysisLogFile = fxCopLogFile; preImportProperties.CodeAnalysisRuleset = "specifiedInProject.ruleset"; preImportProperties[TargetProperties.SonarQubeConfigPath] = rootInputFolder; CreateValidFxCopRuleset(rootInputFolder, string.Format(TargetProperties.SonarQubeRulesetFormat, "cs")); ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); // Add some files to the project string itemPath = CreateTextFile(rootInputFolder, "content1.txt", "aaaa"); projectRoot.AddItem("Content", itemPath); itemPath = CreateTextFile(rootInputFolder, "code1.cs", "class myclassXXX{} // wrong item type"); projectRoot.AddItem("CompileXXX", itemPath); projectRoot.Save(); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertExpectedTargetOrdering( TargetConstants.CategoriseProjectTarget, TargetConstants.OverrideFxCopSettingsTarget, TargetConstants.FxCopTarget, TargetConstants.SetFxCopResultsTarget, // should set the FxCop results after the platform "run Fx Cop" target TargetConstants.DefaultBuildTarget, TargetConstants.CalculateFilesToAnalyzeTarget, TargetConstants.WriteProjectDataTarget); logger.AssertTargetExecuted(TargetConstants.SetFxCopResultsTarget); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); ProjectInfoAssertions.AssertAnalysisResultDoesNotExists(projectInfo, AnalysisType.FxCop.ToString()); }
public void E2E_FxCop_AllConditionsMet() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); string fxCopLogFile = Path.Combine(rootInputFolder, "FxCopResults.xml"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTempPath = rootOutputFolder; // FIXME preImportProperties.SonarQubeOutputPath = rootOutputFolder; preImportProperties.RunCodeAnalysis = "false"; preImportProperties.CodeAnalysisLogFile = fxCopLogFile; preImportProperties.CodeAnalysisRuleset = "specifiedInProject.ruleset"; // we expect these values to be overridden preImportProperties.TreatWarningsAsErrors = "true"; preImportProperties.WarningsAsErrors = "CS0111;CS0222"; preImportProperties.WarningLevel = "3"; preImportProperties[TargetProperties.SonarQubeConfigPath] = rootInputFolder; CreateValidFxCopRuleset(rootInputFolder, string.Format(TargetProperties.SonarQubeRulesetFormat, "cs")); ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); string itemPath = TestUtils.CreateTextFile(rootInputFolder, "my.cs", "class myclass{}"); projectRoot.AddItem(TargetProperties.ItemType_Compile, itemPath); projectRoot.Save(); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertExpectedTargetOrdering( TargetConstants.DetectFxCopRulesetTarget, TargetConstants.CategoriseProjectTarget, TargetConstants.OverrideFxCopSettingsTarget, TargetConstants.FxCopTarget, TargetConstants.SetFxCopResultsTarget, TargetConstants.DefaultBuildTarget); AssertAllFxCopTargetsExecuted(logger); Assert.IsTrue(File.Exists(fxCopLogFile), "FxCop log file should have been produced"); BuildAssertions.AssertWarningsAreNotTreatedAsErrorsNorIgnored(result); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); ProjectInfoAssertions.AssertAnalysisResultExists(projectInfo, AnalysisType.FxCop.ToString(), fxCopLogFile); }
public void E2E_FxCop_TestProject_TestProjectTypeGuid() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); string fxCopLogFile = Path.Combine(rootInputFolder, "FxCopResults.xml"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.SonarQubeTempPath = rootOutputFolder; // FIXME preImportProperties.SonarQubeOutputPath = rootOutputFolder; preImportProperties.CodeAnalysisLogFile = fxCopLogFile; preImportProperties.CodeAnalysisRuleset = "specifiedInProject.ruleset"; preImportProperties.ProjectTypeGuids = "X;" + TargetConstants.MsTestProjectTypeGuid.ToUpperInvariant() + ";Y"; preImportProperties[TargetProperties.SonarQubeConfigPath] = rootInputFolder; CreateValidFxCopRuleset(rootInputFolder, string.Format(TargetProperties.SonarQubeRulesetFormat, "cs")); ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); // Add a file to the project string itemPath = CreateTextFile(rootInputFolder, "code1.cs", "class myclassXXX{}"); projectRoot.AddItem(TargetProperties.ItemType_Compile, itemPath); projectRoot.Save(); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertExpectedTargetOrdering( TargetConstants.CategoriseProjectTarget, TargetConstants.OverrideFxCopSettingsTarget, TargetConstants.FxCopTarget, TargetConstants.DefaultBuildTarget, TargetConstants.CalculateFilesToAnalyzeTarget, TargetConstants.WriteProjectDataTarget); // We expect the FxCop target to be executed... logger.AssertTargetExecuted(TargetConstants.FxCopTarget); // ... but we don't expect the FxCop *task* to have executed logger.AssertTaskNotExecuted(TargetConstants.FxCopTask); logger.AssertTargetNotExecuted(TargetConstants.SetFxCopResultsTarget); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); ProjectInfoAssertions.AssertAnalysisResultDoesNotExists(projectInfo, AnalysisType.FxCop.ToString()); }
public void Roslyn_TargetExecutionOrder() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); WellKnownProjectProperties properties = new WellKnownProjectProperties(); properties.SonarQubeTempPath = rootInputFolder; properties.SonarQubeOutputPath = rootInputFolder; properties.SonarQubeConfigPath = rootOutputFolder; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, properties); // Add some settings we expect to be ignored AddAnalysisSetting("sonar.other.setting", "other value", projectRoot); projectRoot.Save(); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.DefaultBuildTarget); // Assert // Checks that should succeed irrespective of the MSBuild version BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertTargetExecuted(TargetConstants.OverrideRoslynAnalysisTarget); // Note: use VS2013 to run this test using MSBuild 12.0. // Use VS2015 to run this test using MSBuild 14.0. if (result.ProjectStateAfterBuild.ToolsVersion.CompareTo("14.0") < 0) { logger.AssertTargetNotExecuted(TargetConstants.ResolveCodeAnalysisRuleSet); // sanity-check: should only be in MSBuild 14.0+ Assert.Inconclusive("This test requires MSBuild 14.0 to be installed. Version used: {0}", result.ProjectStateAfterBuild.ToolsVersion); } else { // MSBuild 14.0+ checks logger.AssertExpectedTargetOrdering( TargetConstants.ResolveCodeAnalysisRuleSet, TargetConstants.CategoriseProjectTarget, TargetConstants.OverrideRoslynAnalysisTarget, TargetConstants.SetRoslynAnalysisPropertiesTarget, TargetConstants.CoreCompile, TargetConstants.DefaultBuildTarget, TargetConstants.SetRoslynResultsTarget, TargetConstants.WriteProjectDataTarget); } }
public void WriteProjectInfo_BareProject() { // Checks the WriteProjectInfo target handles non-VB/C# project types // that don't import the standard targets or set the expected properties // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); BuildLogger logger = new BuildLogger(); string sqTargetFile = TestUtils.EnsureAnalysisTargetsExists(this.TestContext); string projectFilePath = Path.Combine(rootInputFolder, "project.txt"); Guid projectGuid = Guid.NewGuid(); string projectXml = @"<?xml version='1.0' encoding='utf-8'?> <Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <PropertyGroup> <ProjectGuid>{0}</ProjectGuid> <SonarQubeTempPath>{1}</SonarQubeTempPath> <SonarQubeOutputPath>{1}</SonarQubeOutputPath> <SonarQubeBuildTasksAssemblyFile>{2}</SonarQubeBuildTasksAssemblyFile> </PropertyGroup> <Import Project='{3}' /> </Project> "; ProjectRootElement projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, this.TestContext, projectXml, projectGuid.ToString(), rootOutputFolder, typeof(WriteProjectInfoFile).Assembly.Location, sqTargetFile); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.WriteProjectDataTarget); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.WriteProjectDataTarget); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); Assert.AreEqual(projectGuid, projectInfo.ProjectGuid, "Unexpected project guid"); Assert.IsNull(projectInfo.ProjectLanguage, "Expecting the project language to be null"); Assert.IsFalse(projectInfo.IsExcluded, "Project should not be marked as excluded"); Assert.AreEqual(ProjectType.Product, projectInfo.ProjectType, "Project should be marked as a product project"); Assert.AreEqual(0, projectInfo.AnalysisResults.Count, "Not expecting any analysis results to have been created"); }
public void Roslyn_Settings_SettingsMissing_NoError() { // Arrange BuildLogger logger = new BuildLogger(); // Set the config directory so the targets know where to look for the analysis config file string confDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "config"); // Create a valid config file that does not contain analyzer settings AnalysisConfig config = new AnalysisConfig(); string configFilePath = Path.Combine(confDir, FileConstants.ConfigFileName); config.Save(configFilePath); // Create the project WellKnownProjectProperties properties = new WellKnownProjectProperties { SonarQubeConfigPath = confDir, ResolvedCodeAnalysisRuleset = "c:\\should.be.overridden.ruleset" }; ProjectRootElement projectRoot = CreateValidProjectSetup(properties); projectRoot.AddItem(TargetProperties.AnalyzerItemType, "should.be.removed.analyzer1.dll"); const string additionalFileName = "should.not.be.removed.additional1.txt"; projectRoot.AddItem(TargetProperties.AdditionalFilesItemType, additionalFileName); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.OverrideRoslynAnalysisTarget); string projectSpecificConfFilePath = result.ProjectStateAfterBuild.GetPropertyValue(TargetProperties.ProjectConfFilePath); string[] expectedRoslynAdditionalFiles = new string[] { projectSpecificConfFilePath, additionalFileName /* additional files are not removed any longer */ }; // Assert logger.AssertTargetExecuted(TargetConstants.OverrideRoslynAnalysisTarget); logger.AssertTargetExecuted(TargetConstants.SetRoslynAnalysisPropertiesTarget); BuildAssertions.AssertTargetSucceeded(result, TargetConstants.OverrideRoslynAnalysisTarget); // Check the error log and ruleset properties are set AssertErrorLogIsSetBySonarQubeTargets(result); AssertExpectedResolvedRuleset(result, string.Empty); BuildAssertions.AssertExpectedItemGroupCount(result, TargetProperties.AnalyzerItemType, 0); AssertExpectedItemValuesExists(result, TargetProperties.AdditionalFilesItemType, expectedRoslynAdditionalFiles); }
public void E2E_FxCop_AllConditionsMet() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); string fxCopLogFile = Path.Combine(rootInputFolder, "FxCopResults.xml"); WellKnownProjectProperties preImportProperties = new WellKnownProjectProperties(); preImportProperties.RunSonarQubeAnalysis = "true"; preImportProperties.SonarQubeOutputPath = rootOutputFolder; preImportProperties.RunCodeAnalysis = "false"; preImportProperties.CodeAnalysisLogFile = fxCopLogFile; preImportProperties.CodeAnalysisRuleset = "specifiedInProject.ruleset"; preImportProperties[TargetProperties.SonarQubeConfigPath] = rootInputFolder; CreateValidFxCopRuleset(rootInputFolder, TargetProperties.SonarQubeRulesetName); ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, preImportProperties); string itemPath = CreateTextFile(rootInputFolder, "my.cs", "class myclass{}"); projectRoot.AddItem("Compile", itemPath); projectRoot.Save(); BuildLogger logger = new BuildLogger(); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget); logger.AssertExpectedTargetOrdering(TargetConstants.CoreCompileTarget, TargetConstants.CalculateSonarQubeFileListsTarget, TargetConstants.OverrideFxCopSettingsTarget, TargetConstants.FxCopTarget, TargetConstants.SetFxCopResultsTarget, TargetConstants.DefaultBuildTarget); AssertAllFxCopTargetsExecuted(logger); Assert.IsTrue(File.Exists(fxCopLogFile), "FxCop log file should have been produced"); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); ProjectInfoAssertions.AssertAnalysisResultExists(projectInfo, AnalysisType.FxCop.ToString(), fxCopLogFile); }
public void WriteProjectInfo_UnrecognisedLanguage() { // Checks the WriteProjectInfo target handles projects with unrecognised languages // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); BuildLogger logger = new BuildLogger(); string sqTargetFile = TestUtils.EnsureAnalysisTargetsExists(this.TestContext); string projectFilePath = Path.Combine(rootInputFolder, "unrecognisedLanguage.proj.txt"); string projectXml = @"<?xml version='1.0' encoding='utf-8'?> <Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <PropertyGroup> <Language>my.special.language</Language> <ProjectGuid>670DAF47-CBD4-4735-B7A3-42C0A02B1CB9</ProjectGuid> <SonarQubeTempPath>{0}</SonarQubeTempPath> <SonarQubeOutputPath>{0}</SonarQubeOutputPath> <SonarQubeBuildTasksAssemblyFile>{1}</SonarQubeBuildTasksAssemblyFile> </PropertyGroup> <Import Project='{2}' /> </Project> "; ProjectRootElement projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, this.TestContext, projectXml, rootOutputFolder, typeof(WriteProjectInfoFile).Assembly.Location, sqTargetFile); // Act BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.WriteProjectDataTarget); // Assert BuildAssertions.AssertTargetSucceeded(result, TargetConstants.WriteProjectDataTarget); ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath); Assert.AreEqual("my.special.language", projectInfo.ProjectLanguage, "Unexpected project language"); Assert.AreEqual(0, projectInfo.AnalysisResults.Count, "Not expecting any analysis results to have been created"); }
public void StyleCop_TempFolderIsNotSet() { // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); WellKnownProjectProperties properties = new WellKnownProjectProperties(); properties.SonarQubeTempPath = ""; ProjectRootElement projectRoot = BuildUtilities.CreateValidProjectRoot(this.TestContext, rootInputFolder, properties); BuildLogger logger = new BuildLogger(); // Act BuildUtilities.BuildTargets(projectRoot, logger, TargetConstants.SetStyleCopSettingsTarget); // Assert logger.AssertTargetNotExecuted(TargetConstants.SetStyleCopSettingsTarget); }