Пример #1
0
        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);
            }
        }
Пример #2
0
        public void BootSettings_DownloadConfigOverridesEnvVars()
        {
            // 0. Setup
            TestLogger logger = new TestLogger();

            using (EnvironmentVariableScope envScope = new EnvironmentVariableScope())
            {
                AppConfigWrapper configScope = new AppConfigWrapper();

                envScope.SetVariable(BootstrapperSettings.SQAnalysisRootPath, "env download dir");
                configScope.SetDownloadDir("config download dir");

                // 1. Check the config scope takes precedence
                IBootstrapperSettings settings = new BootstrapperSettings(logger, configScope.AppConfig);
                AssertExpectedDownloadDir(@"config download dir", settings);

                // 2. Now clear the config scope and check the env var is used
                configScope.Reset();
                settings = new BootstrapperSettings(logger);
                AssertExpectedDownloadDir(@"env download dir\sqtemp\bin", settings);
            }
        }
Пример #3
0
        public void BootSettings_PreProcessorPath()
        {
            // 0. Setup
            TestLogger       logger      = new TestLogger();
            AppConfigWrapper configScope = new AppConfigWrapper();

            configScope.SetDownloadDir(@"c:\temp");

            // 1. Default value -> relative to download dir
            IBootstrapperSettings settings = new BootstrapperSettings(logger, configScope.AppConfig);

            AssertExpectedPreProcessPath(@"c:\temp\SonarQube.MSBuild.PreProcessor.exe", settings);

            // 2. Relative exe set in config -> relative to download dir
            configScope.SetPreProcessExe(@"..\myCustomPreProcessor.exe");
            settings = new BootstrapperSettings(logger, configScope.AppConfig);
            AssertExpectedPreProcessPath(@"c:\myCustomPreProcessor.exe", settings);

            // 3. Now set the config path to an absolute value
            configScope.SetPreProcessExe(@"d:\myCustomPreProcessor.exe");
            settings = new BootstrapperSettings(logger, configScope.AppConfig);
            AssertExpectedPreProcessPath(@"d:\myCustomPreProcessor.exe", settings);
        }
Пример #4
0
        public void BootSettings_ConfigOverridesPropertiesFile_Url()
        {
            // 0. Setup
            TestLogger logger = new TestLogger();

            using (EnvironmentVariableScope envScope = new EnvironmentVariableScope())
            {
                string runnerBinDir = CreateSonarRunnerFiles("http://envUrl");
                envScope.SetPath(runnerBinDir); // so the properties file can be found

                AppConfigWrapper configScope = new AppConfigWrapper();
                configScope.SetSonarQubeUrl("http://configUrl");

                // 1. Check the config scope takes precedence
                IBootstrapperSettings settings = new BootstrapperSettings(logger, configScope.AppConfig);
                AssertExpectedServerUrl(@"http://configUrl", settings);

                // 2. Now clear the config scope and check the env var is used
                configScope.Reset();
                settings = new BootstrapperSettings(logger);
                AssertExpectedServerUrl(@"http://envUrl", settings);
            }
        }