private TestRunConfiguration BuildTestRunConfiguration(IEnumerable<PathInfo> scriptPaths, TestOptions testOptions) { var testRunConfiguration = new TestRunConfiguration(); // Find all chutzpah.json files for the input files // Then group files by their respective settings file var testGroups = new List<List<PathInfo>>(); var fileSettingGroups = from path in scriptPaths let settingsFile = testSettingsService.FindSettingsFile(path.FullPath, testOptions.ChutzpahSettingsFileEnvironments) group path by settingsFile; // Scan over the grouped test files and if this file is set up for batching we add those files // as a group to be tested. Otherwise, we will explode them out individually so they get run in their // own context foreach (var group in fileSettingGroups) { if (group.Key.EnableTestFileBatching.Value) { testGroups.Add(group.ToList()); } else { foreach (var path in group) { testGroups.Add(new List<PathInfo> { path }); } } } testRunConfiguration.TestGroups = testGroups; // Take the parallelism degree to be the minimum of any non-null setting in chutzpah.json testRunConfiguration.MaxDegreeOfParallelism = fileSettingGroups.Min(x => x.Key.Parallelism); // Enable tracing if any setting is true testRunConfiguration.EnableTracing = fileSettingGroups.Any(x => x.Key.EnableTracing.HasValue && x.Key.EnableTracing.Value); testRunConfiguration.TraceFilePath = fileSettingGroups.Select(x => x.Key.TraceFilePath).FirstOrDefault(x => !string.IsNullOrEmpty(x)) ?? testRunConfiguration.TraceFilePath; return testRunConfiguration; }
private void ConfigureTracing(TestRunConfiguration testRunConfiguration) { var path = testRunConfiguration.TraceFilePath; if (testRunConfiguration.EnableTracing) { ChutzpahTracer.AddFileListener(path); } else { // TODO (mmanela): There is a known issue with this if the user is running chutzpah in VS and changes their trace path // This will result in that path not getting removed until the VS is restarted. To fix this we need to keep trace of previous paths // and clear them all out. ChutzpahTracer.RemoveFileListener(path); } }