internal static (string containers, string filters) GetTestContainersAndFilters(string configJson, string configPath) { try { var config = OptProfTrainingConfiguration.Deserialize(configJson); return(GetTestContainers(config), GetTestFilters(config)); } catch (Exception e) { throw new ApplicationException($"Unable to read config file '{configPath}': {e.Message}"); } }
private void ExecuteImpl() { OptProfTrainingConfiguration config; try { config = OptProfTrainingConfiguration.Deserialize(File.ReadAllText(ConfigurationFile, Encoding.UTF8)); } catch (Exception e) { Log.LogError($"Unable to open the config file '{ConfigurationFile}': {e.Message}"); return; } if (config.Products == null) { Log.LogError($"Invalid configuration file format: missing 'products' element in '{ConfigurationFile}'."); } if (config.Assemblies == null) { Log.LogError($"Invalid configuration file format: missing 'assemblies' element in '{ConfigurationFile}'."); } if (!Directory.Exists(InsertionDirectory)) { Log.LogError($"Directory specified in InsertionDirectory does not exist: '{InsertionDirectory}'."); } if (Log.HasLoggedErrors) { return; } // Handle product entries foreach (var product in config.Products) { string vsixFilePath = Path.Combine(InsertionDirectory, product.Name); var jsonManifest = ReadVsixJsonManifest(vsixFilePath); var ibcEntries = IbcEntry.GetEntriesFromVsixJsonManifest(jsonManifest).ToArray(); WriteEntries(product.Tests, ibcEntries); } // Handle assembly entries foreach (var assembly in config.Assemblies) { var assemblyEntries = IbcEntry.GetEntriesFromAssembly(assembly).ToArray(); WriteEntries(assembly.Tests, assemblyEntries); } }
private static string GetTestFilters(OptProfTrainingConfiguration config) { var productTests = config.Products?.Any() == true ? config.Products.SelectMany(x => x.Tests.SelectMany(y => y.TestCases ?? y.FilteredTestCases.SelectMany(z => z.TestCases))) : Enumerable.Empty <string>(); var assemblyTests = config.Assemblies?.Any() == true ? config.Assemblies.SelectMany(x => x.Tests.SelectMany(y => y.TestCases)) : Enumerable.Empty <string>(); return(string.Join( "|", productTests .Concat(assemblyTests) .Distinct() .Select(x => $"FullyQualifiedName={x}"))); }
private static string GetTestContainers(OptProfTrainingConfiguration config) { var productContainers = config.Products?.Any() == true ? config.Products.SelectMany(x => x.Tests.Select(y => y.Container + ".dll")) : Enumerable.Empty <string>(); var assemblyContainers = config.Assemblies?.Any() == true ? config.Assemblies.SelectMany(x => x.Tests.Select(y => y.Container + ".dll")) : Enumerable.Empty <string>(); return(string.Join( Environment.NewLine, productContainers .Concat(assemblyContainers) .Distinct() .Select(x => $@" <TestContainer FileName=""{x}"" />"))); }