Example #1
0
 protected BaseCodeExecutionStrategy(
     IProcessExecutorFactory processExecutorFactory,
     int baseTimeUsed,
     int baseMemoryUsed)
 {
     this.ProcessExecutorFactory = processExecutorFactory;
     this.BaseTimeUsed           = baseTimeUsed;
     this.BaseMemoryUsed         = baseMemoryUsed;
 }
Example #2
0
 public CSharpAspProjectTestsExecutionStrategy(
     Func <CompilerType, string> getCompilerPathFunc,
     IProcessExecutorFactory processExecutorFactory,
     string nUnitConsoleRunnerPath,
     int baseTimeUsed,
     int baseMemoryUsed)
     : base(getCompilerPathFunc, processExecutorFactory, nUnitConsoleRunnerPath, baseTimeUsed, baseMemoryUsed)
 {
 }
 public TestCaseFactory(string executable, ILogger logger, SettingsWrapper settings,
                        IDiaResolverFactory diaResolverFactory, IProcessExecutorFactory processExecutorFactory)
 {
     _logger                 = logger;
     _settings               = settings;
     _executable             = executable;
     _diaResolverFactory     = diaResolverFactory;
     _processExecutorFactory = processExecutorFactory;
 }
        public NodeJsZipPreprocessExecuteAndRunUnitTestsWithDomAndMochaExecutionStrategy(
            IProcessExecutorFactory processExecutorFactory,
            string nodeJsExecutablePath,
            string mochaModulePath,
            string chaiModulePath,
            string jsdomModulePath,
            string jqueryModulePath,
            string handlebarsModulePath,
            string sinonModulePath,
            string sinonChaiModulePath,
            string underscoreModulePath,
            string browserifyModulePath,
            string babelifyModulePath,
            string ecmaScriptImportPluginPath,
            int baseTimeUsed,
            int baseMemoryUsed)
            : base(
                processExecutorFactory,
                nodeJsExecutablePath,
                mochaModulePath,
                chaiModulePath,
                jsdomModulePath,
                jqueryModulePath,
                handlebarsModulePath,
                sinonModulePath,
                sinonChaiModulePath,
                underscoreModulePath,
                baseTimeUsed,
                baseMemoryUsed)
        {
            if (!Directory.Exists(browserifyModulePath))
            {
                throw new ArgumentException(
                          $"Browsrify not found in: {browserifyModulePath}",
                          nameof(browserifyModulePath));
            }

            if (!Directory.Exists(babelifyModulePath))
            {
                throw new ArgumentException(
                          $"Babel not found in: {babelifyModulePath}",
                          nameof(babelifyModulePath));
            }

            if (!Directory.Exists(ecmaScriptImportPluginPath))
            {
                throw new ArgumentException(
                          $"ECMAScript2015ImportPluginPath not found in: {ecmaScriptImportPluginPath}",
                          nameof(ecmaScriptImportPluginPath));
            }

            this.BrowserifyModulePath       = FileHelpers.ProcessModulePath(browserifyModulePath);
            this.BabelifyModulePath         = FileHelpers.ProcessModulePath(babelifyModulePath);
            this.EcmaScriptImportPluginPath = FileHelpers.ProcessModulePath(ecmaScriptImportPluginPath);
        }
Example #5
0
 public CSharpProjectTestsExecutionStrategy(
     Func <CompilerType, string> getCompilerPathFunc,
     IProcessExecutorFactory processExecutorFactory,
     int baseTimeUsed,
     int baseMemoryUsed)
     : base(processExecutorFactory, baseTimeUsed, baseMemoryUsed)
 {
     this.GetCompilerPathFunc = getCompilerPathFunc;
     this.TestNames           = new List <string>();
     this.TestPaths           = new List <string>();
 }
 public DotNetCoreCompileExecuteAndCheckExecutionStrategy(
     Func <CompilerType, string> getCompilerPathFunc,
     IProcessExecutorFactory processExecutorFactory,
     string dotNetCoreRuntimeVersion,
     int baseTimeUsed,
     int baseMemoryUsed)
     : base(processExecutorFactory, baseTimeUsed, baseMemoryUsed)
 {
     this.GetCompilerPathFunc      = getCompilerPathFunc;
     this.dotNetCoreRuntimeVersion = dotNetCoreRuntimeVersion;
 }
Example #7
0
        public TruffleProjectManager(string directoryPath, int port, IProcessExecutorFactory processExecutorFactory)
        {
            this.directoryPath = directoryPath;
            this.port          = port;

            var(contractsDir, testsDir, contractsBuildDir) = this.CreateProjectStructure();

            this.contractsDirectoryPath  = contractsDir;
            this.testsDirectoryPath      = testsDir;
            this.contractsBuildDirectory = contractsBuildDir;
            this.processExecutorFactory  = processExecutorFactory;
        }
Example #8
0
        public PhpCgiExecuteAndCheckExecutionStrategy(
            IProcessExecutorFactory processExecutorFactory,
            string phpCgiExecutablePath,
            int baseTimeUsed,
            int baseMemoryUsed)
            : base(processExecutorFactory, baseTimeUsed, baseMemoryUsed)
        {
            if (!File.Exists(phpCgiExecutablePath))
            {
                throw new ArgumentException($"PHP CGI not found in: {phpCgiExecutablePath}", nameof(phpCgiExecutablePath));
            }

            this.phpCgiExecutablePath = phpCgiExecutablePath;
        }
 public DotNetCoreProjectTestsExecutionStrategy(
     Func <CompilerType, string> getCompilerPathFunc,
     IProcessExecutorFactory processExecutorFactory,
     int baseTimeUsed,
     int baseMemoryUsed,
     string targetFrameworkName,
     string microsoftEntityFrameworkCoreInMemoryVersion,
     string microsoftEntityFrameworkCoreProxiesVersion)
     : base(getCompilerPathFunc, processExecutorFactory, baseTimeUsed, baseMemoryUsed)
 {
     this.TargetFrameworkName = targetFrameworkName;
     this.MicrosoftEntityFrameworkCoreInMemoryVersion = microsoftEntityFrameworkCoreInMemoryVersion;
     this.MicrosoftEntityFrameworkCoreProxiesVersion  = microsoftEntityFrameworkCoreProxiesVersion;
 }
        public PythonExecuteAndCheckExecutionStrategy(
            IProcessExecutorFactory processExecutorFactory,
            string pythonExecutablePath,
            int baseTimeUsed,
            int baseMemoryUsed)
            : base(processExecutorFactory, baseTimeUsed, baseMemoryUsed)
        {
            if (!FileHelpers.FileExists(pythonExecutablePath))
            {
                throw new ArgumentException($"Python not found in: {pythonExecutablePath}", nameof(pythonExecutablePath));
            }

            this.pythonExecutablePath = pythonExecutablePath;
        }
        public NodeJsPreprocessExecuteAndRunJsDomUnitTestsExecutionStrategy(
            IProcessExecutorFactory processExecutorFactory,
            string nodeJsExecutablePath,
            string mochaModulePath,
            string chaiModulePath,
            string jsdomModulePath,
            string jqueryModulePath,
            string handlebarsModulePath,
            string sinonModulePath,
            string sinonChaiModulePath,
            string underscoreModulePath,
            int baseTimeUsed,
            int baseMemoryUsed) // TODO: make this modular by getting requires from test
            : base(
                processExecutorFactory,
                nodeJsExecutablePath,
                mochaModulePath,
                chaiModulePath,
                sinonModulePath,
                sinonChaiModulePath,
                underscoreModulePath,
                baseTimeUsed,
                baseMemoryUsed)
        {
            if (!Directory.Exists(jsdomModulePath))
            {
                throw new ArgumentException(
                          $"jsDom not found in: {jsdomModulePath}",
                          nameof(jsdomModulePath));
            }

            if (!Directory.Exists(jqueryModulePath))
            {
                throw new ArgumentException(
                          $"jQuery not found in: {jqueryModulePath}",
                          nameof(jqueryModulePath));
            }

            if (!Directory.Exists(handlebarsModulePath))
            {
                throw new ArgumentException(
                          $"Handlebars not found in: {handlebarsModulePath}",
                          nameof(handlebarsModulePath));
            }

            this.JsDomModulePath      = FileHelpers.ProcessModulePath(jsdomModulePath);
            this.JQueryModulePath     = FileHelpers.ProcessModulePath(jqueryModulePath);
            this.HandlebarsModulePath = FileHelpers.ProcessModulePath(handlebarsModulePath);
        }
 public JavaUnitTestsExecutionStrategy(
     Func <CompilerType, string> getCompilerPathFunc,
     IProcessExecutorFactory processExecutorFactory,
     string javaExecutablePath,
     string javaLibrariesPath,
     int baseTimeUsed,
     int baseMemoryUsed)
     : base(
         getCompilerPathFunc,
         processExecutorFactory,
         javaExecutablePath,
         javaLibrariesPath,
         baseTimeUsed,
         baseMemoryUsed)
     => this.TestNames = new List <string>();
Example #13
0
 public JavaSpringAndHibernateProjectExecutionStrategy(
     Func <CompilerType, string> getCompilerPathFunc,
     IProcessExecutorFactory processExecutorFactory,
     string javaExecutablePath,
     string javaLibrariesPath,
     string mavenPath,
     int baseTimeUsed,
     int baseMemoryUsed)
     : base(
         getCompilerPathFunc,
         processExecutorFactory,
         javaExecutablePath,
         javaLibrariesPath,
         baseTimeUsed,
         baseMemoryUsed)
     => this.MavenPath = mavenPath;
Example #14
0
 public JavaZipFileCompileExecuteAndCheckExecutionStrategy(
     Func <CompilerType, string> getCompilerPathFunc,
     IProcessExecutorFactory processExecutorFactory,
     string javaExecutablePath,
     string javaLibsPath,
     int baseTimeUsed,
     int baseMemoryUsed)
     : base(
         getCompilerPathFunc,
         processExecutorFactory,
         javaExecutablePath,
         javaLibsPath,
         baseTimeUsed,
         baseMemoryUsed)
 {
 }
Example #15
0
        public NodeJsPreprocessExecuteAndRunUnitTestsWithMochaExecutionStrategy(
            IProcessExecutorFactory processExecutorFactory,
            string nodeJsExecutablePath,
            string mochaModulePath,
            string chaiModulePath,
            string sinonModulePath,
            string sinonChaiModulePath,
            string underscoreModulePath,
            int baseTimeUsed,
            int baseMemoryUsed)
            : base(processExecutorFactory, nodeJsExecutablePath, underscoreModulePath, baseTimeUsed, baseMemoryUsed)
        {
            if (!File.Exists(mochaModulePath))
            {
                throw new ArgumentException(
                          $"Mocha not found in: {mochaModulePath}",
                          nameof(mochaModulePath));
            }

            if (!Directory.Exists(chaiModulePath))
            {
                throw new ArgumentException(
                          $"Chai not found in: {chaiModulePath}",
                          nameof(chaiModulePath));
            }

            if (!Directory.Exists(sinonModulePath))
            {
                throw new ArgumentException(
                          $"Sinon not found in: {sinonModulePath}",
                          nameof(sinonModulePath));
            }

            if (!Directory.Exists(sinonChaiModulePath))
            {
                throw new ArgumentException(
                          $"Sinon-chai not found in: {sinonChaiModulePath}",
                          nameof(sinonChaiModulePath));
            }

            this.MochaModulePath     = mochaModulePath;
            this.ChaiModulePath      = FileHelpers.ProcessModulePath(chaiModulePath);
            this.SinonModulePath     = FileHelpers.ProcessModulePath(sinonModulePath);
            this.SinonChaiModulePath = FileHelpers.ProcessModulePath(sinonChaiModulePath);
        }
        public PhpProjectWithDbExecutionStrategy(
            IProcessExecutorFactory processExecutorFactory,
            string phpCliExecutablePath,
            string sysDbConnectionString,
            string restrictedUserId,
            string restrictedUserPassword,
            int baseTimeUsed,
            int baseMemoryUsed)
            : base(processExecutorFactory, phpCliExecutablePath, baseTimeUsed, baseMemoryUsed)
        {
            this.MySqlHelperStrategy = new MySqlPrepareDatabaseAndRunQueriesExecutionStrategy(
                sysDbConnectionString,
                restrictedUserId,
                restrictedUserPassword);

            this.restrictedUserId       = restrictedUserId;
            this.restrictedUserPassword = restrictedUserPassword;
        }
Example #17
0
        public CSharpProjectTestsExecutionStrategy(
            Func <CompilerType, string> getCompilerPathFunc,
            IProcessExecutorFactory processExecutorFactory,
            string nUnitConsoleRunnerPath,
            int baseTimeUsed,
            int baseMemoryUsed)
            : base(processExecutorFactory, baseTimeUsed, baseMemoryUsed)
        {
            if (!File.Exists(nUnitConsoleRunnerPath))
            {
                throw new ArgumentException(
                          $"NUnitConsole not found in: {nUnitConsoleRunnerPath}",
                          nameof(nUnitConsoleRunnerPath));
            }

            this.NUnitConsoleRunnerPath = nUnitConsoleRunnerPath;
            this.GetCompilerPathFunc    = getCompilerPathFunc;
            this.TestNames = new List <string>();
            this.TestPaths = new List <string>();
        }
 public RunSpaAndExecuteMochaTestsExecutionStrategy(
     IProcessExecutorFactory processExecutorFactory,
     string pythonExecutablePath,
     string jsProjNodeModulesPath,
     string mochaNodeModulePath,
     string chaiNodeModulePath,
     string playwrightChromiumModulePath,
     int portNumber,
     int baseTimeUsed,
     int baseMemoryUsed)
     : base(
         processExecutorFactory,
         pythonExecutablePath,
         baseTimeUsed,
         baseMemoryUsed)
 {
     this.JsProjNodeModulesPath        = jsProjNodeModulesPath;
     this.MochaModulePath              = mochaNodeModulePath;
     this.ChaiModulePath               = chaiNodeModulePath;
     this.PlaywrightChromiumModulePath = playwrightChromiumModulePath;
     this.PortNumber = portNumber;
 }
        public SolidityCompileDeployAndRunUnitTestsExecutionStrategy(
            Func <CompilerType, string> getCompilerPathFunc,
            IProcessExecutorFactory processExecutorFactory,
            string nodeJsExecutablePath,
            string ganacheCliNodeExecutablePath,
            string truffleCliNodeExecutablePath,
            int portNumber,
            int baseTimeUsed,
            int baseMemoryUsed)
            : base(processExecutorFactory, baseTimeUsed, baseMemoryUsed)
        {
            if (!File.Exists(nodeJsExecutablePath))
            {
                throw new ArgumentException(
                          $"NodeJS not found in: {nodeJsExecutablePath}",
                          nameof(nodeJsExecutablePath));
            }

            if (!File.Exists(ganacheCliNodeExecutablePath))
            {
                throw new ArgumentException(
                          $"Ganache-cli not found in: {ganacheCliNodeExecutablePath}",
                          nameof(ganacheCliNodeExecutablePath));
            }

            if (!File.Exists(truffleCliNodeExecutablePath))
            {
                throw new ArgumentException(
                          $"Truffle not found in: {truffleCliNodeExecutablePath}",
                          nameof(truffleCliNodeExecutablePath));
            }

            this.nodeJsExecutablePath         = nodeJsExecutablePath;
            this.ganacheCliNodeExecutablePath = ganacheCliNodeExecutablePath;
            this.truffleCliNodeExecutablePath = truffleCliNodeExecutablePath;
            this.portNumber          = portNumber;
            this.GetCompilerPathFunc = getCompilerPathFunc;
        }
        public NodeJsExecuteAndRunAsyncJsDomTestsWithReactExecutionStrategy(
            IProcessExecutorFactory processExecutorFactory,
            string nodeJsExecutablePath,
            string mochaModulePath,
            string chaiModulePath,
            string jsdomModulePath,
            string jqueryModulePath,
            string handlebarsModulePath,
            string sinonJsDomModulePath,
            string sinonModulePath,
            string sinonChaiModulePath,
            string underscoreModulePath,
            string babelCoreModulePath,
            string reactJsxPluginPath,
            string reactModulePath,
            string reactDomModulePath,
            string nodeFetchModulePath,
            int baseTimeUsed,
            int baseMemoryUsed)
            : base(
                processExecutorFactory,
                nodeJsExecutablePath,
                mochaModulePath,
                chaiModulePath,
                jsdomModulePath,
                jqueryModulePath,
                handlebarsModulePath,
                sinonModulePath,
                sinonChaiModulePath,
                underscoreModulePath,
                baseTimeUsed,
                baseMemoryUsed)
        {
            if (!File.Exists(sinonJsDomModulePath))
            {
                throw new ArgumentException(
                          $"SinonPackaged not found in: {sinonJsDomModulePath}",
                          nameof(sinonJsDomModulePath));
            }

            if (!Directory.Exists(babelCoreModulePath))
            {
                throw new ArgumentException(
                          $"Babel-Core not found in: {babelCoreModulePath}",
                          nameof(babelCoreModulePath));
            }

            if (!Directory.Exists(reactJsxPluginPath))
            {
                throw new ArgumentException(
                          $"React JSX Plugin not found in: {reactJsxPluginPath}",
                          nameof(reactJsxPluginPath));
            }

            if (!Directory.Exists(reactModulePath))
            {
                throw new ArgumentException(
                          $"React Module not found in: {reactModulePath}",
                          nameof(reactModulePath));
            }

            if (!Directory.Exists(reactDomModulePath))
            {
                throw new ArgumentException(
                          $"ReactDOM Module not found in: {reactDomModulePath}",
                          nameof(reactDomModulePath));
            }

            if (!Directory.Exists(nodeFetchModulePath))
            {
                throw new ArgumentException(
                          $"node-fetch Module not found in: {nodeFetchModulePath}",
                          nameof(nodeFetchModulePath));
            }

            this.SinonJsDomModulePath = FileHelpers.ProcessModulePath(sinonJsDomModulePath);
            this.BabelCoreModulePath  = FileHelpers.ProcessModulePath(babelCoreModulePath);
            this.ReactJsxPluginPath   = FileHelpers.ProcessModulePath(reactJsxPluginPath);
            this.ReactModulePath      = FileHelpers.ProcessModulePath(reactModulePath);
            this.ReactDomModulePath   = FileHelpers.ProcessModulePath(reactDomModulePath);
            this.NodeFetchModulePath  = FileHelpers.ProcessModulePath(nodeFetchModulePath);
        }
        private static void DiscoverTests(string executable, ITestFrameworkReporter reporter, SettingsWrapper settings, ILogger logger, IDiaResolverFactory diaResolverFactory, IProcessExecutorFactory processExecutorFactory)
        {
            settings.ExecuteWithSettingsForExecutable(executable, logger, () =>
            {
                if (!VerifyExecutableTrust(executable, settings, logger) || !IsGoogleTestExecutable(executable, settings.TestDiscoveryRegex, logger))
                {
                    return;
                }

                int nrOfTestCases = 0;
                void ReportTestCases(TestCase testCase)
                {
                    reporter.ReportTestsFound(testCase.Yield());
                    logger.VerboseInfo("Added testcase " + testCase.DisplayName);
                    nrOfTestCases++;
                }

                var factory = new TestCaseFactory(executable, logger, settings, diaResolverFactory, processExecutorFactory);
                factory.CreateTestCases(ReportTestCases);
                logger.LogInfo("Found " + nrOfTestCases + " tests in executable " + executable);
            });
        }
        private void SafeRunBatch(string batchType, string workingDirectory, string batch, IProcessExecutorFactory processExecutorFactory)
        {
            if (string.IsNullOrEmpty(batch))
            {
                return;
            }
            if (!File.Exists(batch))
            {
                _logger.LogError($"{_threadName}Did not find " + batchType.ToLower() + " batch file: " + batch);
                return;
            }

            try
            {
                RunBatch(batchType, workingDirectory, batch, processExecutorFactory);
            }
            catch (Exception e)
            {
                _logger.LogError(
                    $"{_threadName}{batchType} batch caused exception, msg: \'{e.Message}\', executed command: \'{batch}\'");
            }
        }
        private void RunBatch(string batchType, string workingDirectory, string batch, IProcessExecutorFactory processExecutorFactory)
        {
            var executor      = processExecutorFactory.CreateExecutor(false, _logger);
            int batchExitCode = executor.ExecuteBatchFileBlocking(batch, "", workingDirectory, "", s => { });

            if (batchExitCode == 0)
            {
                _logger.DebugInfo(
                    $"{_threadName}Successfully ran {batchType} batch \'{batch}\'");
            }
            else
            {
                _logger.LogWarning(
                    $"{_threadName}{batchType} batch returned exit code {batchExitCode}, executed command: \'{batch}\'");
            }
        }
Example #24
0
        private static void DiscoverTests(string executable, ITestFrameworkReporter reporter, SettingsWrapper settings, ILogger logger, IDiaResolverFactory diaResolverFactory, IProcessExecutorFactory processExecutorFactory)
        {
            settings.ExecuteWithSettingsForExecutable(executable, logger, () =>
            {
                if (!VerifyExecutableTrust(executable, settings, logger) ||
                    !IsGoogleTestExecutable(executable, settings.TestDiscoveryRegex, logger))
                {
                    return;
                }

                int nrOfTestCases = 0;
                void ReportTestCases(TestCase testCase)
                {
                    reporter.ReportTestsFound(testCase.Yield());
                    logger.DebugInfo(String.Format(Resources.AddedTestCase, testCase.DisplayName));
                    nrOfTestCases++;
                }

                var factory = new TestCaseFactory(executable, logger, settings, diaResolverFactory, processExecutorFactory);
                factory.CreateTestCases(ReportTestCases);
                logger.LogInfo(String.Format(Resources.NumberOfTestsMessage, nrOfTestCases, executable));
            });
        }
Example #25
0
        private void RunBatch(string batchTypeString, string workingDirectory, string batch, IProcessExecutorFactory processExecutorFactory)
        {
            var executor      = processExecutorFactory.CreateExecutor(false, _logger);
            int batchExitCode = executor.ExecuteBatchFileBlocking(batch, "", workingDirectory, "", s => { });

            if (batchExitCode == 0)
            {
                _logger.DebugInfo(String.Format(Resources.SuccessfullyRun, _threadName, batchTypeString, batch));
            }
            else
            {
                _logger.LogWarning(String.Format(Resources.BatchReturnedExitCode, _threadName, batchTypeString, batchExitCode, batch));
            }
        }
Example #26
0
        private void SafeRunBatch(BatchType batchType, string workingDirectory, string batch, IProcessExecutorFactory processExecutorFactory)
        {
            string batchTypeString = (batchType == BatchType.TestSetup) ? Resources.TestSetupBatchFile : Resources.TestTeardownBatchFile;

            if (string.IsNullOrEmpty(batch))
            {
                return;
            }
            if (!File.Exists(batch))
            {
                _logger.LogError(String.Format(Resources.BatchFileMissing, _threadName, batchTypeString, batch));
                return;
            }

            try
            {
                RunBatch(batchTypeString, workingDirectory, batch, processExecutorFactory);
            }
            catch (Exception e)
            {
                _logger.LogError(String.Format(Resources.RunBatchException, _threadName, batchTypeString, e.Message, batch));
            }
        }