Skip to content

Commit

Permalink
Merge pull request #96 from netspiri/feature-parity/force-pattern
Browse files Browse the repository at this point in the history
Update 'ForceListContent' Filename Pattern
  • Loading branch information
Łukasz Mendakiewicz authored Sep 13, 2018
2 parents 5deb402 + 98d10d6 commit f0675bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
22 changes: 14 additions & 8 deletions BoostTestAdapter/Discoverers/BoostTestDiscovererFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

using BoostTestAdapter.Discoverers;
using BoostTestAdapter.Boost.Runner;
using BoostTestAdapter.Settings;
using System;

namespace BoostTestAdapter
{
class BoostTestDiscovererFactory : IBoostTestDiscovererFactory
{
#region Constants

private static string ForceListContentExtension { get { return ".test.boostd.exe"; } }

/// <summary>
/// Default 'ForceListContent' filename pattern. Such filenames are assumed to be valid Boost.Test modules by default.
/// </summary>
private static readonly Regex _forceListContentExtensionPattern = new Regex(@"test\.boost(?:d)?\.exe$", RegexOptions.IgnoreCase);

#endregion

#region Constructors
Expand Down Expand Up @@ -87,8 +92,10 @@ public IEnumerable<FactoryResult> GetDiscoverers(IReadOnlyCollection<string> sou
}

// Skip modules which are not .exe
if (extension != BoostTestDiscoverer.ExeExtension)
if (string.Compare(extension, BoostTestDiscoverer.ExeExtension, true) != 0)
{
continue;
}

// Ensure that the source is a Boost.Test module if it supports '--list_content'
if (((settings.ForceListContent) || IsListContentSupported(source, settings)))
Expand Down Expand Up @@ -133,9 +140,8 @@ private bool IsListContentSupported(string source, BoostTestAdapterSettings sett

IBoostTestRunner runner = _factory.GetRunner(source, options);

// Convention over configuration. Assume test runners utilising such an extension
return (runner != null) && (runner.Source.EndsWith(ForceListContentExtension, StringComparison.OrdinalIgnoreCase) || runner.ListContentSupported);
// Convention over configuration. Assume test runners utilising such an extension pattern
return (runner != null) && (_forceListContentExtensionPattern.IsMatch(source) || runner.ListContentSupported);
}

}
}
19 changes: 19 additions & 0 deletions BoostTestAdapterNunit/DefaultTestDiscovererFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ internal enum ListContentUse
// .test.boostd.exe
[TestCase("test.test.boostd.exe", ListContentUse.Use, null, Result = typeof(ListContentDiscoverer))]
[TestCase("test.test.boostd.exe", ListContentUse.ForceUse, null, Result = typeof(ListContentDiscoverer))]
// .test.boostd.exe (case-insensitive)
[TestCase("test.TEST.BOOSTD.exe", ListContentUse.Use, null, Result = typeof(ListContentDiscoverer))]
// .test.boost.exe
[TestCase("test.test.boost.exe", ListContentUse.Use, null, Result = typeof(ListContentDiscoverer))]
[TestCase("test.test.boost.exe", ListContentUse.ForceUse, null, Result = typeof(ListContentDiscoverer))]
// .test.boostd.exe (case-insensitive)
[TestCase("test.TEST.BOOST.EXE", ListContentUse.Use, null, Result = typeof(ListContentDiscoverer))]
// .AcceptanceTest.boostd.exe
[TestCase("test.AcceptanceTest.boostd.exe", ListContentUse.Use, null, Result = typeof(ListContentDiscoverer))]
[TestCase("test.AcceptanceTest.boostd.exe", ListContentUse.ForceUse, null, Result = typeof(ListContentDiscoverer))]
// .Acceptancetest.boostd.exe (case-insensitive)
[TestCase("test.Acceptancetest.boostd.exe", ListContentUse.Use, null, Result = typeof(ListContentDiscoverer))]
// .AcceptanceTest.boost.exe
[TestCase("test.AcceptanceTest.boost.exe", ListContentUse.Use, null, Result = typeof(ListContentDiscoverer))]
[TestCase("test.AcceptanceTest.boost.exe", ListContentUse.ForceUse, null, Result = typeof(ListContentDiscoverer))]
// .Acceptancetest.boost.exe (case-insensitive)
[TestCase("test.Acceptancetest.boost.exe", ListContentUse.Use, null, Result = typeof(ListContentDiscoverer))]
// Dll types
[TestCase("test.dll", ListContentUse.Use, null, Result = null)]
[TestCase("test.dll", ListContentUse.Use, ".dll", Result = typeof(ExternalDiscoverer))]
Expand All @@ -85,6 +102,8 @@ internal enum ListContentUse
[TestCase("test.txt", ListContentUse.ForceUse, null, Result = null)]
[TestCase("test.txt", ListContentUse.ForceUse, ".dll", Result = null)]
[TestCase("test.txt", ListContentUse.ForceUse, ".exe", Result = null)]
[TestCase("test.test.Acceptance.boostd.exe", ListContentUse.Use, null, Result = null)]
[TestCase("test.test.Acceptance.boost.exe", ListContentUse.Use, null, Result = null)]
public Type TestDiscovererProvisioning(string source, ListContentUse listContent, string externalExtension)
{
ExternalBoostTestRunnerSettings externalSettings = null;
Expand Down

0 comments on commit f0675bb

Please sign in to comment.