public void TBSettings_NonLegacyTeamBuild() { // Arrange var logger = new TestLogger(); TeamBuildSettings settings; using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamFoundationBuild, "TRUE"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_TFS2015, "http://builduri"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.TfsCollectionUri_TFS2015, "http://collectionUri"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, "non-legacy team build"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SourcesDirectory_TFS2015, @"c:\agent\_work\1"); // Act settings = TeamBuildSettings.GetSettingsFromEnvironment(logger); } // Assert settings.Should().NotBeNull("Failed to create the TeamBuildSettings"); logger.AssertErrorsLogged(0); logger.AssertWarningsLogged(0); // Check the environment properties CheckExpectedSettings( settings, BuildEnvironment.TeamBuild, Directory.GetCurrentDirectory(), "http://builduri", "http://collectionUri", "non-legacy team build", @"c:\agent\_work\1"); }
public void Fallback_FilesLocatedCorrectly() { // Arrange var testSubject = new BuildVNextCoverageSearchFallback(new TestLogger()); var dir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString(), "TestResults"); var subDir = Path.Combine(dir, "subDir", "subDir2"); Directory.CreateDirectory(subDir); TestUtils.CreateTextFile(dir, "foo.coverageXXX", "1"); TestUtils.CreateTextFile(dir, "abc.trx", "2"); var expected1 = TestUtils.CreateTextFile(dir, "foo.coverage", "3"); var expected2 = TestUtils.CreateTextFile(dir, "DUPLICATE.coverage", "4"); TestUtils.CreateTextFile(dir, "BAR.coverage.XXX", ""); TestUtils.CreateTextFile(dir, "Duplicate.coverage", "4"); // appears in both places - only one should be returned var expected3 = TestUtils.CreateTextFile(subDir, "BAR.COVERAGE", "5"); // should be found using (var envVars = new EnvironmentVariableScope()) { envVars.SetVariable(BuildVNextCoverageSearchFallback.AGENT_TEMP_DIRECTORY, dir); // Act var actual = testSubject.FindCoverageFiles(); // Assert actual.Should().BeEquivalentTo(expected1, expected2, expected3); } }
public void Fallback_CalculatesAndDeDupesOnContentCorrectly() { // Arrange var testSubject = new BuildVNextCoverageSearchFallback(new TestLogger()); var dir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString(), "TestResults"); var subDir = Path.Combine(dir, "subDir", "subDir2"); Directory.CreateDirectory(subDir); var fileOne = "fileNameOne.coverage"; var fileTwo = "fileNameTwo.coverage"; var fileThree = "fileNameThree.coverage"; var fileOneDuplicate = "fileNameOneDuplicate.coverage"; var expected1 = TestUtils.CreateTextFile(dir, fileOne, fileOne); var expected2 = TestUtils.CreateTextFile(dir, fileTwo, fileTwo); var expected3 = TestUtils.CreateTextFile(dir, fileThree, fileThree); TestUtils.CreateTextFile(dir, fileOneDuplicate, fileOne); // Same content as fileOne, should not be expected TestUtils.CreateTextFile(subDir, fileOne, fileOne); // Same content and filename, but in other dir, as fileOne, should not be expected using (var envVars = new EnvironmentVariableScope()) { envVars.SetVariable(BuildVNextCoverageSearchFallback.AGENT_TEMP_DIRECTORY, dir); // Act var actual = testSubject.FindCoverageFiles(); // Assert actual.Should().BeEquivalentTo(expected1, expected2, expected3); } }
public void ProcessCoverageReports_LegacyTeamBuild_SkipCoverageIsTrue_WhenProcess_CallsLegacyFactoryThenCallsReturnedProcessor() { // Arrange var analysisConfig = new AnalysisConfig { LocalSettings = new AnalysisProperties() }; var settingsMock = new MockTeamBuildSettings { BuildEnvironment = BuildEnvironment.LegacyTeamBuild }; var logger = new TestLogger(); using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SkipLegacyCodeCoverage, "true"); var testSubject = new CoverageReportProcessor(legacyFactoryMock.Object, converterMock.Object, logger); testSubject.Initialise(analysisConfig, settingsMock); // Act var result = false; using (new AssertIgnoreScope()) { result = testSubject.ProcessCoverageReports(); } // Assert result.Should().BeTrue(); legacyFactoryMock.Verify(x => x.BuildTfsLegacyCoverageReportProcessor(), Times.Never); } }
public void Execute_ShouldExecute_CoverageConverter_ShouldSucceeed() { var logger = new TestLogger(); var tempDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())).FullName; var text = @"<?xml version=""1.0"" encoding=""utf-8""?> <AnalysisConfig xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.sonarsource.com/msbuild/integration/2015/1""> </AnalysisConfig>"; File.WriteAllText(Path.Combine(tempDir, "temp.xml"), text); File.WriteAllText(Path.Combine(tempDir, "sonar-project.properties"), string.Empty); using (var scope = new EnvironmentVariableScope()) { //Faking TeamBuild scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamFoundationBuild, "true"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_TFS2015, "vsts://test/test"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, tempDir); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SourcesDirectory_TFS2015, tempDir); var result = Program.Execute(new string[] { "ConvertCoverage", Path.Combine(tempDir, "temp.xml"), Path.Combine(tempDir, "sonar-project.properties") }, logger); result.Should().Be(0); logger.Errors.Should().HaveCount(0); logger.InfoMessages.Should().Contain("Coverage report conversion completed successfully."); } }
public void PreArgProc_Aliases() { // 0. Setup ProcessedArgs actual; using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { string envPropertiesFilePath = CreateRunnerFilesInScope(scope); // Valid // Full names, no path actual = CheckProcessingSucceeds("/key:my.key", "/name:my name", "/version:1.0"); AssertExpectedValues("my.key", "my name", "1.0", envPropertiesFilePath, actual); // Aliases, no path, different order actual = CheckProcessingSucceeds("/v:2.0", "/k:my.key", "/n:my name"); AssertExpectedValues("my.key", "my name", "2.0", envPropertiesFilePath, actual); // Full names with path, casing actual = CheckProcessingSucceeds("/KEY:my.key", "/nAme:my name", "/version:1.0", @"/runnerProperties:" + envPropertiesFilePath); AssertExpectedValues("my.key", "my name", "1.0", envPropertiesFilePath, actual); // Aliases, no path, different order actual = CheckProcessingSucceeds(@"/r:" + envPropertiesFilePath, "/v:2:0", "/k:my.key", "/n:my name"); AssertExpectedValues("my.key", "my name", "2:0", envPropertiesFilePath, actual); } }
public void TBSettings_LegacyTeamBuild() { // Arrange TestLogger logger = new TestLogger(); TeamBuildSettings settings; using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamBuild, "TRUE"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_Legacy, "http://legacybuilduri"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.TfsCollectionUri_Legacy, "http://legacycollectionUri"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_Legacy, "legacy build dir"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SourcesDirectory_Legacy, @"c:\build\1234");; // Act settings = TeamBuildSettings.GetSettingsFromEnvironment(logger); } // Assert Assert.IsNotNull(settings, "Failed to create the TeamBuildSettings"); logger.AssertErrorsLogged(0); logger.AssertWarningsLogged(0); // Check the environment properties CheckExpectedSettings( settings, BuildEnvironment.LegacyTeamBuild, Directory.GetCurrentDirectory(), "http://legacybuilduri", "http://legacycollectionUri", "legacy build dir", @"c:\build\1234"); }
public void TBSettings_NotTeamBuild() { // 0. Setup TestLogger logger; TeamBuildSettings settings; // 1. No environment vars set using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamBuild, null); logger = new TestLogger(); settings = TeamBuildSettings.GetSettingsFromEnvironment(logger); // Check the environment properties CheckExpectedSettings(settings, BuildEnvironment.NotTeamBuild, Directory.GetCurrentDirectory(), null, null, null); } // 2. Some Team build settings provided, but not marked as in team build using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamBuild, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_Legacy, "build uri"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.TfsCollectionUri_Legacy, "collection uri"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_Legacy, "should be ignored"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, "should be ignored"); logger = new TestLogger(); settings = TeamBuildSettings.GetSettingsFromEnvironment(logger); CheckExpectedSettings(settings, BuildEnvironment.NotTeamBuild, Directory.GetCurrentDirectory(), null, null, null); } }
public void BootSettings_DownloadDirFromEnvVars() { // 0. Setup TestLogger logger = new TestLogger(); // 1. Legacy TFS variable will be used if available using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(BootstrapperSettings.BuildDirectory_Legacy, "legacy tf build"); scope.SetVariable(BootstrapperSettings.BuildDirectory_TFS2015, null); IBootstrapperSettings settings = new BootstrapperSettings(AnalysisPhase.PreProcessing, null, "http://sq", LoggerVerbosity.Debug, logger); AssertExpectedDownloadDir(Path.Combine("legacy tf build", DownloadFolderRelativePath), settings); } // 2. TFS2015 variable will be used if available using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(BootstrapperSettings.BuildDirectory_Legacy, null); scope.SetVariable(BootstrapperSettings.BuildDirectory_TFS2015, "tfs build"); IBootstrapperSettings settings = new BootstrapperSettings(AnalysisPhase.PreProcessing, null, "http://sq", LoggerVerbosity.Debug, logger); AssertExpectedDownloadDir(Path.Combine("tfs build", DownloadFolderRelativePath), settings); } // 3. CWD has least precedence over env variables using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(BootstrapperSettings.BuildDirectory_Legacy, null); scope.SetVariable(BootstrapperSettings.BuildDirectory_TFS2015, null); IBootstrapperSettings settings = new BootstrapperSettings(AnalysisPhase.PreProcessing, null, "http://sq", LoggerVerbosity.Debug, logger); AssertExpectedDownloadDir(Path.Combine(Directory.GetCurrentDirectory(), DownloadFolderRelativePath), settings); } }
public void TBSettings_NonLegacyTeamBuild() { // Arrange TestLogger logger = new TestLogger(); TeamBuildSettings settings; using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamBuild, "TRUE"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, "build dir"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_TFS2015, "http://builduri"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.TfsCollectionUri_TFS2015, "http://collectionUri"); // Act settings = TeamBuildSettings.GetSettingsFromEnvironment(logger); } // Assert Assert.IsNotNull(settings, "Failed to create the TeamBuildSettings"); logger.AssertErrorsLogged(0); logger.AssertWarningsLogged(0); // Check the environment properties CheckExpectedSettings(settings, BuildEnvironment.TeamBuild, "build dir", "http://builduri", "http://collectionUri"); }
public void ProcessCoverageReports_LegacyTeamBuild_SkipCoverageIsFalse_WhenProcess_CallsLegacyFactoryThenCallsReturnedProcessor() { // Arrange var analysisConfig = new AnalysisConfig { LocalSettings = new AnalysisProperties() }; var settingsMock = new MockTeamBuildSettings { BuildEnvironment = BuildEnvironment.LegacyTeamBuild }; var logger = new TestLogger(); // Set up the factory to return a processor that returns success var processorMock = new Mock <ICoverageReportProcessor>(); processorMock.Setup(x => x.Initialise(It.IsAny <AnalysisConfig>(), It.IsAny <ITeamBuildSettings>())).Returns(true); processorMock.Setup(x => x.ProcessCoverageReports()).Returns(true); legacyFactoryMock.Setup(x => x.BuildTfsLegacyCoverageReportProcessor()).Returns(processorMock.Object); using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SkipLegacyCodeCoverage, "false"); var testSubject = new CoverageReportProcessor(legacyFactoryMock.Object, converterMock.Object, logger); testSubject.Initialise(analysisConfig, settingsMock); // Act var result = testSubject.ProcessCoverageReports(); // Assert result.Should().BeTrue(); legacyFactoryMock.Verify(x => x.BuildTfsLegacyCoverageReportProcessor(), Times.Once); processorMock.Verify(x => x.Initialise(It.IsAny <AnalysisConfig>(), It.IsAny <ITeamBuildSettings>()), Times.Once); processorMock.Verify(x => x.ProcessCoverageReports(), Times.Once); } }
public void BootSettings_PostProcessorPath() { // Check the default values, and that relative paths are turned into absolute paths // 0. Setup TestLogger logger = new TestLogger(); using (EnvironmentVariableScope envScope = new EnvironmentVariableScope()) { AppConfigWrapper configScope = new AppConfigWrapper(); envScope.SetVariable(BootstrapperSettings.SQAnalysisRootPath, @"c:\temp"); // 1. Default value -> relative to download dir IBootstrapperSettings settings = new BootstrapperSettings(logger, configScope.AppConfig); AssertExpectedPostProcessPath(@"c:\temp\sqtemp\bin\SonarQube.MSBuild.PostProcessor.exe", settings); // 2. Relative exe set in config -> relative to download dir configScope.SetPostProcessExe(@"..\foo\myCustomPreProcessor.exe"); settings = new BootstrapperSettings(logger, configScope.AppConfig); AssertExpectedPostProcessPath(@"c:\temp\sqtemp\foo\myCustomPreProcessor.exe", settings); // 3. Now set the config path to an absolute value configScope.SetPostProcessExe(@"d:\myCustomPostProcessor.exe"); settings = new BootstrapperSettings(logger, configScope.AppConfig); AssertExpectedPostProcessPath(@"d:\myCustomPostProcessor.exe", settings); } }
public void LogDebugMessages_CorrectlyMapped(string envVarValue, bool expected) { using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(EnvironmentSettings.LogDebugMessagesEnvVar, envVarValue); new EnvironmentSettings().ShouldLogDebugMessages().Should().Be(expected); } }
public void TreatBlockerSeverityAsError_CorrectlyMapped(string envVarValue, bool expected) { using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(EnvironmentSettings.TreatBlockerAsErrorEnvVar, envVarValue); new EnvironmentSettings().TreatBlockerSeverityAsError().Should().Be(expected); } }
public void PchTimeoutInMs_ReturnsExpectedValue(string envVarValue, int expected) { using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(EnvironmentSettings.PchGenerationTimeoutEnvVar, envVarValue); new EnvironmentSettings().PCHGenerationTimeoutInMs(PchGenerationDefaultValue).Should().Be(expected); } }
public void SonarLintDaemonDownloadUrl_ReturnsExpectedValue(string envVarValue, string expected) { using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(EnvironmentSettings.SonarLintDownloadUrlEnvVar, envVarValue); new EnvironmentSettings().SonarLintDaemonDownloadUrl().Should().Be(expected); } }
public void AnalysisTimeoutInMs_ReturnsExpectedValue(string envVarValue, int expected) { using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(EnvironmentSettings.AnalysisTimeoutEnvVar, envVarValue); new EnvironmentSettings().AnalysisTimeoutInMs().Should().Be(expected); } }
private static void CheckExpectedTimeoutReturned(string envValue, int expected) { using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.LegacyCodeCoverageTimeoutInMs, envValue); int result = TeamBuildSettings.LegacyCodeCoverageProcessingTimeout; Assert.AreEqual(expected, result, "Unexpected timeout value returned. Environment value: {0}", envValue); } }
private EnvironmentVariableScope CreateEnvironmentVariableScope(string path = null) { var scope = new EnvironmentVariableScope(); // remove any existing node.exe from machine's PATH for testing purposes scope.SetPath(path); return(scope); }
private static EnvironmentVariableScope InitializeNonTeamBuildEnvironment(string workingDirectory) { Directory.SetCurrentDirectory(workingDirectory); var scope = new EnvironmentVariableScope(); scope.SetVariable(BootstrapperSettings.BuildDirectory_Legacy, null); scope.SetVariable(BootstrapperSettings.BuildDirectory_TFS2015, null); return(scope); }
private static void CheckExpectedTimeoutReturned(string envValue, int expected) { using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.LegacyCodeCoverageTimeoutInMs, envValue); var result = TeamBuildSettings.LegacyCodeCoverageProcessingTimeout; result.Should().Be(expected, "Unexpected timeout value returned. Environment value: {0}", envValue); } }
public void Get_HasEnvironmentVariable_ReturnsListWithValue() { using var scope = new EnvironmentVariableScope(); scope.SetVariable(EnvironmentVariableNodeLocationsProvider.NodeJsPathEnvVar, "some path"); var testSubject = CreateTestSubject(); var result = testSubject.Get(); result.Should().BeEquivalentTo("some path"); }
public void Get_NoEnvironmentVariable_EmptyList(string envVarValue) { using var scope = new EnvironmentVariableScope(); scope.SetVariable(EnvironmentVariableNodeLocationsProvider.NodeJsPathEnvVar, envVarValue); var testSubject = CreateTestSubject(); var result = testSubject.Get(); result.Should().BeEmpty(); }
public void GetEnvironments_NoEnvVar_ReturnsDefaults() { using var environmentsScope = new EnvironmentVariableScope(); environmentsScope.SetVariable(AnalysisConfiguration.EnvironmentsVarName, null); var testSubject = CreateTestSubject(); var result = testSubject.GetEnvironments(); result.Should().BeEquivalentTo(AnalysisConfiguration.EnvironmentsDefaultValue.Split(',').Select(x => x.Trim())); }
public void GetEnvironments_HasEnvVar_ReturnsFromEnvVar() { using var environmentsScope = new EnvironmentVariableScope(); environmentsScope.SetVariable(AnalysisConfiguration.EnvironmentsVarName, "test1,test2"); var testSubject = CreateTestSubject(); var result = testSubject.GetEnvironments(); result.Should().BeEquivalentTo("test1", "test2"); }
public void Initialize() { // Backup environment variable values envVarScope = new EnvironmentVariableScope( Authentication.RequireSignatureEnvironmentVariableName, Authentication.SecretTokenEnvironmentVariableName); mockAuthentication = new Mock <Authentication> { CallBase = true }; authentication = mockAuthentication.Object; }
public void BootSettings_Properties() { // Check the properties values and that relative paths are turned into absolute paths var logger = new TestLogger(); using var envScope = new EnvironmentVariableScope(); envScope.SetVariable(BootstrapperSettings.BuildDirectory_Legacy, @"c:\temp"); // Default value -> relative to download dir var sut = new BootstrapperSettings(AnalysisPhase.PreProcessing, null, LoggerVerbosity.Debug, logger); sut.TempDirectory.Should().Be(@"c:\temp\.sonarqube"); }
/// <summary> /// Creates and returns an environment scope configured as if it /// is not running under TeamBuild /// </summary> public static EnvironmentVariableScope CreateValidNonTeamBuildScope() { EnvironmentVariableScope scope = new EnvironmentVariableScope(); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamFoundationBuild, "false"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.TfsCollectionUri_Legacy, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.TfsCollectionUri_TFS2015, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_Legacy, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_TFS2015, null); return(scope); }
public void TBSettings_NotTeamBuild() { // 0. Setup TestLogger logger; TeamBuildSettings settings; // 1. No environment vars set -> use the temp path using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SQAnalysisRootPath, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamBuild, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_Legacy, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, null); logger = new TestLogger(); settings = TeamBuildSettings.GetSettingsFromEnvironment(logger); // Check the environment properties CheckExpectedSettings(settings, BuildEnvironment.NotTeamBuild, Path.GetTempPath(), null, null); } // 2. SQ analysis dir set using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SQAnalysisRootPath, "d:\\sqdir"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamBuild, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_Legacy, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, null); logger = new TestLogger(); settings = TeamBuildSettings.GetSettingsFromEnvironment(logger); CheckExpectedSettings(settings, BuildEnvironment.NotTeamBuild, "d:\\sqdir", null, null); } // 3. Some Team build settings provided, but not marked as in team build using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SQAnalysisRootPath, "x:\\a"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamBuild, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_Legacy, "build uri"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.TfsCollectionUri_Legacy, "collection uri"); logger = new TestLogger(); settings = TeamBuildSettings.GetSettingsFromEnvironment(logger); CheckExpectedSettings(settings, BuildEnvironment.NotTeamBuild, "x:\\a", null, null); } }
/// <summary> /// Creates and returns an environment scope that contains all of the required /// legacy TeamBuild environment variables /// </summary> public static EnvironmentVariableScope CreateValidLegacyTeamBuildScope(string tfsUri, string buildUri, string buildDir) { EnvironmentVariableScope scope = new EnvironmentVariableScope(); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamBuild, "true"); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.TfsCollectionUri_Legacy, tfsUri); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_Legacy, buildUri); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_Legacy, buildDir); // Make sure the other variables are not set scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, null); scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SQAnalysisRootPath, null); return(scope); }