in BoostTestAdapter/Discoverers/ListContentDiscoverer.cs [67:148]
public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, ITestCaseDiscoverySink discoverySink)
{
Code.Require(sources, "sources");
Code.Require(discoverySink, "discoverySink");
// Populate loop-invariant attributes and settings
BoostTestAdapterSettings settings = BoostTestAdapterSettingsProvider.GetSettings(discoveryContext);
BoostTestRunnerSettings runnerSettings = new BoostTestRunnerSettings()
{
Timeout = settings.DiscoveryTimeoutMilliseconds
};
BoostTestRunnerCommandLineArgs args = new BoostTestRunnerCommandLineArgs()
{
ListContent = ListContentFormat.DOT
};
foreach (var source in sources)
{
try
{
using (var packageService = _packageServiceFactory.Create(settings.ParentVSProcessId))
{
args.SetWorkingEnvironment(source, settings, packageService);
}
}
catch (Exception ex)
{
Logger.Debug(Resources.WorkingDirectoryNotFoundEx, ex.Message);
}
try
{
IBoostTestRunner runner = _runnerFactory.GetRunner(source, settings.TestRunnerFactoryOptions);
using (TemporaryFile output = new TemporaryFile(TestPathGenerator.Generate(source, ".list.content.gv")))
{
// --list_content output is redirected to standard error
args.StandardErrorFile = output.Path;
Logger.Debug(Resources.ListContentsFile, args.StandardErrorFile);
int resultCode = EXIT_SUCCESS;
using (var context = new DefaultProcessExecutionContext())
{
resultCode = runner.Execute(args, runnerSettings, context);
}
// Skip sources for which the --list_content file is not available
if (!File.Exists(args.StandardErrorFile))
{
Logger.Error(Resources.ListContentsNotFound, source);
continue;
}
// If the executable failed to exit with an EXIT_SUCCESS code, skip source and notify user accordingly
if (resultCode != EXIT_SUCCESS)
{
Logger.Error(Resources.ListContentProcessFailure, source, resultCode);
continue;
}
// Parse --list_content=DOT output
using (var stream = File.OpenRead(args.StandardErrorFile))
using (var reader = new StreamReader(stream, System.Text.Encoding.Default))
{
TestFrameworkDOTDeserialiser deserialiser = new TestFrameworkDOTDeserialiser(source);
TestFramework framework = deserialiser.Deserialise(reader);
if ((framework != null) && (framework.MasterTestSuite != null))
{
framework.MasterTestSuite.Apply(new VSDiscoveryVisitor(source, discoverySink));
}
}
}
}
catch (Exception ex)
{
Logger.Exception(ex, Resources.DiscoveryExceptionFor, source, ex.Message, ex.HResult);
}
}
}