private void ExecuteCheck(ExecuteContext context, ExecuteParameters parameters) { var cell = (Parse)parameters.Cell; var matcher = new ListMatcher(Processor, new ArrayMatchStrategy(Processor, cell.Parts.Parts)); matcher.MarkCell(context.SystemUnderTest.Value, GetActual(context, parameters), cell.Parts.Parts); }
public ExecuteResult Execute(ExecuteParameters executeParameters) { var executableName = $"{executeParameters.BuildResult.ArtifactsPaths.ProgramName}.dll"; if (!File.Exists(Path.Combine(executeParameters.BuildResult.ArtifactsPaths.BinariesDirectoryPath, executableName))) { executeParameters.Logger.WriteLineError($"Did not find {executableName} in {executeParameters.BuildResult.ArtifactsPaths.BinariesDirectoryPath}, but the folder contained:"); foreach (var file in new DirectoryInfo(executeParameters.BuildResult.ArtifactsPaths.BinariesDirectoryPath).GetFiles("*.*")) { executeParameters.Logger.WriteLineError(file.Name); } return(new ExecuteResult(false, -1, Array.Empty <string>(), Array.Empty <string>())); } ConsoleHandler.EnsureInitialized(executeParameters.Logger); try { return(Execute( executeParameters.Benchmark, executeParameters.Logger, executeParameters.BuildResult.ArtifactsPaths, executeParameters.Diagnoser, executableName, executeParameters.Config)); } finally { ConsoleHandler.Instance.ClearProcess(); } }
TypedValue Execute(Tree <Cell> targetCell) { var parameters = new ExecuteParameters( ExecuteParameters.Make(new CellTreeLeaf(memberName), new CellTree(), targetCell)); return(execute.Execute(new ExecuteContext(ExecuteCommand.Invoke, target), parameters)); }
private TypedValue ExecuteEvaluate(ExecuteContext context, ExecuteParameters parameters) { var cell = (Parse)parameters.Cell; var matcher = new ListMatcher(Processor, new ArrayMatchStrategy(Processor, cell.Parts.Parts)); return(new TypedValue(matcher.IsEqual(context.Target.Value.Value, cell))); }
/// <summary>Executes the specified benchmark.</summary> public ExecuteResult Execute(ExecuteParameters executeParameters) { // TODO: preallocate buffer for output (no direct logging)? var hostLogger = LogOutput ? executeParameters.Logger : NullLogger.Instance; var host = new InProcessHost(executeParameters.BenchmarkCase, hostLogger, executeParameters.Diagnoser); int exitCode = -1; var runThread = new Thread(() => exitCode = ExecuteCore(host, executeParameters)); if (executeParameters.BenchmarkCase.Descriptor.WorkloadMethod.GetCustomAttributes <STAThreadAttribute>(false).Any()) { runThread.SetApartmentState(ApartmentState.STA); } runThread.IsBackground = true; var timeout = HostEnvironmentInfo.GetCurrent().HasAttachedDebugger ? UnderDebuggerTimeout : ExecutionTimeout; runThread.Start(); if (!runThread.Join((int)timeout.TotalMilliseconds)) { throw new InvalidOperationException( $"Benchmark {executeParameters.BenchmarkCase.DisplayInfo} takes too long to run. " + "Prefer to use out-of-process toolchains for long-running benchmarks."); } return(GetExecutionResult(host.RunResults, exitCode)); }
public IHttpActionResult Identities(ExecuteParameters executeParameters) { using (wfe_sampleEntities entities = new wfe_sampleEntities()) { var identities = entities.Employees.Where(e => e.Role.Name == executeParameters.Name).Select(s => s.Name).ToList(); return(Ok(new { data = identities, success = true, error = "", message = "" })); } }
public ExecuteResult Execute(ExecuteParameters executeParameters) { string exePath = executeParameters.BuildResult.ArtifactsPaths.ExecutablePath; string args = executeParameters.BenchmarkId.ToArguments(); if (!File.Exists(exePath)) { return(new ExecuteResult(false, -1, default, Array.Empty <string>(), Array.Empty <string>()));
[Test] public void LastActionIsSetAsExpectedCellAttribute() { SetUpSUT("procedure"); var parameters = new ExecuteParameters( ExecuteParameters.Make(new CellTreeLeaf("procedure"), new CellTree(), targetCell)); execute.Execute(new ExecuteContext(ExecuteCommand.Check, target.Value), parameters); Assert.AreEqual("blah blah", targetCell.Value.GetAttribute(CellAttribute.Extension)); }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { if (context.Command != ExecuteCommand.Check) { return(false); } TypedValue actualValue = GetTypedActual(context, parameters); return(typeof(Parse).IsAssignableFrom(actualValue.Type)); }
public ExecuteResult Execute(ExecuteParameters executeParameters) { var exePath = executeParameters.BuildResult.ArtifactsPaths.ExecutablePath; var args = executeParameters.BenchmarkId.ToArgument(); if (!File.Exists(exePath)) { return(new ExecuteResult(false, -1, Array.Empty <string>(), Array.Empty <string>())); } return(Execute(executeParameters.Benchmark, executeParameters.BenchmarkId, executeParameters.Logger, exePath, null, args, executeParameters.Diagnoser, executeParameters.Resolver, executeParameters.Config)); }
public ExecuteResult Execute(ExecuteParameters executeParameters) { var hostLogger = LogOutput ? executeParameters.Logger : NullLogger.Instance; var host = new InProcessHost(executeParameters.BenchmarkCase, hostLogger, executeParameters.Diagnoser); int exitCode = 0; // The class is internal typeof(InProcessNoEmitToolchain).Assembly.GetType("BenchmarkDotNet.Toolchains.InProcess.NoEmit.InProcessNoEmitRunner").GetMethod("Run").Invoke(null, new object [] { host, executeParameters.BenchmarkCase }); return(GetExecutionResult(host.RunResults, exitCode, executeParameters.Logger, executeParameters.BenchmarkCase.Config.Encoding)); }
public ExecuteResult Execute(ExecuteParameters executeParameters) { var exePath = executeParameters.BuildResult.ArtifactsPaths.ExecutablePath; var args = executeParameters.Diagnoser == null ? string.Empty : Engine.Signals.DiagnoserIsAttachedParam; if (!File.Exists(exePath)) { return(new ExecuteResult(false, -1, Array.Empty <string>(), Array.Empty <string>())); } return(Execute(executeParameters.Benchmark, executeParameters.Logger, exePath, null, args, executeParameters.Diagnoser, executeParameters.Resolver, executeParameters.Config)); }
public ExecuteResult Execute(ExecuteParameters executeParameters) { string exePath = executeParameters.BuildResult.ArtifactsPaths.ExecutablePath; string args = executeParameters.BenchmarkId.ToArguments(); if (!File.Exists(exePath)) { return(ExecuteResult.CreateFailed()); } return(Execute(executeParameters.BenchmarkCase, executeParameters.BenchmarkId, executeParameters.Logger, executeParameters.BuildResult.ArtifactsPaths, args, executeParameters.Diagnoser, executeParameters.Resolver, executeParameters.LaunchIndex)); }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { switch (context.Command) { case ExecuteCommand.Check: ExecuteCheck(context, parameters); break; case ExecuteCommand.Compare: return(ExecuteEvaluate(context, parameters)); } return(TypedValue.Void); }
public ExecuteResult Execute(ExecuteParameters executeParameters) { if (!(executeParameters.Benchmark is ExternalProcessBenchmark benchmark)) { throw new ArgumentException($"Benchmark given is not an {nameof(ExternalProcessBenchmark)}"); } var exePath = executeParameters.BuildResult.ArtifactsPaths.ExecutablePath; using (var proc = new Process { StartInfo = CreateStartInfo(exePath, benchmark) }) { return(Execute(proc, benchmark, executeParameters.Logger)); } }
public virtual IActionResult ExecuteAction([FromBody] ExecuteParameters executeParameters) { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(200, default(ActionExecutionResult)); string exampleJson = null; exampleJson = "\"\""; var example = exampleJson != null ? JsonConvert.DeserializeObject <ActionExecutionResult>(exampleJson) : default(ActionExecutionResult); //TODO: Change the data returned return(new ObjectResult(example)); }
public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters) { switch (context.Command) { case ExecuteCommand.Check: var cell1 = (Parse)parameters.Cell; return(cell1.Parts != null && typeof(IList).IsAssignableFrom(GetTypedActual(context, parameters).Type)); case ExecuteCommand.Compare: var cell2 = (Parse)parameters.Cell; return(cell2.Parts != null && typeof(IList).IsAssignableFrom(context.Target.Value.Type)); default: return(false); } }
private int ExecuteCore(IHost host, ExecuteParameters parameters) { int exitCode = -1; var process = Process.GetCurrentProcess(); var oldPriority = process.PriorityClass; var oldAffinity = process.TryGetAffinity(); var thread = Thread.CurrentThread; var oldThreadPriority = thread.Priority; var affinity = parameters.BenchmarkCase.Job.ResolveValueAsNullable(EnvironmentMode.AffinityCharacteristic); try { process.TrySetPriority(ProcessPriorityClass.High, parameters.Logger); thread.TrySetPriority(ThreadPriority.Highest, parameters.Logger); if (affinity != null) { process.TrySetAffinity(affinity.Value, parameters.Logger); } var generatedAssembly = ((InProcessEmitArtifactsPath)parameters.BuildResult.ArtifactsPaths) .GeneratedAssembly; exitCode = RunnableProgram.Run( parameters.BenchmarkId, generatedAssembly, parameters.BenchmarkCase, host); } catch (Exception ex) { parameters.Logger.WriteLineError($"// ! {GetType().Name}, exception: {ex}"); } finally { process.TrySetPriority(oldPriority, parameters.Logger); thread.TrySetPriority(oldThreadPriority, parameters.Logger); if (affinity != null && oldAffinity != null) { process.TrySetAffinity(oldAffinity.Value, parameters.Logger); } } return(exitCode); }
private int ExecuteCore(IHost host, ExecuteParameters parameters) { int exitCode = -1; var process = Process.GetCurrentProcess(); var oldPriority = process.PriorityClass; var oldAffinity = process.TryGetAffinity(); #if !NETCOREAPP1_1 var thread = Thread.CurrentThread; var oldThreadPriority = thread.Priority; #endif var affinity = parameters.Benchmark.Job.ResolveValueAsNullable(EnvMode.AffinityCharacteristic); try { process.TrySetPriority(ProcessPriorityClass.High, parameters.Logger); #if !NETCOREAPP1_1 thread.TrySetPriority(ThreadPriority.Highest, parameters.Logger); #endif if (affinity != null) { process.TrySetAffinity(affinity.Value, parameters.Logger); } exitCode = InProcessRunner.Run(host, parameters.Benchmark, CodegenMode, parameters.Config); } catch (Exception ex) { parameters.Logger.WriteLineError($"// ! {GetType().Name}, exception: {ex}"); } finally { process.TrySetPriority(oldPriority, parameters.Logger); #if !NETCOREAPP1_1 thread.TrySetPriority(oldThreadPriority, parameters.Logger); #endif if (affinity != null && oldAffinity != null) { process.TrySetAffinity(oldAffinity.Value, parameters.Logger); } } return(exitCode); }
public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters) { TypedValue actualValue = GetTypedActual(context, parameters); var cell = (Parse)parameters.Cell; var expected = new FixtureTable(cell.Parts); var tables = actualValue.GetValue <Parse>(); var actual = new FixtureTable(tables); string differences = actual.Differences(expected); if (differences.Length == 0) { Processor.TestStatus.MarkRight(parameters.Cell); } else { Processor.TestStatus.MarkWrong(parameters.Cell, differences); cell.More = new Parse("td", string.Empty, tables, null); } return(TypedValue.Void); }
public IHttpActionResult ExecuteRuleCheck([FromBody] ExecuteParameters executeParameters) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Type type = executingAssembly.GetType("WorkFlowServices.Controllers.HelperMethods"); MethodInfo mInfo = type.GetMethod(executeParameters.Name); ParameterInfo[] parameters = mInfo.GetParameters(); object classInstance = Activator.CreateInstance(type, null); object result = null; if (parameters.Length == 0) { result = mInfo.Invoke(classInstance, null); } else { string userId = executeParameters.IdentityId; Guid processId = executeParameters.ProcessInstance.Id.Value; object[] paramsArray = new object[parameters.Length]; if (executeParameters.Name == "IsAuthorized") { paramsArray[0] = userId; } else { paramsArray[0] = userId; paramsArray[1] = processId; } result = mInfo.Invoke(classInstance, paramsArray); } return(Ok(new { data = Convert.ToBoolean(result), success = true, error = "", message = "" })); }
public ExecuteResult Execute(ExecuteParameters executeParameters) { executeParameters.Logger.WriteLine("Executing"); Done = true; return(new ExecuteResult(true, 0, Array.Empty <string>(), Array.Empty <string>())); }
public async Task ExecuteQuery() { if (!CanExecuteQuery) return; var dtNow = DateTime.Now; _cancellationTokenSource = new CancellationTokenSource(); IsExecutingQuery = true; Status = "Executing query."; var databaseQueryService = new DbClient(); var executeParameters = new ExecuteParameters { ConnectionString = ConnectionString, SqlStatement = CommandTextSource }; var cancellationToken = _cancellationTokenSource.Token; var updateStatusAction = OneTimeAction.Execute(1000, () => { Status = string.Format("Executing query in {0}. ", (DateTime.Now - dtNow).ToString(@"dd\.hh\:mm\:ss")); }); var results = await databaseQueryService.ExecuteSqlAsync(executeParameters, DefaultQueryTimeout, cancellationToken); // Reset updateStatusAction.Cancel(); Status = string.Empty; ResultsSets.Clear(); // Preccess results var i = 1; foreach (var executeResults in results) { var hasData = executeResults.ResultsData != null && executeResults.ResultsData.Rows.Count > 0; var resultsSetModel = new ResultsSetModel { Title = "Result Set " + i, StatusMessage = executeResults.StatusMessage, ExceptionDetails = executeResults.ExceptionDetails }; if (hasData) resultsSetModel.ResultsData = executeResults.ResultsData; else resultsSetModel.ResultsData = executeResults.StatusMessage; ResultsSets.Add(resultsSetModel); i++; } IsExecutingQuery = false; IsCancelingQuery = false; SelectedResultsSetsIndex = 0; }
public void TestRegisterAndGet() { Assert.IsTrue(IsMatch("<<xyz")); Assert.IsFalse(TestUtils.IsMatch(ExecuteCommand.Check, new ExecuteSymbolSave(), ExecuteParameters.Make(TestUtils.CreateCell("x<<yz")))); Assert.IsFalse(IsMatch("x<<yz")); Assert.IsTrue(TestUtils.IsMatch(ExecuteCommand.Check, new ExecuteSymbolSave(), ExecuteParameters.Make(TestUtils.CreateCell(">>xyz")))); Assert.IsFalse(TestUtils.IsMatch(ExecuteCommand.Input, new ExecuteSymbolSave(), ExecuteParameters.MakeMemberCell(TestUtils.CreateCell("stuff"), TestUtils.CreateCell(">>xyz")))); Assert.IsFalse(TestUtils.IsMatch(ExecuteCommand.Check, new ExecuteSymbolSave(), ExecuteParameters.Make(TestUtils.CreateCell("x>>yz")))); Assert.IsFalse(IsMatch("x>>yz")); Assert.IsFalse(TestUtils.IsMatch(ExecuteCommand.Input, new ExecuteSymbolSave(), ExecuteParameters.MakeMemberCell(TestUtils.CreateCell("stuff"), TestUtils.CreateCell("error")))); }
public void Generate(ExecuteParameters parameters) { Controls.Clear(); CurtTop = ItemMarginTop; if (parameters != null) { foreach (KeyValuePair<string, ExecuteParameter> i in parameters) { string key = i.Key; ExecuteParameter p = i.Value; if (p.Value != null && p.Value is CommandNode) { UICommandNode ucmd = null; CommandNode cmd = (CommandNode)p.Value; if (!cmd.Visible) { continue; } if (cmd is UICommandNode) { ucmd = (UICommandNode)cmd; } if (cmd is SetCommand) { SetCommand set = (SetCommand)cmd; FieldInfo f = cmd.GetType().GetField("Content"); SettingTag tag = AddCmdItem(p.Name, cmd, f.Name, set.IsCondition ? 1 : 0); tag.Cmd = cmd; tag.Id = f.Name; } else if (cmd is ArrayCommand) { ArrayCommand ac = (ArrayCommand)cmd; AddCmdItem(ac.Id, ac, "SelectedIndex", 2); } else if (cmd is RunJobCommand) { RunJobCommand rc = (RunJobCommand)cmd; AddCmdItem(rc.Id, rc, "JobName"); } else { FieldInfo[] list = cmd.GetType().GetFields(); AddGroup(string.Concat(p.Name, " - ", cmd.GetType().Name)); foreach (FieldInfo f in list) { ParameterAttribute a = null; object[] attr = f.GetCustomAttributes(typeof(ULib.Executing.ParameterAttribute), true); if (attr != null && attr.Length > 0) { a = attr[0] as ParameterAttribute; } if (!string.Equals(f.Name, "id", StringComparison.OrdinalIgnoreCase) && !string.Equals(f.Name, "iscondition", StringComparison.OrdinalIgnoreCase)) { if (a == null || !a.IsHidden) { SettingTag tag = AddCmdItem(f.Name, cmd, f.Name, f.FieldType.Name.IndexOf("bool", StringComparison.OrdinalIgnoreCase) >= 0 ? 1 : 0); tag.Cmd = cmd; tag.Id = f.Name; if (a != null) { tag.Attribute = a; } } } } if (ucmd != null) { ucmd.OnGenerateCompleted(this); } AddGroup(string.Empty); } } } } }
public void MatchesErrorKeyword() { Assert.IsTrue(IsMatch(ExecuteCommand.Check, new ExecuteError(), ExecuteParameters.Make(TestUtils.CreateCell("error")))); Assert.IsFalse(IsMatch(ExecuteCommand.Input, new ExecuteError(), ExecuteParameters.MakeMemberCell(TestUtils.CreateCell("stuff"), TestUtils.CreateCell("error")))); }
public ExecuteResult Execute(ExecuteParameters executeParameters) { return(LastExecResult = this.executor.Execute(executeParameters)); }
public void Check(object systemUnderTest, TypedValue actualValue, Tree <Cell> expectedCell) { processor.Execute( ExecuteContext.Make(ExecuteCommand.Check, systemUnderTest, actualValue), ExecuteParameters.Make(expectedCell)); }
public void Check(object systemUnderTest, Tree <Cell> memberName, Tree <Cell> parameters, Tree <Cell> expectedCell) { processor.Execute( ExecuteContext.Make(ExecuteCommand.Check, systemUnderTest), ExecuteParameters.Make(memberName, parameters, expectedCell)); }
public void Input(object systemUnderTest, Tree <Cell> memberName, Tree <Cell> cell) { processor.Execute( ExecuteContext.Make(ExecuteCommand.Input, systemUnderTest), ExecuteParameters.MakeMemberCell(memberName, cell)); }
public bool Compare(TypedValue actual, Tree <Cell> expectedCell) { return((bool)processor.Execute( ExecuteContext.Make(ExecuteCommand.Compare, actual), ExecuteParameters.Make(expectedCell)).Value); }
public TypedValue TryInvoke(object target, Tree <Cell> memberName, Tree <Cell> parameters, Tree <Cell> targetCell) { return(processor.Execute( ExecuteContext.Make(ExecuteCommand.Invoke, new TypedValue(target)), ExecuteParameters.Make(memberName, parameters, targetCell))); }