public static void RunTests(int testMode, string[] assemblyNames, string[] testNames, string[] categoryNames, string[] groupNames, int?buildTarget)
        {
            CallbackData.instance.isRider = true;

            var api      = ScriptableObject.CreateInstance <TestRunnerApi>();
            var settings = new ExecutionSettings();
            var filter   = new Filter
            {
                assemblyNames  = assemblyNames,
                testNames      = testNames,
                categoryNames  = categoryNames,
                groupNames     = groupNames,
                targetPlatform = (BuildTarget?)buildTarget
            };

            if (testMode > 0) // for future use - test-framework would allow running both Edit and Play test at once
            {
                filter.testMode = (TestMode)testMode;
            }

            settings.filters = new [] {
                filter
            };
            api.Execute(settings);

            api.UnregisterCallbacks(Callback); // avoid multiple registrations
            api.RegisterCallbacks(Callback);   // This can be used to receive information about when the test suite and individual tests starts and stops. Provide this with a scriptable object implementing ICallbacks
        }
Esempio n. 2
0
        public static void RunTests(int testMode, string[] assemblyNames, string[] testNames, string[] categoryNames, string[] groupNames, int?buildTarget)
        {
#if !TEST_FRAMEWORK
            Debug.LogError("Update Test Framework package to v.1.1.1+ to run tests from Rider.");
            throw new NotSupportedException("Incompatible `Test Framework` package in Unity. Update to v.1.1.1+");
#else
            CallbackData.instance.isRider = true;

            var api      = ScriptableObject.CreateInstance <TestRunnerApi>();
            var settings = new ExecutionSettings();
            var filter   = new Filter
            {
                assemblyNames  = assemblyNames,
                testNames      = testNames,
                categoryNames  = categoryNames,
                groupNames     = groupNames,
                targetPlatform = (BuildTarget?)buildTarget
            };

            if (testMode > 0) // for future use - test-framework would allow running both Edit and Play test at once
            {
                filter.testMode = (TestMode)testMode;
            }

            settings.filters = new [] {
                filter
            };
            api.Execute(settings);

            api.UnregisterCallbacks(Callback); // avoid multiple registrations
            api.RegisterCallbacks(Callback);   // This can be used to receive information about when the test suite and individual tests starts and stops. Provide this with a scriptable object implementing ICallbacks
#endif
        }
 public TestJobData(ExecutionSettings settings)
 {
     executionSettings = settings;
     isRunning = false;
     taskIndex = 0;
     taskPC = 0;
 }
Esempio n. 4
0
        /// <summary>
        /// Encapsulates logic for executing.
        /// </summary>
        public override void Execute()
        {
            DirectoryInfo distributedExecutionDirectory = TestRecords.GetDistributedDirectory(DistributionKey, RunDirectory);
            TestRecords   tests = TestRecords.Load(distributedExecutionDirectory);

            ExecutionSettings settings = new ExecutionSettings();

            settings.Tests = tests;
            settings.TestBinariesDirectory = TestBinariesDirectory;
            settings.DebugTests            = DebugTests;
            settings.DebugSti            = DebugSti;
            settings.WaitForDebugger     = WaitForDebugger;
            settings.LogFilesPath        = distributedExecutionDirectory;
            settings.JitDebuggerCommand  = JitDebuggerCommand;
            settings.TimeoutMultiplier   = TimeoutMultiplier;
            settings.ContinueExecution   = ContinueExecution;
            settings.CodeCoverageEnabled = CodeCoverage;
            settings.CodeCoverageImport  = CodeCoverageImport;
            settings.RerunFailures       = RerunFailures;
            settings.SkipDxDiag          = SkipDxDiag;
            CodeCoverageUtilities.ValidateForCodeCoverage(CodeCoverage, CodeCoverageImport);

            tests.Execute(settings);
            tests.Save(distributedExecutionDirectory);
            ExecutionBackupStore.ClearAllIntermediateTestResults(settings.LogFilesPath);
            tests.DisplayConsoleSummary();
        }
Esempio n. 5
0
        /// <summary>
        /// Runs Test process. Returns duration of execution.
        /// </summary>
        internal static TimeSpan Launch(ExecutionSettings settings, List <TestRecord> tests, DirectoryInfo executionDirectory, DebuggingEngineCommand debuggingEngine)
        {
            //Small hack to lessen the chance that Mosh UI on Win8 will interfere with tests.
            //This can be removed once all tests play nice and don't bring up Mosh in the middle of the runs.
            if (Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2)
            {
                if (ModernShellUtilities.IsImmersiveWindowOpen())
                {
                    ModernShellUtilities.EnsureDesktop();
                }
            }
            PrepareDriverPayload(tests, executionDirectory);
            //Hmm. Need to check for overflow, or be less Linq-ish...
            int timeout = AddUpTimeout(settings, tests);

            DriverLaunchSettings.StoreSettings(executionDirectory.FullName, settings.TestBinariesDirectory.FullName);
            ProcessStartInfo startInfo = PrepareProcessStartInfo(tests.First().TestInfo.Driver.Executable, executionDirectory, settings);

            ExecutionEventLog.RecordStatus("Running Driver sandbox.");
            Process p = Process.Start(startInfo);

            debuggingEngine.TestStarted(p.Id, executionDirectory);

            int millisecondsTimeout = timeout;

            if (!p.WaitForExit(millisecondsTimeout))
            {
                TerminateLaggard(p, millisecondsTimeout);
            }

            debuggingEngine.TestEnded(p.StartTime);

            return(p.ExitTime - p.StartTime);
        }
        public ReturnMessage <bool> ValidateProcess(ExecutionSettings settings)
        {
            var retResult = new ReturnMessage <bool>(false, "Execution unsuccesful");

            //Todo : Validate the process  and return true if the process is valid.
            return(retResult);
        }
Esempio n. 7
0
        public ExecutionContext(ExecutionSettings executionSettings)
        {
            if (executionSettings == null)
            {
                throw new ArgumentNullException(nameof(executionSettings));
            }
            if (executionSettings.ProblemDir == null)
            {
                throw new ArgumentNullException("Problem directory is not specified");
            }

            _inputManager = new InputManagerImpl(executionSettings.ProblemDir);

            if (executionSettings.SolutionStore == null)
            {
                throw new ArgumentNullException("Solution Store Server is not specified");
            }
            if (executionSettings.SolutionStore is FileSolutionStoreSettings settings)
            {
                _solutionManager = new SolutionManagerFileImpl(settings.SolutionsDir);
            }
            else if (executionSettings.SolutionStore is HttpServiceSolutionStoreSettings httpSettings)
            {
                _solutionManager = new SolutionManagerHttpImpl(httpSettings.ServerUrl, httpSettings.Authrozation);
            }
            else
            {
                throw new ArgumentException("Unknown type of solution store");
            }
        }
Esempio n. 8
0
 public TestJobData(ExecutionSettings settings)
 {
     guid = Guid.NewGuid().ToString();
     executionSettings = settings;
     isRunning         = false;
     taskIndex         = 0;
     taskPC            = 0;
 }
Esempio n. 9
0
        public static void BuildWithIl2CPP(bool cleanup)
        {
            var hasErrors = false;

            var startTime = DateTime.Now;

            Debug.Log("Start BuildWithIl2CPP");

            var target       = EditorUserBuildSettings.activeBuildTarget;
            var targetFolder = "./Temp/TestPlayerBuild";
            var exePath      = $"{targetFolder}/mirage.exe";

            var runner = UnityEngine.ScriptableObject.CreateInstance <TestRunnerApi>();

            try
            {
                using (new IL2CPPApplier(target, true))
                {
                    var filter = new Filter
                    {
                        targetPlatform = target,
                        testMode       = TestMode.PlayMode,
                    };
                    var testSettings = new ExecutionSettings
                    {
                        overloadTestRunSettings = GetRunSettings(exePath),
                        filters = new Filter[] { filter },
                        // sync so that IL2CPPApplier will revert after
                        runSynchronously = true,
                    };

                    using (var logCatcher = new LogErrorChecker())
                    {
                        runner.Execute(testSettings);

                        hasErrors = logCatcher.HasErrors;
                    }
                }
            }
            finally
            {
                UnityEngine.Object.DestroyImmediate(runner);
                if (cleanup)
                {
                    CleanUpBuildFolder(targetFolder);
                }
            }
            var duration = DateTime.Now - startTime;

            Debug.Log($"End BuildWithIl2CPP duration:{duration.TotalSeconds:0.0}s");

            if (hasErrors)
            {
                // throw so it fails in both editor and CI
                throw new Exception("BuildWithIl2CPP failed");
            }
        }
Esempio n. 10
0
 public TestJobData(ExecutionSettings settings)
 {
     guid = Guid.NewGuid().ToString();
     executionSettings = settings;
     isRunning         = false;
     taskIndex         = 0;
     taskPC            = 0;
     startTime         = DateTime.Now.ToString("o");
 }
Esempio n. 11
0
 public RunCommand(
     IFrostingContext context,
     IExecutionStrategy strategy,
     ICakeReportPrinter printer)
 {
     _context           = context;
     _strategy          = strategy;
     _printer           = printer;
     _executionSettings = new ExecutionSettings();
 }
Esempio n. 12
0
        /// <summary>
        /// Runs the specified test
        /// </summary>
        private static TimeSpan ExecuteTest(ExecutionSettings settings, TestRecord test, ExecutionComponents components, DirectoryInfo executionDirectory, DirectoryInfo executionLogPath)
        {
            TimeSpan processDuration = TimeSpan.Zero;
            Stack <ICleanableCommand> cleanupCommands = new Stack <ICleanableCommand>();

            try
            {
                List <TestRecord> tests = new List <TestRecord>();
                tests.Add(test);

                //Perform the following set of commands, and unwind at cleanup in reverse order, regardless of success/failure
                cleanupCommands.Push(ListenToTestsCommand.Apply(tests, components.LoggingMediator, executionLogPath, settings.DebugTests));
                if (settings.CodeCoverageEnabled)
                {
                    cleanupCommands.Push(GatherTestCodeCoverageCommand.Apply(test, executionLogPath));
                }

                ExecutionEventLog.RecordStatus("Starting Test.");
                processDuration = DriverLauncher.Launch(settings, tests, executionDirectory, components.DebuggingEngine);

                if (settings.RerunFailures && ShouldRerun(tests))
                {
                    // Run cleanup to end any active logs...
                    // *************************************
                    // ATTENTION!
                    // This behavior (clear cleanup commands, then re-push them) used for re-run has only been tested to work with the CodeCoverage and ListenToTestsCommands.
                    // Since the stack is instantiated here and used here, this is a very contained assumption.
                    // If you need to add more types of cleanup commands, please ensure they work with RerunFailures.
                    // *************************************
                    Cleanup(cleanupCommands);
                    cleanupCommands.Clear();
                    //Perform the following set of commands, and unwind at cleanup in reverse order, regardless of success/failure
                    cleanupCommands.Push(ListenToTestsCommand.Apply(tests, components.LoggingMediator, executionLogPath, settings.DebugTests));
                    if (settings.CodeCoverageEnabled)
                    {
                        cleanupCommands.Push(GatherTestCodeCoverageCommand.Apply(test, executionLogPath));
                    }
                    ClearResult(test);
                    // Then re-run the test...
                    ExecutionEventLog.RecordStatus("Not all test variations passed but no crashes recorded, attempting to re-run. (ExecuteTest Variation)");
                    processDuration = processDuration.Add(DriverLauncher.Launch(settings, tests, executionDirectory, components.DebuggingEngine));
                }
                ExecutionEventLog.RecordStatus("Test Execution sequence completed normally.");
            }
            catch (Exception e)
            {
                ExecutionEventLog.RecordException(e);
            }
            finally
            {
                Cleanup(cleanupCommands);
            }
            return(processDuration);
        }
    public static void RunTests(TestCallbacks callbacks, TestMode testModeToRun = TestMode.EditMode)
    {
        var testRunnerApi = ScriptableObject.CreateInstance <TestRunnerApi>();
        var filter        = new Filter()
        {
            testMode = testModeToRun
        };
        var executionSettings = new ExecutionSettings(filter);

        testRunnerApi.RegisterCallbacks(callbacks);
        testRunnerApi.Execute(executionSettings);
    }
Esempio n. 14
0
        /// <summary>
        /// Bucketize and run through groups of matching support file needs.
        /// </summary>
        private static void ExecuteTestSupportFileGroups(ExecutionSettings settings, List <TestRecord> stateManagementGroup, ExecutionGroupRecord stateGroupRecord, int stateGroupIndex, ExecutionComponents components)
        {
            int supportFileGroupIndex = 0;

            //Bucketize
            // NOTE: Hash method for SupportFiles is order sensitive.
            IEnumerable <List <TestRecord> > testGroups = ExecutionGrouper.Bucketize(
                stateManagementGroup,
                ExecutionGroupingLevel.SharedSupportFiles,
                x => HashSupportFileGroup(x));

            foreach (List <TestRecord> supportFileGroup in testGroups)
            {
                Stack <ICleanableCommand> filecleanupCommands = new Stack <ICleanableCommand>();

                ExecutionGroupRecord supportFileGroupRecord = ExecutionGroupRecord.Begin(ExecutionGroupType.Files, stateGroupRecord.Area);
                stateGroupRecord.ExecutionGroupRecords.Add(supportFileGroupRecord);
                DirectoryInfo executionDirectory = settings.DetermineTestExecutionDirectory(settings.DetermineGroupPath(stateGroupIndex, supportFileGroupIndex));
                DirectoryInfo logDirectory       = settings.DetermineTestLogDirectory(settings.DetermineGroupPath(stateGroupIndex, supportFileGroupIndex));
                PrepLogDirectory(logDirectory);//HACK: Ideally logging can guarantee this in final configuration.
                if (GetCachedExecutionResult(settings, supportFileGroup, logDirectory, components))
                {
                    ExecutionEventLog.RecordStatus("Successfully retrieved previously stored execution result. ");
                }
                else
                {
                    ExecutionEventLog.RecordStatus("Applying Support Files and Executing.");
                    ExecutionGroupLogCommand command = ExecutionGroupLogCommand.Apply("SupportFiles", logDirectory, components.LoggingMediator);
                    filecleanupCommands.Push(command);
                    filecleanupCommands.Push(DesktopSnapshotCommand.Apply(logDirectory));
                    // Create temporary directory, but if we are using a fixed test execution directory, don't delete it if it was pre-existing.
                    filecleanupCommands.Push(TemporaryDirectoryCommand.Apply(executionDirectory, settings.FixedTestExecutionDirectory != null));
                    filecleanupCommands.Push(SupportFileCommand.Apply(supportFileGroup, settings.TestBinariesDirectory, executionDirectory));
                    filecleanupCommands.Push(BackupRecordsCommand.Apply(supportFileGroup, logDirectory));
                    filecleanupCommands.Push(ProcessLogsCommand.Apply(supportFileGroup, components.LoggingMediator));
                    try
                    {
                        ExecuteUniformTestGroup(settings, supportFileGroup, supportFileGroupRecord, stateGroupIndex, supportFileGroupIndex, components);
                    }
                    catch (Exception e)
                    {
                        ExecutionEventLog.RecordException(e);
                    }
                    finally
                    {
                        Cleanup(filecleanupCommands);
                    }
                }
                supportFileGroupRecord.End();
                supportFileGroupIndex++;
            }
        }
Esempio n. 15
0
        private static MethodInfo PrepareAlgorithmForRun(ExecutionSettings executionSettings)
        {
            if (executionSettings == null)
            {
                throw new ArgumentNullException(nameof(executionSettings));
            }

            var entryPoint = ValidateAlgorithm(executionSettings.AlgorithmDir);
            var assembly   = Assembly.LoadFrom(entryPoint.Assembly);
            var type       = assembly.GetType(entryPoint.ClassName);

            return(type.GetMethod(entryPoint.MethodName));
        }
Esempio n. 16
0
        protected string GetTestResultsPathWithTestName(bool createFolder)
        {
            string retString = CurrentTestMethodName.Replace(TestBaseNamespace, "").Replace(".", @"\").SanitisePath();

            /* need to sanitise the path before passing in to OutputPath method as it combines the paths
             * and throws an exception if illegal characters exist when combining paths.
             */
            retString = ExecutionSettings.OutputPath(
                $@"{TestResultsBaseFolder}\{retString}\{DateTime.Now.ToString("yyyyMMdd")}\{DateTime.Now.ToString(
                    "HHmmss")}", createFolder);

            return(retString.SanitisePath());
        }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptHost"/> class.
 /// </summary>
 /// <param name="engine">The engine.</param>
 /// <param name="context">The context.</param>
 protected ScriptHost(ICakeEngine engine, ICakeContext context)
 {
     if (engine == null)
     {
         throw new ArgumentNullException(nameof(engine));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     Engine   = engine;
     Context  = context;
     Settings = new ExecutionSettings();
 }
        /// <summary>
        /// Retrieve the test list for given mode.
        /// </summary>
        /// <param name="testMode"></param>
        /// <param name="assemblyNames">Can be null.</param>
        /// <param name="callback"></param>
        void RetrieveTestList(TestMode testMode, string[] assemblyNames, Action <ITestAdaptor, ExecutionSettings> callback)
        {
            var filter = new Filter {
                testMode = testMode, assemblyNames = assemblyNames
            };
            var executionSettings = new ExecutionSettings {
                filter = filter, filters = new Filter[0]
            };

            api.RetrieveTestList(testMode, rootTest =>
            {
                callback(rootTest, executionSettings);
            });
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            ExecutionSettings executionSettings = ExecutionSettings.None | ExecutionSettings.AllowUiPostconditions | ExecutionSettings.AllowAutoLogIn;

            //true
            Console.WriteLine(executionSettings.HasFlag(ExecutionSettings.AllowUiPostconditions));

            //false
            Console.WriteLine(executionSettings.HasFlag(ExecutionSettings.AllowUiPreconditions));

            //true
            Console.WriteLine(executionSettings.HasFlag(ExecutionSettings.AllowAutoLogIn));
            Console.ReadKey();
        }
Esempio n. 20
0
        /// <summary>
        /// Executes Tests
        /// </summary>
        public static void Execute(ExecutionSettings settings)
        {
            Stack <ICleanableCommand> cleanupCommands = new Stack <ICleanableCommand>();

            try
            {
                //Elevation Service is hitting Error #5 "Access Denied" in XP - We don't have run time dependencies on it right now, so disabling.
                //cleanupCommands.Push(ElevationServiceCommand.Apply(infraBinariesDirectory));

                cleanupCommands.Push(LogDirectoryCommand.Apply(settings.LogFilesPath, settings.SkipDxDiag));

                ExecutionComponents executionComponents = new ExecutionComponents();
                executionComponents.DebuggingEngine = DebuggingEngineCommand.Apply(settings.InfraBinariesDirectory, settings.JitDebuggerCommand);
                cleanupCommands.Push(executionComponents.DebuggingEngine);
                ExecutionEventLog.RecordStatus("Creating LoggingMediator.");
                executionComponents.LoggingMediator = new LoggingMediator(settings.DebugTests); //Consider using dispose pattern.
                executionComponents.LoggingMediator.StartService(executionComponents.DebuggingEngine, settings.Tests.TestCollection.Count(record => record.ExecutionEnabled));

                //

                cleanupCommands.Push(ExecutionGroupLogCommand.Apply("InfraExecution", settings.LogFilesPath, executionComponents.LoggingMediator));
                if (settings.CodeCoverageEnabled)
                {
                    cleanupCommands.Push(MergeCodeCoverageDataCommand.Apply(settings.LogFilesPath));
                }
                cleanupCommands.Push(TemporaryDirectoryCommand.Apply(settings.ExecutionRootDirectory));
                cleanupCommands.Push(MoveWindowCommand.Apply());
                cleanupCommands.Push(ExecutionEventLog.Apply(settings.LogFilesPath, !settings.ContinueExecution));

                try
                {
                    ExecuteTestStateGroups(settings, executionComponents);
                }
                catch (Exception e)
                {
                    ExecutionEventLog.RecordException(e);
                }
                finally
                {
                    ExecutionEventLog.RecordStatus("Ending Test Sequence.");
                    ExecutionEventLog.RecordStatus("Shutting down test logging system.");
                    executionComponents.LoggingMediator.StopService();
                }
            }
            finally
            {
                Cleanup(cleanupCommands);
                Console.WriteLine("Test Execution has finished.\n");
            }
        }
Esempio n. 21
0
        public void Execute()
        {
            //  unity -batchmode -nographics -runTests -runSynchronously -projectPath
            //  . -logFile -testResults /j/logs/test.xml

            // unity -batchmode -nographics -executeCommand HumanBuilders.CLI.Test
            // -testResults /j/logs/test.xml

            Filter            filter   = CreateFilter(testMode);
            ExecutionSettings settings = new ExecutionSettings(filter);

            settings.runSynchronously = synchronous;
            runner.RegisterCallbacks(this);
            string result = runner.Execute(settings);
        }
Esempio n. 22
0
        private static int AddUpTimeout(ExecutionSettings settings, List <TestRecord> tests)
        {
            int total = 0;

            foreach (TestRecord test in tests)
            {
                int timeout = ConvertTimeoutToMilliSeconds(settings.DetermineTimeout(test.TestInfo.Timeout, test.TestInfo.Type));
                if (timeout >= int.MaxValue)
                {
                    return(int.MaxValue);
                }
                total += timeout;
            }
            return(total);
        }
        public ReturnMessage <string> Execute(ExecutionSettings settings)
        {
            var retResult = new ReturnMessage <string>(string.Empty, "Execution unsuccesful");

            switch (settings.ExecutionType)
            {
            case OperationType.GET:
                retResult = ExecuteGetOperation(settings);
                break;

            case OperationType.POST:
                retResult = this.ExecutePostOperation(settings);
                break;
            }
            return(retResult);
        }
Esempio n. 24
0
        public override void Run(ExecutionSettings executionSettings)
        {
            builder = new MsDataBuilder();
            var data = builder.BuildInstance(executionSettings);

            var compressedDatabase = FrequentSetGenerator.Generate(data.Transactions, executionSettings.MinSup);

            var tree = new FpTree<int>();
            tree.BuildFpTreeFromData(compressedDatabase);

            var treeExplorer = new TreeExplorer<int>((int)(data.Transactions.Keys.Count * executionSettings.MinSup));
            var rules = treeExplorer.GenerateRuleSet(tree, executionSettings.MinConf);

            var result = PrintRules(rules, executionSettings.DataSourcePath, executionSettings.MinSup, executionSettings.MinConf, data.Transactions.Keys.Count, data.Elements);
            Console.WriteLine(result);
        }
Esempio n. 25
0
        /// <summary>
        /// Retrieve previously generated execution results, if they are present.
        /// </summary>
        private static bool GetCachedExecutionResult(ExecutionSettings settings, List <TestRecord> executionGroup, DirectoryInfo executionLogPath, ExecutionComponents components)
        {
            List <TestRecord> previousResults = null;

            if (settings.ContinueExecution)
            {
                previousResults = ExecutionBackupStore.LoadIntermediateTestRecords(executionLogPath);
            }
            if (previousResults != null)
            {
                //Confirm we have a match for all  the tests
                if (executionGroup.Count != previousResults.Count)
                {
                    return(false);
                }

                for (int i = 0; i < executionGroup.Count; i++)
                {
                    if (executionGroup[i].TestInfo.Name != previousResults[i].TestInfo.Name)
                    {
                        return(false); //Note: We should probably ---- previous log results
                    }
                }

                for (int i = 0; i < executionGroup.Count; i++)
                {
                    TestRecord test     = executionGroup[i];
                    TestRecord previous = previousResults[i];

                    test.Log = previous.Log;
                    foreach (FileInfo file in previous.LoggedFiles)
                    {
                        test.LoggedFiles.Add(file);
                    }
                    test.Machine = previous.Machine;
                    foreach (VariationRecord record in previous.Variations)
                    {
                        test.Variations.Add(record);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 26
0
        public static void MakeBuild(string[] testToExecute, BuildTarget platform)
        {
            var filter = new Filter()
            {
                testMode       = TestMode.PlayMode,
                targetPlatform = platform
            };

            if (testToExecute.Length > 0)
            {
                filter.testNames = testToExecute;
            }

            var settings = new ExecutionSettings(filter);

            TestRunnerInstance.Execute(settings);
        }
Esempio n. 27
0
        public MsInstance <int> BuildInstance(ExecutionSettings executionSettings)
        {
            var instance = new MsInstance <int>(executionSettings.TransactionsNumber);

            if (!File.Exists(executionSettings.DataSourcePath))
            {
                //! here an exception should be thrown!
                return(null);
            }

            var    r = new StreamReader(executionSettings.DataSourcePath);
            string line, transactionId = null;
            var    votes = new List <int>();

            while (!r.EndOfStream)
            {
                line = r.ReadLine();
                if (line != null)
                {
                    switch (line[0])
                    {
                    case 'A':
                        instance.AddElement(line);
                        break;

                    case 'C':
                        if (transactionId != null)
                        {
                            instance.AddEntry(Convert.ToInt32(transactionId), votes.ToArray());
                            votes.Clear();
                        }
                        transactionId = line.Split(',')[2];
                        break;

                    case 'V':
                        votes.Add(Convert.ToInt32(line.Split(',')[1]));
                        break;
                    }
                }
            }
            if (transactionId != null)
            {
                instance.AddEntry(Convert.ToInt32(transactionId), votes.ToArray());
            }
            return(instance);
        }
Esempio n. 28
0
        private static IEnumerable <TestTaskBase> GetTaskList(ExecutionSettings settings)
        {
            if (settings == null)
            {
                yield break;
            }

            if (settings.EditModeIncluded() || (PlayerSettings.runPlayModeTestAsEditModeTest && settings.PlayModeInEditorIncluded()))
            {
                yield return(new SaveModiedSceneTask());

                yield return(new RegisterFilesForCleanupVerificationTask());

                yield return(new SaveUndoIndexTask());

                yield return(new BuildTestTreeTask(TestPlatform.EditMode));

                yield return(new PrebuildSetupTask());

                yield return(new LegacyEditModeRunTask());

                yield return(new PerformUndoTask());

                yield return(new CleanupVerificationTask());

                yield break;
            }

            if (settings.PlayModeInEditorIncluded() && !PlayerSettings.runPlayModeTestAsEditModeTest)
            {
                yield return(new SaveModiedSceneTask());

                yield return(new LegacyPlayModeRunTask());

                yield break;
            }

            if (settings.PlayerIncluded())
            {
                yield return(new LegacyPlayerRunTask());

                yield break;
            }
        }
Esempio n. 29
0
        private string _GetOutputFile(SettingsType settingsType)
        {
            switch (settingsType)
            {
            case SettingsType.ProjectBound:
            {
                return(ExecutionSettings.SettingsFilePath());
            }

            case SettingsType.CentrallyStored:
            {
                return(ExecutionSettings.SettingsStorePath());
            }

            default:
            {
                return(null);
            }
            }
        }
Esempio n. 30
0
        public void Run()
        {
            if (!this.settings.IsEnabled)
            {
                throw new ApplicationExecutionException("Run As command not enabled.");
            }

            if (!File.Exists(this.settings.Application))
            {
                string errorMessage = string.Concat("Executable '", this.settings.Application, "' could be found.");
                throw new ApplicationExecutionException(errorMessage);
            }

            ExecutionSettings impersonationSettings = this.entryManager.GetExecutionSettings();

            if (string.IsNullOrWhiteSpace(impersonationSettings.Username))
            {
                throw new ApplicationExecutionException("No username present.");
            }

            if (impersonationSettings.Password.IsEmpty)
            {
                throw new ApplicationExecutionException("No password present.");
            }

            if (!string.IsNullOrWhiteSpace(this.settings.WorkingDir) && !Directory.Exists(this.settings.WorkingDir))
            {
                throw new ApplicationExecutionException(string.Format("Working directory '{0}' does not exist.", this.settings.WorkingDir));
            }

            try
            {
                IImpersonationHandler impersonation = new NativeCallImpersonationHandler();
                impersonation.ExecuteApplication(this.entryManager);
            }
            catch (Exception ex)
            {
                throw new ApplicationExecutionException(ex.Message, ex);
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Bucketize collection of tests by matching State management needs, and run through each group.
        /// Notion of Execution group + a tracking counter variable seem to be critical elements.
        /// This (and supportfiles one) can likely get generalized+factored well to the ExecutionGroup class with some thought.
        /// </summary>
        private static void ExecuteTestStateGroups(ExecutionSettings settings, ExecutionComponents executionComponents)
        {
            ExecutionEventLog.RecordStatus("Running Test Sequence.");

            List <TestRecord> enabledTests = new List <TestRecord>(settings.Tests.TestCollection.Where(test => (test.ExecutionEnabled == true)));

            int stateGroupIndex = 0;
            // NOTE: Hash method for Deployments is order sensitive.
            IEnumerable <List <TestRecord> > testGroups = ExecutionGrouper.Bucketize(enabledTests,
                                                                                     ExecutionGroupingLevel.SharedStateManagement,
                                                                                     x => x.TestInfo.Area + x.TestInfo.Deployments.ToCommaSeparatedList());

            foreach (List <TestRecord> stateManagementGroup in testGroups)
            {
                ExecutionEventLog.RecordStatus("Running State Group # " + stateGroupIndex + " of " + testGroups.Count());
                Stack <ICleanableCommand> stateCleanupCommands = new Stack <ICleanableCommand>();
                ExecutionGroupRecord      stateGroupRecord     = ExecutionGroupRecord.Begin(ExecutionGroupType.State, stateManagementGroup[0].TestInfo.Area);
                try
                {
                    settings.Tests.ExecutionGroupRecords.Add(stateGroupRecord);
                    DirectoryInfo            stateLogPath = settings.DetermineTestLogDirectory(settings.DetermineGroupPath(stateGroupIndex));
                    ExecutionGroupLogCommand command      = ExecutionGroupLogCommand.Apply("StateManagement", stateLogPath, executionComponents.LoggingMediator);
                    stateCleanupCommands.Push(command);

                    stateCleanupCommands.Push(ExecutionStateCommand.Apply(stateManagementGroup.First(), settings.TestBinariesDirectory));
                    ExecuteTestSupportFileGroups(settings, stateManagementGroup, stateGroupRecord, stateGroupIndex, executionComponents);
                }
                catch (Exception e)
                {
                    ExecutionEventLog.RecordException(e);
                }
                finally
                {
                    Cleanup(stateCleanupCommands);
                    stateGroupRecord.End();
                    stateGroupIndex++;
                }
            }
        }
Esempio n. 32
0
        public override void Run(ExecutionSettings executionSettings)
        {
            builder = new MsDataBuilder();
            var data = builder.BuildInstance(executionSettings);

            var frequentSets = data.Elements.Keys.Select(element => new List<int> { element }).ToList();

            frequentSets = frequentSets.Where(set => set.IsFrequent(data.Transactions, executionSettings.MinSup)).ToList();
            var frequentItemSets = frequentSets.ToDictionary(set => new FrequentItemSet<int>(set),
                                                             set => set.GetSupport(data.Transactions));
            List<List<int>> candidates;

            while ((candidates = GenerateCandidates(frequentSets)).Count > 0)
            {
                //! sprawdź czy któryś podzbiór k-1 elementowy kadydatów nie jest w frequentSets => wywal go!

                // leave only these sets which are frequent
                candidates =
                    candidates.Where(set => set.IsFrequent(data.Transactions, executionSettings.MinSup)).ToList();

                if (candidates.Count > 0)
                {
                    frequentSets = candidates;
                    foreach (var candidate in candidates)
                    {
                        frequentItemSets.Add(new FrequentItemSet<int>(candidate), candidate.GetSupport(data.Transactions));
                    }
                }
                else
                {
                    // we don't have any more candidates
                    break;
                }
            }

            //here we should do something with the candidates
            var decisionRules = new List<DecisionRule<int>>();

            foreach (var frequentSet in frequentSets)
            {
                var subSets = EnumerableHelper.GetSubsets(frequentSet);

                foreach (var t in subSets)
                {
                    var leftSide = new FrequentItemSet<int>(t);
                    for (var j = 0; j < subSets.Count; j++)
                    {
                        var rightSide = new FrequentItemSet<int>(subSets[j]);
                        if (rightSide.ItemSet.Count != 1 || !FrequentItemSet<int>.SetsSeparated(rightSide, leftSide))
                        {
                            continue;
                        }

                        if (frequentItemSets.ContainsKey(leftSide))
                        {
                            var confidence = (double)frequentItemSets[new FrequentItemSet<int>(frequentSet)] / frequentItemSets[leftSide];
                            if (confidence >= executionSettings.MinConf)
                            {
                                var rule = new DecisionRule<int>(leftSide.ItemSet, rightSide.ItemSet, frequentItemSets[new FrequentItemSet<int>(frequentSet)], confidence);
                                decisionRules.Add(rule);
                            }
                        }
                    }
                }
            }

            var result = PrintRules(decisionRules, executionSettings.DataSourcePath, executionSettings.MinSup, executionSettings.MinConf, data.Transactions.Keys.Count, data.Elements);
            Console.WriteLine(result);
        }
 internal BasicWorklistItem(ExecutionSettings settings)
 {
     this._execSettings = settings;
 }
Esempio n. 34
0
 public abstract void Run(ExecutionSettings executionSettings);
 internal DetailedWorklistItem(ExecutionSettings settings)
     : base(settings)
 {
 }