private Deployment(InlineDeploymentSettings settings) { if (settings is null) throw new ArgumentNullException(nameof(settings)); _projectName = settings.Project; _stackName = settings.Stack; _isDryRun = settings.IsDryRun; SetAllConfig(settings.Config, settings.ConfigSecretKeys); if (string.IsNullOrEmpty(settings.MonitorAddr) || string.IsNullOrEmpty(settings.EngineAddr) || string.IsNullOrEmpty(_projectName) || string.IsNullOrEmpty(_stackName)) { throw new InvalidOperationException("Inline execution was not provided the necessary parameters to run the Pulumi engine."); } var deploymentLogger = settings.Logger ?? CreateDefaultLogger(); deploymentLogger.LogDebug("Creating deployment engine"); Engine = new GrpcEngine(settings.EngineAddr); deploymentLogger.LogDebug("Created deployment engine"); deploymentLogger.LogDebug("Creating deployment monitor"); Monitor = new GrpcMonitor(settings.MonitorAddr); deploymentLogger.LogDebug("Created deployment monitor"); // Tell the runner that we are running inside an inline automation program // in which case it shall not set/pollute the global process exit code // when encountering unhandles exceptions var runnerOptions = new RunnerOptions { IsInlineAutomationProgram = true }; _runner = new Runner(this, deploymentLogger, runnerOptions); _logger = new EngineLogger(this, deploymentLogger, Engine); }
public void DoesItsThing() { featureFileFinder.Stub(f => f.Find("weird pattern")).Return(new[] { "file1", "file2", "file3" }); var feature1 = Stub("file1", "bla1", "feature1", new[] { "bom" }); var feature2 = Stub("file2", "bla2", "feature2", new[] { "bom" }); var feature3 = Stub("file3", "bla3", "feature3", new[] { "bim" }); var actionStepsTypes = new Type[0]; actionStepsFinder.Stub(a => a.FindTypesWithActionSteps("some path")).Return(actionStepsTypes); sut.Execute(new CommandLineArguments { AssemblyPath = "some path", FeaturePattern = "weird pattern", TagsToExclude = new[] { "bim" }, TagsToInclude = new[] { "bom" }, }); var expectedOptions = new RunnerOptions { Filter = new TagFilter(new[] { "bom" }, new[] { "bim" }), DruRun = false, }; featureRunner.AssertWasCalled(r => r.Run(feature1, actionStepsTypes, expectedOptions)); featureRunner.AssertWasCalled(r => r.Run(feature2, actionStepsTypes, expectedOptions)); featureRunner.AssertWasNotCalled(r => r.Run(feature3, actionStepsTypes, expectedOptions)); }
public IEnumerable<string> Directories(RunnerOptions options) { return Directory .GetDirectories(options.WorkingDirectory, "_*") .Where(x => !Path.GetFileName(x).Equals("_templates")) .ToList(); }
private RunnerOptions getRunnerOptions(IEnumerable <TestRunInfo> unitInfos, IAutoTestNetTestRunner instance) { DebugLog.Debug.WriteDetail("Getting runner options for {0}", instance.Identifier); var runner = new RunnerOptions(instance.Identifier); var testRunner = TestRunnerConverter.FromString(instance.Identifier); foreach (var info in unitInfos) { DebugLog.Debug.WriteDetail("Handling {0}", info.Assembly); DebugLog.Debug.WriteDetail("About to add assembly"); var assembly = new AssemblyOptions(info.Assembly); assembly.AddTests(info.GetTestsFor(testRunner)); assembly.AddTests(info.GetTestsFor(TestRunner.Any)); DebugLog.Debug.WriteDetail("Found {0} tests for assembly", assembly.Tests.Count()); assembly.AddMembers(info.GetMembersFor(testRunner)); assembly.AddMembers(info.GetMembersFor(TestRunner.Any)); DebugLog.Debug.WriteDetail("Found {0} members for assembly", assembly.Members.Count()); assembly.AddNamespaces(info.GetNamespacesFor(testRunner)); assembly.AddNamespaces(info.GetNamespacesFor(TestRunner.Any)); DebugLog.Debug.WriteDetail("Found {0} namespaces for assembly", assembly.Namespaces.Count()); DebugLog.Debug.WriteDetail("Run only specified tests for runner {0} is {1}", testRunner, info.OnlyRunSpcifiedTestsFor(testRunner)); if (info.OnlyRunSpcifiedTestsFor(testRunner) && assembly.Tests.Count() == 0 && assembly.Members.Count() == 0 && assembly.Namespaces.Count() == 0) { continue; } DebugLog.Debug.WriteDetail("Adding assembly"); runner.AddAssembly(assembly); } return(runner); }
private static RunnerOptions getTestRunsFor(IAutoTestNetTestRunner instance, RunnerOptions run) { if (run.ID.ToLower() != "any") { return(run); } var newRun = new RunnerOptions(run.ID); newRun.AddCategories(run.Categories.ToArray()); foreach (var asm in run.Assemblies) { if (!asm.IsVerified && !instance.ContainsTestsFor(asm.Assembly)) { continue; } var assembly = new AssemblyOptions(asm.Assembly); assembly.AddNamespaces(asm.Namespaces.Where(x => asm.IsVerified || instance.ContainsTestsFor(asm.Assembly, x)).ToArray()); assembly.AddMembers(asm.Members.Where(x => asm.IsVerified || instance.ContainsTestsFor(asm.Assembly, x)).ToArray()); assembly.AddTests(asm.Tests.Where(x => asm.IsVerified || instance.IsTest(asm.Assembly, x)).ToArray()); if (hasNoTests(asm) || hasTests(assembly)) { newRun.AddAssembly(assembly); } } if (newRun.Assemblies.Count() == 0) { return(null); } return(newRun); }
public void Should_produce_xml() { var plugins = new List <Plugin>(); var options = new RunOptions(); plugins.Add(new Plugin(@"C:\Some\Path\Assembly.dll", "This.Is.Full.Type.Name.For.Class.Implementing.IAutoTestNetTestRunner")); plugins.Add(new Plugin(@"C:\Some\Path\Assembly.dll", "Some.Class.Name")); var runner1 = new RunnerOptions("nunit"); runner1.AddCategories(new string[] { "SomeTestCategory", "SomeOtherTestCategory" }); var assembly1 = new AssemblyOptions(@"C:\my\testassembly.dll"); assembly1.AddTests(new string[] { "testassembly.class.test1", "testassembly.class.test2" }); assembly1.AddMembers(new string[] { "testassembly.class2", "testassembly.class3" }); assembly1.AddNamespaces(new string[] { "testassembly.somenamespace1", "testassembly.somenamespace2" }); runner1.AddAssemblies(new AssemblyOptions[] { assembly1, new AssemblyOptions(@"C:\my\anothernunitassembly.dll") }); options.AddTestRun(runner1); var runner2 = new RunnerOptions("another"); runner2.AddAssembly(new AssemblyOptions(@"C:\my\other\testassembly.dll")); options.AddTestRun(runner2); var writer = new OptionsXmlWriter(plugins, options); var file = Path.GetTempFileName(); writer.Write(file); var path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var original = File.ReadAllText(file).Replace("\r\n", "\n"); var generated = File.ReadAllText(Path.Combine(path, "TestOptions.xml")).Replace("\r\n", "\n"); Assert.That(original, Is.EqualTo(generated)); }
public static void Execute(RunnerOptions options) { var newArgs = new List <string>(); newArgs.Add(options.Target); Bullseye.Targets.RunTargetsAndExit(newArgs.ToArray()); }
public void Execute(CommandLineArguments arguments) { var assemblyPath = arguments.AssemblyPath; var featurePattern = arguments.FeaturePattern; featureRunner.AddListener(new ConsoleWritingEventListener { ShowCurrentTimes = arguments.ShowCurrentTime, }); var filter = new TagFilter(arguments.TagsToInclude, arguments.TagsToExclude); var featuresToRun = featureFileFinder.Find(featurePattern) .SelectMany(fileName => gherkinParser.Parse(fileName, fileReader.Read(fileName, Encoding.UTF8)).Features) .Where(f => filter.IsSatisfiedBy(f.Tags)); Console.WriteLine("Found {0} features containing {1} executable scenarios", featuresToRun.Count(), featuresToRun.Sum(f => f.Scenarios.Count)); var actionStepsTypes = actionStepsFinder.FindTypesWithActionSteps(assemblyPath); var options = new RunnerOptions { Filter = filter, DruRun = arguments.DruRun, SuccessRequired = arguments.SuccessRequired, }; foreach(var feature in featuresToRun) { var featureResult = featureRunner.Run(feature, actionStepsTypes, options); if (options.SuccessRequired && !featureResult.Success) break; } }
public dynamic LoadFile(RunnerOptions runnerOptions, string fileName) { try { _logger.Info(string.Format("Loading file {0}...", Path.GetFileName(fileName))); var fileContents = File.ReadAllLines(fileName); _logger.Debug(string.Format("Found {0} lines in file.", fileContents.Length)); dynamic file = new ExpandoObject(); var f = file as IDictionary<string, object>; if(f == null) { _logger.Warn("Something's very wrong, ExpandoObject could not be cast to a Dictionary."); return null; } f["FileName"] = Path.GetFileName(fileName); var loadingContent = false; var contentBuilder = new StringBuilder(); foreach(var line in fileContents) { if (string.IsNullOrWhiteSpace(line)) { _logger.Debug("Found break between properties and content."); loadingContent = true; continue; } if(!loadingContent) { var key = _propertySplitter.GetKey(line); var value = _propertySplitter.GetValue(line); _logger.Debug(string.Format("Adding property {0} with value {1}", key, value)); f[key] = value; } else { contentBuilder.AppendLine(line); } } var content = contentBuilder.ToString(); if(!string.IsNullOrWhiteSpace(content)) { f["content"] = content; } return file; } catch (Exception ex) { _logger.Error(string.Format("{0} while loading file {1}.", ex.GetType().Name, fileName)); } return null; }
public void Should_group_by_assembly() { var locator = MockRepository.GenerateMock <IAssemblyReader>(); locator.Stub(x => x.GetTargetFramework("Assembly1")).Return(new Version(2, 0)); locator.Stub(x => x.GetTargetFramework("Assembly2")).Return(new Version(4, 0)); locator.Stub(x => x.GetTargetFramework("Assembly3")).Return(new Version(2, 0)); locator.Stub(x => x.GetTargetFramework("Assembly4")).Return(new Version(2, 0)); locator.Stub(x => x.GetTargetFramework("Assembly5")).Return(new Version(2, 0)); locator.Stub(x => x.GetTargetFramework("Assembly6")).Return(new Version(4, 0)); locator.Stub(x => x.GetPlatform("Assembly1")).Return(Platform.AnyCPU); locator.Stub(x => x.GetPlatform("Assembly2")).Return(Platform.AnyCPU); locator.Stub(x => x.GetPlatform("Assembly3")).Return(Platform.AnyCPU); locator.Stub(x => x.GetPlatform("Assembly4")).Return(Platform.AnyCPU); locator.Stub(x => x.GetPlatform("Assembly5")).Return(Platform.x86); locator.Stub(x => x.GetPlatform("Assembly6")).Return(Platform.x86); var options = new RunOptions(); var runner = new RunnerOptions("NUnit"); runner.AddAssemblies(new AssemblyOptions[] { new AssemblyOptions("Assembly1"), new AssemblyOptions("Assembly2") }); options.AddTestRun(runner); runner = new RunnerOptions("NUnit"); runner.AddAssemblies(new AssemblyOptions[] { new AssemblyOptions("Assembly3"), new AssemblyOptions("Assembly5") }); options.AddTestRun(runner); runner = new RunnerOptions("XUnit"); runner.AddAssemblies(new AssemblyOptions[] { new AssemblyOptions("Assembly4"), new AssemblyOptions("Assembly6") }); options.AddTestRun(runner); var assembler = new TargetedRunAssembler(options, locator); var targeted = assembler.Assemble(); Assert.That(targeted.Count(), Is.EqualTo(4)); Assert.That(targeted.ElementAt(0).Platform, Is.EqualTo(Platform.AnyCPU)); Assert.That(targeted.ElementAt(0).TargetFramework, Is.EqualTo(new Version(2, 0))); Assert.That(targeted.ElementAt(0).Runners.Count(), Is.EqualTo(2)); Assert.That(targeted.ElementAt(0).Runners.Count(), Is.EqualTo(2)); Assert.That(targeted.ElementAt(0).Runners.ElementAt(0).ID, Is.EqualTo("NUnit")); Assert.That(targeted.ElementAt(0).Runners.ElementAt(0).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly1")); Assert.That(targeted.ElementAt(0).Runners.ElementAt(0).Assemblies.ElementAt(1).Assembly, Is.EqualTo("Assembly3")); Assert.That(targeted.ElementAt(0).Runners.ElementAt(1).ID, Is.EqualTo("XUnit")); Assert.That(targeted.ElementAt(0).Runners.ElementAt(1).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly4")); Assert.That(targeted.ElementAt(1).Platform, Is.EqualTo(Platform.AnyCPU)); Assert.That(targeted.ElementAt(1).TargetFramework, Is.EqualTo(new Version(4, 0))); Assert.That(targeted.ElementAt(1).Runners.ElementAt(0).ID, Is.EqualTo("NUnit")); Assert.That(targeted.ElementAt(1).Runners.ElementAt(0).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly2")); Assert.That(targeted.ElementAt(2).Platform, Is.EqualTo(Platform.x86)); Assert.That(targeted.ElementAt(2).TargetFramework, Is.EqualTo(new Version(2, 0))); Assert.That(targeted.ElementAt(2).Runners.ElementAt(0).ID, Is.EqualTo("NUnit")); Assert.That(targeted.ElementAt(2).Runners.ElementAt(0).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly5")); Assert.That(targeted.ElementAt(3).Platform, Is.EqualTo(Platform.x86)); Assert.That(targeted.ElementAt(3).TargetFramework, Is.EqualTo(new Version(4, 0))); Assert.That(targeted.ElementAt(3).Runners.ElementAt(0).ID, Is.EqualTo("XUnit")); Assert.That(targeted.ElementAt(3).Runners.ElementAt(0).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly6")); }
public AbstractRunner(RunnerOptions options, string program) { this.Program = Parser.Parse(program); this.CurrentProgramPosition = 0; this.CurrentTapePosition = 0; this.Tape = new byte[Shared.Constants.TapeLength]; this.InputOutputSystem = options.InputOutputSystem; this.Wrap = options.Wrap; }
public string ReadShell(string command, RunnerOptions runnerOptions = null) { if (runnerOptions == null) { runnerOptions = new RunnerOptions(); } var workingDirectory = runnerOptions.WorkingDirectory; if (string.IsNullOrEmpty(workingDirectory)) { workingDirectory = Directory.GetCurrentDirectory(); } var escapedArgs = command.Replace("\"", "\\\""); var processStartInfo = new System.Diagnostics.ProcessStartInfo { FileName = "/usr/bin/env", Arguments = $"{(runnerOptions.UseSudo ? "sudo " : "")}bash -c \"{escapedArgs}\"", UseShellExecute = false, RedirectStandardError = false, RedirectStandardOutput = true, WorkingDirectory = workingDirectory }; if (runnerOptions.Env != null) { foreach (var envValue in runnerOptions.Env) { processStartInfo.Environment.Add(envValue.Key, envValue.Value); } } var process = System.Diagnostics.Process.Start(processStartInfo); if (process == null) { throw new Exception("Couldn't create process."); } var output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); if (process.ExitCode != 0) { _logger.LogError("Error executing command: {command}", command); _logger.LogError("Command output: {output}", output); throw new Exception($"Exit code: {process.ExitCode}"); } return(output); }
private static RunOptions getRunOptions() { var assembly = new AssemblyOptions(@"P:\projects\mooseprofiler.git\MMProfiler\main\x86\Debug\Test.Target.dll"); var run = new RunnerOptions("NUnit"); run.AddAssembly(assembly); var optoins = new RunOptions(); optoins.AddTestRun(run); return(optoins); }
public bool Equals(RunnerOptions other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other.Filter, Filter) && other.DruRun.Equals(DruRun)); }
private static void Run(Options options) { var runnerOptions = new RunnerOptions(options.FolderPath); var runnerResult = new DuplocatorRunner().GetDuplicates(runnerOptions); Console.WriteLine($"Found {runnerResult.TotalDuplicates} duplicates in {runnerResult.DuplicateGroups.Count()} groups. Elapsed time: {runnerResult.ElapsedTime.TotalSeconds:F1}s"); if (!string.IsNullOrWhiteSpace(options.ExportFileName)) { var csvContent = string.Join(Environment.NewLine, runnerResult.DuplicateGroups.Select(group => string.Join(",", group.Duplicates.OrderBy(_ => _)))); File.WriteAllText(options.ExportFileName, csvContent); } }
public IList<dynamic> LoadModel(RunnerOptions runnerOptions, string directory) { var model = new List<dynamic>(); var files = Directory.GetFiles(directory, "*.markdown", SearchOption.AllDirectories); _logger.Info(string.Format("Found {0} files to load...", files.Length)); foreach(var file in files) { var fileModel = _fileLoader.LoadFile(runnerOptions, file); model.Add(fileModel); } return model; }
public static TestRunExtractor Create(RunnerOptions options) { if (options.Environments.Any(env => env.Namespaces != null)) { return(new EnvironmentNamespacesExtractor(options)); } if (options.Namespaces != null || options.Categories != null) { return(new FilteredSplitExtractor(options)); } return(new EvenSplitExtractor(options)); }
public void Run_Program(string programName, string expectedOutput, bool enableWrapping) { string helloWorld = Tests.Utils.LoadBrainFuckProgram(programName); MockInputOutput fakeIo = new MockInputOutput(); RunnerOptions options = new RunnerOptions { InputOutputSystem = fakeIo, Wrap = enableWrapping, }; AbstractRunner runner = new Interpreter(options, helloWorld); runner.Run(); Assert.Equal(expectedOutput, fakeIo.Output); }
private static void RunOptionsAndReturnExitCode(RunnerOptions opts) { switch (opts.Game) { case "TickTackToe": break; case "Lunar": break; } //throw new NotImplementedException(); Console.WriteLine("Press enter to close!"); Console.ReadLine(); }
public static RunnerOptions ParseOptions(string[] args) { RunnerOptions options = new RunnerOptions(); var optionSet = new OptionSet { { "i|iterations=", "number of iterations over test suite to make", (int n) => options.Iterations = n }, { "d|duration=", "duration of test suite execution (full load)", (int d) => options.Hold = d }, { "c|concurrency=", "number of concurrent users", (int c) => options.Concurrency = c }, { "l|ramp_up=", "time to ramp all concurrent users", (int l) => options.RampUp = l }, { "r|report-file=", "Name of report file", r => options.ReportFile = r }, { "t|target=", "Test suite", t => options.TargetAssembly = t }, { "h|help", "show this message and exit", h => options.ShouldShowHelp = h != null }, }; optionSet.Parse(args); if (options.ShouldShowHelp) { ShowHelp(); } if (options.TargetAssembly == null) { throw new Exception("Target test suite wasn't provided. Is your file actually NUnit test DLL?"); } if (options.Concurrency <= 0) { options.Concurrency = 1; } options.DurationLimit = options.Hold + options.RampUp; if (options.DurationLimit == 0 && options.Iterations == 0) { options.Iterations = 1; } Console.WriteLine("Concurrent users: {0}", options.Concurrency); Console.WriteLine("Iterations: {0}", options.Iterations); Console.WriteLine("Ramp period: {0}", options.RampUp); Console.WriteLine("Hold for: {0}", options.Hold); Console.WriteLine("Report file: {0}", options.ReportFile); Console.WriteLine("Target: {0}", options.TargetAssembly); return(options); }
private static async Task MainAsync(string[] args) { var options = new RunnerOptions(); try { options = OptionsParser.ParseOptions(args); } catch (OptionException e) { Console.WriteLine(e.Message); Console.WriteLine("Try running with '--help' for more information."); Environment.Exit(1); } var engine = TestEngineActivator.CreateInstance(true); var package = new TestPackage(options.TargetAssembly); var reportItems = new ConcurrentQueue <ReportItem>(); var testEventListener = new TestEventListener(engine, package, reportItems, string.Empty); var testCount = testEventListener.Runner.CountTestCases(TestFilter.Empty); if (testCount == 0) { throw new ArgumentException("Nothing to run, no tests were loaded"); } var userStepTime = options.RampUp / options.Concurrency; var reportWriter = new ReportWriter(reportItems); var reportWriterTask = Task.Run(() => reportWriter.StartWriting(options.ReportFile)); var startTime = DateTime.UtcNow; var testTasks = new Task[options.Concurrency]; for (int i = 0; i < options.Concurrency; i++) { var threadName = "worker_" + (i + 1); testTasks[i] = Task.Run(() => Test.RunTest( startTime, options, new TestEventListener(engine, package, reportItems, threadName))); Thread.Sleep(userStepTime * 1000); } await Task.WhenAll(testTasks); reportWriter.TestsCompleted = true; await reportWriterTask; }
public static void Main(string[] args) { RunnerOptions opts = null; try { opts = ParseOptions(args); } catch (OptionException e) { Console.WriteLine(e.Message); Console.WriteLine("Try running with '--help' for more information."); Environment.Exit(1); } RecordingListener listener = new RecordingListener(opts.reportFile); ITestEngine engine = TestEngineActivator.CreateInstance(); TestPackage package = new TestPackage(opts.targetAssembly); ITestRunner runner = engine.GetRunner(package); int testCount = runner.CountTestCases(TestFilter.Empty); if (testCount < 1) { throw new ArgumentException("Nothing to run, no tests were loaded"); } try { DateTime startTime = DateTime.Now; for (int i = 0; i < opts.iterations; i++) { runner.Run(listener, TestFilter.Empty); TimeSpan offset = DateTime.Now - startTime; if (opts.durationLimit > 0 && offset.TotalSeconds > opts.durationLimit) { break; } } } finally { listener.CloseFile(); } Environment.Exit(0); }
/// <summary> /// Get the duplicates using file size and hash checks. /// </summary> public RunnerResult GetDuplicates(RunnerOptions options) { var stopWatch = Stopwatch.StartNew(); var duplocatorFuncs = GetDuplocatorFuncs().ToArray(); var initialGroup = GetInitialDuplicateGroup(options.FolderPath); var duplicateGroups = new [] { initialGroup }; foreach (var duplocatorFunc in duplocatorFuncs) { duplicateGroups = duplicateGroups .AsParallel() .SelectMany(duplicateGroup => duplocatorFunc(duplicateGroup)) .ToArray(); } return(new RunnerResult(duplicateGroups, stopWatch.Elapsed)); }
public void Render(dynamic model, RunnerOptions runnerOptions) { _logger.Debug(string.Format("Rendering {0}", model.FileName)); var viewEngine = new SparkViewEngine { DefaultPageBaseType = typeof (SparkView).FullName, ViewFolder = new FileSystemViewFolder(Path.Combine(runnerOptions.WorkingDirectory, "_templates")) }; var view = (SparkView) viewEngine.CreateInstance(new SparkViewDescriptor().AddTemplate("post.spark")); view.Model = model; using(var writer = new StreamWriter(Console.OpenStandardOutput(), Encoding.UTF8)) { view.RenderView(writer); } }
/// <summary> /// Yet Another Brainfuck Thing. /// </summary> /// <param name="file">Brainfuck program file to load.</param> /// <param name="argument">Brainfuck program as a string.</param> /// <param name="wrap">Enable wrapping of bytes in cell.</param> public static int Main(FileInfo file = null, string argument = null, bool wrap = false) { string brainfuckProgram; if (file != null) { try { brainfuckProgram = File.ReadAllText(Path.GetFullPath(file.FullName)); } catch { Console.Error.WriteLine("File loading error"); return(1); } } else { brainfuckProgram = argument; } // Check program before running it bool isValid = Parser.IsValid(brainfuckProgram); if (!isValid) { Console.Error.WriteLine("Invalid program input"); return(1); } // Parse runner options RunnerOptions runnerOptions = new RunnerOptions { Wrap = wrap, InputOutputSystem = new ConsoleInputOutput(), }; var interpreter = new Runner.Interpreter(runnerOptions, brainfuckProgram); interpreter.Run(); return(0); }
public static RunnerOptions ParseOptions(string[] args) { RunnerOptions opts = new RunnerOptions(); var optionSet = new OptionSet { { "i|iterations=", "number of iterations over test suite to make.", (int n) => opts.iterations = n }, { "d|duration=", "duration of test suite execution.", (int d) => opts.durationLimit = d }, { "r|report-file=", "Name of report file", r => opts.reportFile = r }, { "t|target=", "Test suite", t => opts.targetAssembly = t }, { "h|help", "show this message and exit", h => opts.shouldShowHelp = h != null }, }; optionSet.Parse(args); if (opts.shouldShowHelp) { ShowHelp(); } if (opts.targetAssembly == null) { throw new Exception("Target test suite wasn't provided. Is your file actually NUnit test DLL?"); } if (opts.iterations == 0) { if (opts.durationLimit > 0) { opts.iterations = int.MaxValue; } else { opts.iterations = 1; } } Console.WriteLine("Iterations: {0}", opts.iterations); Console.WriteLine("Hold for: {0}", opts.durationLimit); Console.WriteLine("Report file: {0}", opts.reportFile); Console.WriteLine("Target: {0}", opts.targetAssembly); return(opts); }
public void TestRunnerOptions() { RunnerOptions runnerOptions = new RunnerOptions().TestConcurrency(5); VisualGridRunner runner1 = new VisualGridRunner(); Assert.AreEqual(VisualGridRunner.CONCURRENCY_FACTOR, ((IRunnerOptionsInternal)runner1.runnerOptions_).GetConcurrency()); runner1.GetAllTestResults(); VisualGridRunner runner2 = new VisualGridRunner(runnerOptions); Assert.AreEqual(5, ((IRunnerOptionsInternal)runner2.runnerOptions_).GetConcurrency()); runner2.GetAllTestResults(); VisualGridRunner runner3 = new VisualGridRunner(5); Assert.AreEqual(VisualGridRunner.CONCURRENCY_FACTOR * 5, ((IRunnerOptionsInternal)runner3.runnerOptions_).GetConcurrency()); runner3.GetAllTestResults(); }
public void StopsExecutingIfErrorIsEncountered() { featureFileFinder.Stub(f => f.Find(Arg <string> .Is.Anything)).Return(new[] { "file1", "file2" }); actionStepsFinder.Stub(a => a.FindTypesWithActionSteps(Arg <string> .Is.Anything)).Return(new Type[0]); var feature1 = Stub("file1", "bla1", "feature1", new[] { "bom" }); var feature2 = Stub("file2", "bla2", "feature2", new[] { "bom" }); var expectedOptions = new RunnerOptions { Filter = TagFilter.Empty(), DruRun = false, SuccessRequired = true, }; featureRunner.Stub(r => r.Run(feature1, new Type[0], expectedOptions)) .Return(new FeatureResult(feature1) { ScenarioResults = { new ScenarioResult("has an error") { StepResults = { new StepResult("is an error") { Result = Result.Failed } } } } }); sut.Execute(new CommandLineArguments { AssemblyPath = "some path", FeaturePattern = "weird pattern", TagsToExclude = new string[0], TagsToInclude = new string[0], SuccessRequired = true, }); featureRunner.AssertWasCalled(r => r.Run(feature1, new Type[0], expectedOptions)); featureRunner.AssertWasNotCalled(r => r.Run(feature2, new Type[0], expectedOptions)); }
public dynamic LoadModelCollection(RunnerOptions runnerOptions) { var modelCollection = new ExpandoObject(); var m = modelCollection as IDictionary<string, object>; _logger.Info("Loading directories..."); var directories = _directoryLocator.Directories(runnerOptions); _logger.Info(string.Format("Loaded {0} directories.", directories.Count())); foreach(var directory in directories) { var modelName = Path.GetFileName(directory).TrimStart('_'); _logger.Info(string.Format("Loading {0}...", modelName)); if(string.IsNullOrEmpty(modelName)) { _logger.Warn("ModelName cannot be null or empty. Skipping..."); continue; } var model = _modelLoader.LoadModel(runnerOptions, directory); m[modelName] = model; } return modelCollection; }
/// <summary> /// Initializes a new instance of the <see cref="MigrationRunner"/> class. /// </summary> /// <param name="options">The migration runner options</param> /// <param name="processorOptions">The migration processor options</param> /// <param name="profileLoader">The profile loader</param> /// <param name="processorAccessor">The migration processor accessor</param> /// <param name="maintenanceLoader">The maintenance loader</param> /// <param name="migrationLoader">The migration loader</param> /// <param name="logger">The logger</param> /// <param name="stopWatch">The stopwatch</param> /// <param name="migrationRunnerConventionsAccessor">The accessor for migration runner conventions</param> /// <param name="assemblySource">The assemblies to scan for migrations, etc...</param> /// <param name="migrationValidator">The validator for migrations</param> /// <param name="serviceProvider">The service provider</param> /// <param name="migrationScopeHandler">THe migration scope handler</param> public MigrationRunner( [NotNull] IOptions <RunnerOptions> options, [NotNull] IOptionsSnapshot <ProcessorOptions> processorOptions, [NotNull] IProfileLoader profileLoader, [NotNull] IProcessorAccessor processorAccessor, [NotNull] IMaintenanceLoader maintenanceLoader, [NotNull] IMigrationInformationLoader migrationLoader, [NotNull] ILogger <MigrationRunner> logger, [NotNull] IStopWatch stopWatch, [NotNull] IMigrationRunnerConventionsAccessor migrationRunnerConventionsAccessor, [NotNull] IAssemblySource assemblySource, [NotNull] MigrationValidator migrationValidator, [NotNull] IServiceProvider serviceProvider, [CanBeNull] IMigrationScopeManager migrationScopeHandler) { Processor = processorAccessor.Processor; Conventions = migrationRunnerConventionsAccessor.MigrationRunnerConventions; ProfileLoader = profileLoader; MaintenanceLoader = maintenanceLoader; MigrationLoader = migrationLoader; _serviceProvider = serviceProvider; _options = options.Value; _logger = logger; _stopWatch = stopWatch; _processorOptions = processorOptions.Value; _migrationScopeManager = migrationScopeHandler ?? new MigrationScopeHandler(Processor, processorOptions.Value); _migrationValidator = migrationValidator; _versionLoader = new Lazy <IVersionLoader>(serviceProvider.GetRequiredService <IVersionLoader>); #pragma warning disable 612 #pragma warning disable 618 _migrationAssemblies = new AssemblyCollectionService(assemblySource); #pragma warning restore 618 #pragma warning restore 612 }
public FilteredSplitExtractor(RunnerOptions options) : base(options) { }
public EvenSplitExtractor(RunnerOptions options) : base(options) { }
RunnerOptions(RunnerOptions other) { concurrency_ = other.concurrency_; }
public ProbeConfiguration(ProbeOptions probeOptions, RunnerOptions runnerOptions, MqttOptions mqttOptions) { ProbeOptions = probeOptions ?? throw new ArgumentNullException(nameof(probeOptions)); RunnerOptions = runnerOptions ?? throw new ArgumentNullException(nameof(runnerOptions)); MqttOptions = mqttOptions ?? throw new ArgumentNullException(nameof(mqttOptions)); }
protected TestRunExtractor(RunnerOptions options) { Options = options; Environments = options.Environments; Environments.ForEach(env => env.Initialize(options.AssemblyPath, options.ConfigFilepath)); }
public void Debug(CacheTestMessage test) { try { AutoTest.Core.DebugLog.Debug.WriteDebug("Starting debug session"); var found = false; var targetFramework = ""; found = setBreakpointFromMethod(test, ref targetFramework); if (!found) { found = setBreakpointFromStacktrace(test, ref targetFramework); } if (!found) { return; } var process = new AutoTestRunnerDebugProcess(); var assembly = test.Assembly; AutoTest.Core.DebugLog.Debug.WriteDebug("Starting process suspended"); var command = ""; var options = new RunOptions(); var runner = new RunnerOptions(getTestRunner(TestRunnerConverter.ToString(test.Test.Runner), test.Assembly, test.Test.Name)); var asm = new AssemblyOptions(test.Assembly); asm.AddTest(test.Test.Name); runner.AddAssembly(asm); options.AddTestRun(runner); AutoTest.Core.DebugLog.Debug.WriteDebug(string.Format("Starting {0}", command)); var processID = process.StartPaused(options, test.Test.Runner); try { AutoTest.Core.DebugLog.Debug.WriteDebug("Locating debugger for Visual Studio " + _application.Version); var dbg2 = (EnvDTE80.Debugger2)_application.Debugger; var trans = (EnvDTE80.Transport)dbg2.Transports.Item("Default"); EnvDTE80.Engine[] dbgeng; if (_application.Version == "9.0") { dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item("Managed") }; } else { if (process.Framework >= new Version(4, 0)) { dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item(string.Format("Managed (v{0}.{1})", process.Framework.Major, process.Framework.Minor)) } } ; else { dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item("Managed (v2.0, v1.1, v1.0)") } }; } EnvDTE80.Process2 proc2 = null; foreach (EnvDTE80.Process2 proc in dbg2.GetProcesses(trans, null)) { if (proc.ProcessID == processID) { proc2 = proc; break; } } if (proc2 != null) { proc2.Attach2(dbgeng); } } catch (Exception ex) { AutoTest.Core.DebugLog.Debug.WriteException(ex); throw; } finally { AutoTest.Core.DebugLog.Debug.WriteDebug("Resuming process"); process.Resume(); } } catch (Exception ex) { AutoTest.Core.DebugLog.Debug.WriteException(ex); } }