public static XDocument ReadTestContainerInSeperateProcess(string assemblyLocation) { string assyXml; string errMsg; assemblyLocation = Path.GetFullPath(assemblyLocation); string assyFolderPath = Path.GetDirectoryName(assemblyLocation); if (!Directory.Exists(assyFolderPath)) { assyXml = TestAssemblyReader.CreateXTestAssemblyPlaceholder(assemblyLocation).ToString(); errMsg = null; } else { using (Process p = new Process()) { p.StartInfo = new ProcessStartInfo(MCutToolsUtil.MCutExecutableFilePath) { WorkingDirectory = assyFolderPath, Arguments = String.Format("getTestListFromAssembly \"{0}\"", Path.GetFileName(assemblyLocation)), CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, }; p.Start(); assyXml = p.StandardOutput.ReadToEnd(); errMsg = p.StandardError.ReadToEnd(); p.WaitForExit(); } } if (String.IsNullOrWhiteSpace(errMsg)) { return(XDocument.Parse(assyXml, LoadOptions.SetLineInfo)); } else { return(new XDocument(XNames.CreateXError(errMsg))); } }
private static int WriteTestAssemblyXml(string assemblyFilePath) { XElement xtestAssy = null; try { var assyReader = new TestAssemblyReader(assemblyFilePath); xtestAssy = assyReader.Read(); } catch (Exception ex) { xtestAssy = XNames.CreateXError(ex); } using (XmlWriter w = XmlWriter.Create(Console.Out)) { if (xtestAssy != null) { xtestAssy.WriteTo(w); } } return(0); }