public void Sink_ShouldContainTestForAllSupportedTypeOfSources() { var sources = new[] { "ListContentSupport" + BoostTestDiscoverer.ExeExtension, "DllProject1" + BoostTestDiscoverer.DllExtension, "DllProject2" + BoostTestDiscoverer.DllExtension, }; var context = new DefaultTestContext(); var logger = new ConsoleMessageLogger(); var sink = new DefaultTestCaseDiscoverySink(); context.RegisterSettingProvider(BoostTestAdapterSettings.XmlRootName, new BoostTestAdapterSettingsProvider()); context.LoadEmbeddedSettings("BoostTestAdapterNunit.Resources.Settings.externalTestRunner.runsettings"); var boostTestDiscovererFactory = new StubBoostTestDiscovererFactory(); var boostTestDiscoverer = new BoostTestDiscoverer(boostTestDiscovererFactory); boostTestDiscoverer.DiscoverTests(sources, context, logger, sink); Assert.That(sink.Tests, Is.Not.Empty); // tests are found in the using the fake debughelper Assert.That(sink.Tests.Count(x => x.Source == "ListContentSupport" + BoostTestDiscoverer.ExeExtension), Is.EqualTo(8)); // the external runner does NOT support the two dll projects Assert.That(sink.Tests.Any(x => x.Source == "DllProject1" + BoostTestDiscoverer.DllExtension), Is.False); Assert.That(sink.Tests.Any(x => x.Source == "DllProject2" + BoostTestDiscoverer.DllExtension), Is.False); }
public void DiscoveryFileMapWithInvalidDiscovery() { using (var listing = TestHelper.CopyEmbeddedResourceToTempDirectory("BoostTestAdapterNunit.Resources.TestLists", "sample.test.list.xml")) using (var invalid_listing = TestHelper.CopyEmbeddedResourceToTempDirectory("BoostTestAdapterNunit.Resources.TestLists", "invalid.test.list.xml")) { ExternalBoostTestRunnerSettings settings = new ExternalBoostTestRunnerSettings { DiscoveryMethodType = DiscoveryMethodType.DiscoveryFileMap }; settings.DiscoveryFileMap["test_2.dll"] = invalid_listing.Path; settings.DiscoveryFileMap["test_1.dll"] = listing.Path; ExternalDiscoverer discoverer = new ExternalDiscoverer(settings, DummyVSProvider.Default); DefaultTestContext context = new DefaultTestContext(); ConsoleMessageLogger logger = new ConsoleMessageLogger(); DefaultTestCaseDiscoverySink sink = new DefaultTestCaseDiscoverySink(); const string mappedSource = "C:\\test_1.dll"; const string invalidSource = "C:\\test_2.dll"; discoverer.DiscoverTests(new string[] { mappedSource, invalidSource }, context, sink); // A total of 7 tests should be discovered as described in the Xml descriptor Assert.That(sink.Tests.Count(), Is.EqualTo(7)); // All of the discovered tests should originate from C:\test_1.dll. // No mapping to C:\test_2.dll exist so no tests should be discovered from that source. Assert.That(sink.Tests.Count((test) => test.Source == mappedSource), Is.EqualTo(7)); const string masterTestSuite = "Test runner test"; AssertVSTestCaseProperties(sink.Tests, QualifiedNameBuilder.FromString(masterTestSuite, "test1"), mappedSource, new SourceFileInfo("test_runner_test.cpp", 26)); AssertVSTestCaseProperties(sink.Tests, QualifiedNameBuilder.FromString(masterTestSuite, "test2"), mappedSource, new SourceFileInfo("test_runner_test.cpp", 35)); AssertVSTestCaseProperties(sink.Tests, QualifiedNameBuilder.FromString(masterTestSuite, "SampleSuite/SampleNestedSuite/test3"), mappedSource, new SourceFileInfo("test_runner_test.cpp", 48)); AssertVSTestCaseProperties(sink.Tests, QualifiedNameBuilder.FromString(masterTestSuite, "TemplateSuite/my_test<char>"), mappedSource, new SourceFileInfo("test_runner_test.cpp", 79)); AssertVSTestCaseProperties(sink.Tests, QualifiedNameBuilder.FromString(masterTestSuite, "TemplateSuite/my_test<int>"), mappedSource, new SourceFileInfo("test_runner_test.cpp", 79)); AssertVSTestCaseProperties(sink.Tests, QualifiedNameBuilder.FromString(masterTestSuite, "TemplateSuite/my_test<float>"), mappedSource, new SourceFileInfo("test_runner_test.cpp", 79)); AssertVSTestCaseProperties(sink.Tests, QualifiedNameBuilder.FromString(masterTestSuite, "TemplateSuite/my_test<double>"), mappedSource, new SourceFileInfo("test_runner_test.cpp", 79)); } }
private static void RunWithOptions(Options opts) { //Guid timeline_guid = Guid.NewGuid(); FileInfo referenceFile = new(opts.ReferenceAssembly); FileInfo newFile = new(opts.NewAssembly); if (referenceFile.Exists && newFile.Exists) { //if (opts.AzurePipelines) //Console.WriteLine("##vso[task.logdetail id={0};name=BinaryCompatibilityCheck;type=build;order=1;state=Initialized]Starting...", timeline_guid); var refName = AssemblyName.GetAssemblyName(referenceFile.FullName); var newName = AssemblyName.GetAssemblyName(newFile.FullName); Console.WriteLine("Using '{0}' as the reference assembly.", refName.FullName); Console.WriteLine("Using '{0}' as the new assembly.", refName.FullName); using (PEReader referenceAssembly = new(File.OpenRead(referenceFile.FullName))) { using (PEReader newAssembly = new(File.OpenRead(newFile.FullName))) { IMessageLogger logger; if (opts.AzurePipelines) { if (opts.WarningsOnly) { logger = new AzurePipelinesMessageLogger(Severity.Warning); } else { logger = new AzurePipelinesMessageLogger(); } } else { logger = new ConsoleMessageLogger(); } Analyzer analyzer = new(referenceAssembly, newAssembly, null, logger); analyzer.Run(); if (analyzer.HasRun) { Console.WriteLine(string.Format("Analyzer done. {0} errors, {1} warnings, {2} informational items.", analyzer.ResultStatistics.SeverityCounts.error, analyzer.ResultStatistics.SeverityCounts.warning, analyzer.ResultStatistics.SeverityCounts.information)); if (analyzer.ResultStatistics.SeverityCounts.error > 0) { if (opts.AzurePipelines) { Console.WriteLine("##vso[task.complete result=SucceededWithIssues]"); } Environment.ExitCode = opts.WarningsOnly ? 0 : -2; return; } else { if (opts.AzurePipelines) { Console.WriteLine("##vso[task.complete result=Succeeded]"); } return; } } else { if (opts.AzurePipelines) { Console.WriteLine("##vso[task.complete result=Failed]"); } Environment.ExitCode = opts.WarningsOnly ? 0 : -1; return; } } } } else { if (!referenceFile.Exists) { Console.Error.WriteLine("{1}Reference file '{0}' not found or inaccessible.", referenceFile.FullName, opts.AzurePipelines ? "##vso[task.logissue type=error]" : string.Empty); } if (!newFile.Exists) { Console.Error.WriteLine("{1}New file '{0}' not found or inaccessible.", newFile.FullName, opts.AzurePipelines ? "##vso[task.logissue type=error]" : string.Empty); } Environment.ExitCode = 2; return; } }