private static PerDocumentLocationXTestCases GetTestToDebug(string discoveredUnitTestsStore, string discoveredUnitDTestsStore) { var discoveredUnitTests = PerDocumentLocationXTestCases.Deserialize(FilePath.NewFilePath(discoveredUnitTestsStore)); var discoveredUnitDTests = PerDocumentLocationDTestCases.Deserialize(FilePath.NewFilePath(discoveredUnitDTestsStore)); var dtc = discoveredUnitDTests.Values.First().First(); var dl = new DocumentLocation(dtc.CodeFilePath, dtc.LineNumber); var testToDebug = new PerDocumentLocationXTestCases(); testToDebug.TryAdd(dl, discoveredUnitTests[dl]); return(testToDebug); }
private static int MainImpl(string[] args) { if (File.Exists(@"c:\debug.testhost.txt")) { while (true) { System.Threading.Thread.Sleep(2000); } } LogInfo("TestHost: Entering Main."); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomainUnhandledException); var command = args[0]; var buildRoot = args[1]; var codeCoverageStore = args[2]; var testResultsStore = args[3]; var discoveredUnitTestsStore = args[4]; var testFailureInfoStore = args[5]; var timeFilter = args[6]; var slnPath = args[7]; var slnSnapPath = args[8]; var discoveredUnitDTestsStore = args[9]; var ignoredTests = (args[10] ?? "").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var searchPath = FilePath.NewFilePath(Path.Combine(Path.GetDirectoryName(slnSnapPath), "packages")); if (command == "discover") { var tds = AdapterLoader.LoadDiscoverers(searchPath.Item); DiscoverUnitTests(tds, slnPath, slnSnapPath, discoveredUnitTestsStore, discoveredUnitDTestsStore, buildRoot, new DateTime(long.Parse(timeFilter)), ignoredTests); LogInfo("TestHost: Exiting Main."); return(0); } else { var tes = AdapterLoader.LoadExecutors(searchPath.Item); var allTestsPassed = false; if (_debuggerAttached) { allTestsPassed = RunTests(tes, slnPath, slnSnapPath, buildRoot, testResultsStore, testFailureInfoStore, GetTestToDebug(discoveredUnitTestsStore, discoveredUnitDTestsStore)); } else { allTestsPassed = ExecuteTestWithCoverageDataCollection(() => RunTests(tes, slnPath, slnSnapPath, buildRoot, testResultsStore, testFailureInfoStore, PerDocumentLocationXTestCases.Deserialize(FilePath.NewFilePath(discoveredUnitTestsStore))), codeCoverageStore); } LogInfo("TestHost: Exiting Main."); return(allTestsPassed ? 0 : 1); } }