public void Should_return_max_argument_length() { var calculator = new MaxCmdLengthCalculator(); var length = calculator.GetLength(); Assert.IsTrue(length > 0); }
public TestRunResults[] RunTests(TestRunInfo[] runInfos, Action <AutoTest.TestRunners.Shared.Targeting.Platform, Action <ProcessStartInfo> > processWrapper, Func <bool> abortWhen) { var results = new List <TestRunResults>(); foreach (var runInfo in runInfos) { var timer = Stopwatch.StartNew(); var unitTestExe = _configuration.MSTestRunner(getFramework(runInfo)); if (!File.Exists(unitTestExe)) { var project = ""; if (runInfo.Project != null) { project = runInfo.Project.Key; } results.Add(new TestRunResults(project, runInfo.Assembly, false, TestRunner.MSTest, new TestResult[] { })); continue; } if (runInfo.OnlyRunSpcifiedTestsFor(TestRunner.MSTest) && runInfo.GetTestsFor(TestRunner.MSTest).Length.Equals(0)) { continue; } var calc = new MaxCmdLengthCalculator(); var tests = getTestsList(runInfo); var testRunConfig = getTestrunConfigArguments(); var arguments = "/testcontainer:\"" + runInfo.Assembly + "\" " + tests + " /detail:errorstacktrace /detail:errormessage" + testRunConfig; var runAllTests = (arguments.Length + unitTestExe.Length) > calc.GetLength(); if (runAllTests) { arguments = "/testcontainer:\"" + runInfo.Assembly + "\"" + " /detail:errorstacktrace /detail:errormessage" + testRunConfig; } DebugLog.Debug.WriteInfo("Running tests: {0} {1}", unitTestExe, arguments); var proc = new Process(); proc.StartInfo = new ProcessStartInfo(unitTestExe, arguments); proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(runInfo.Assembly); proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.StartInfo.UseShellExecute = false; proc.StartInfo.CreateNoWindow = true; proc.Start(); string line; var parser = new MSTestResponseParser(runInfo.Project.Key, runInfo.Assembly, !runAllTests); while ((line = proc.StandardOutput.ReadLine()) != null) { parser.ParseLine(line); } proc.WaitForExit(); timer.Stop(); parser.Result.SetTimeSpent(timer.Elapsed); results.Add(parser.Result); } return(results.ToArray()); }
public TestRunResults[] RunTests(TestRunInfo[] runInfos, Action<AutoTest.TestRunners.Shared.Targeting.Platform, Version, Action<ProcessStartInfo, bool>> processWrapper, Func<bool> abortWhen) { var results = new List<TestRunResults>(); foreach (var runInfo in runInfos) { var timer = Stopwatch.StartNew(); var unitTestExe = _configuration.MSTestRunner(getFramework(runInfo)); if (!File.Exists(unitTestExe)) { var project = ""; if (runInfo.Project != null) project = runInfo.Project.Key; results.Add(new TestRunResults(project, runInfo.Assembly, false, TestRunner.MSTest, new TestResult[] { })); continue; } if (runInfo.OnlyRunSpcifiedTestsFor(TestRunner.MSTest) && runInfo.GetTestsFor(TestRunner.MSTest).Length.Equals(0)) continue; var calc = new MaxCmdLengthCalculator(); var tests = getTestsList(runInfo); var testRunConfig = getTestrunConfigArguments(); var arguments = "/testcontainer:\"" + runInfo.Assembly + "\" " + tests + " /detail:errorstacktrace /detail:errormessage" + testRunConfig; var runAllTests = (arguments.Length + unitTestExe.Length) > calc.GetLength(); if (runAllTests) arguments = "/testcontainer:\"" + runInfo.Assembly + "\"" + " /detail:errorstacktrace /detail:errormessage" + testRunConfig; DebugLog.Debug.WriteInfo("Running tests: {0} {1}", unitTestExe, arguments); var proc = new Process(); proc.StartInfo = new ProcessStartInfo(unitTestExe, arguments); proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(runInfo.Assembly); proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.StartInfo.UseShellExecute = false; proc.StartInfo.CreateNoWindow = true; proc.Start(); string line; var parser = new MSTestResponseParser(runInfo.Project.Key, runInfo.Assembly, !runAllTests); while ((line = proc.StandardOutput.ReadLine()) != null) parser.ParseLine(line); proc.WaitForExit(); timer.Stop(); parser.Result.SetTimeSpent(timer.Elapsed); results.Add(parser.Result); } return results.ToArray(); }
string getExecutableArguments(RunnerExe exe, string assemblyName, string tests, TestRunInfo[] runInfos) { var calc = new MaxCmdLengthCalculator(); var separator = getArgumentSeparator(); string framework = ""; // only use framework for windows as the default runner on linux has no framework parameter if (!Environment.OSVersion.Platform.Equals(PlatformID.Unix) && !Environment.OSVersion.Platform.Equals(PlatformID.MacOSX)) { if (exe.Version.Length > 0) { framework = string.Format(" {0}framework:{1}", separator, exe.Version); } } var categoryList = getCategoryIgnoreList(); var arguments = string.Format("{0}noshadow{2} {0}xmlconsole {1}", separator, categoryList, framework) + assemblyName + " " + tests; if ((arguments.Length + exe.Exe.Length) > calc.GetLength()) { arguments = string.Format("{0}noshadow{2} {0}xmlconsole {1}", separator, categoryList, framework) + assemblyName; } return(arguments); }
string getExecutableArguments (RunnerExe exe, string assemblyName, string tests, TestRunInfo[] runInfos) { var calc = new MaxCmdLengthCalculator(); var separator = getArgumentSeparator(); string framework = ""; // only use framework for windows as the default runner on linux has no framework parameter if (!Environment.OSVersion.Platform.Equals(PlatformID.Unix) && !Environment.OSVersion.Platform.Equals(PlatformID.MacOSX)) { if (exe.Version.Length > 0) framework = string.Format(" {0}framework:{1}", separator, exe.Version); } var categoryList = getCategoryIgnoreList(); var arguments = string.Format("{0}noshadow{2} {0}xmlconsole {1}", separator, categoryList, framework) + assemblyName + " " + tests; if ((arguments.Length + exe.Exe.Length) > calc.GetLength()) arguments = string.Format("{0}noshadow{2} {0}xmlconsole {1}", separator, categoryList, framework) + assemblyName; return arguments; }