private bool HandleRunTests(RunTests runTests) { var testDll = Path.Combine(AgentHelpers.GetWorkingDirectory(), runTests.Dll); var testNames = string.Join(",", runTests.TestNames); Console.WriteLine($"Starting process for {testNames}"); Console.WriteLine($"{settingsHolder.AgentSettings.NunitConsoleExePath} {testDll} /run={testNames}"); //extract this blocking call from the message handler var process = new Process { StartInfo = new ProcessStartInfo { FileName = settingsHolder.AgentSettings.NunitConsoleExePath, Arguments = $"{testDll} /run={testNames}", UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; process.OutputDataReceived += (sender, args) => Console.WriteLine(args.Data); process.ErrorDataReceived += (sender, args) => Console.WriteLine(args.Data); process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); Console.WriteLine("Process finished " + process.ExitCode); return(true); }
private void Update(string branch) { Console.Out.WriteLine("Starting pull..."); Run($"pull", AgentHelpers.GetWorkingDirectory()); Console.Out.WriteLine("Starting update..."); Run($"update {branch}", AgentHelpers.GetWorkingDirectory()); Console.Out.WriteLine("Update finished..."); }
public void CloneOrUpdate(string server, string branch) { //naive if (Directory.Exists(AgentHelpers.GetWorkingDirectory())) { Update(branch); } else { Clone(server, branch); } }
public void Build() { var workingDirectory = AgentHelpers.GetWorkingDirectory(); var buildScriptPath = Path.Combine(workingDirectory, "buildTests.bat"); var arguments = $"/c {buildScriptPath}"; var processInfo = new ProcessStartInfo("cmd.exe", arguments) { WorkingDirectory = workingDirectory }; var process = Process.Start(processInfo); process.WaitForExit(); if (process.ExitCode != 0) { throw new Exception($"cmd exit code: [{process.ExitCode}], arguments: [{arguments}]"); } }
private bool HandleParseTestDll(ParseTestDll parseTestDll) { Console.WriteLine("Handling Parse message"); var testDll = Path.Combine(AgentHelpers.GetWorkingDirectory(), parseTestDll.Dll); AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomainReflectionOnlyAssemblyResolve; var testAassembly = Assembly.ReflectionOnlyLoadFrom(testDll); var methods = testAassembly.DefinedTypes .SelectMany(t => t.GetMethods()) .Where(m => m.GetCustomAttributesData() .Any(x => x.AttributeType.FullName == "NUnit.Framework.TestAttribute")) .Select(x => $"{x.ReflectedType.FullName}.{x.Name}") .ToArray(); Sender.Tell(new ParseTestDllResult { TestNames = methods }, Self); Assembly CurrentDomainReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args) { var directory = Path.GetDirectoryName(testDll); var dllpath = Path.Combine(directory, args.Name.Split(',').First() + ".dll"); try { return(Assembly.ReflectionOnlyLoadFrom(dllpath)); } catch (FileNotFoundException) { return(Assembly.ReflectionOnlyLoad(args.Name)); } } return(true); }