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}");
     }
 }
Beispiel #2
0
        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);
            }
        }