private IEnumerable <PathInfo> FindTestFiles(IEnumerable <string> testPaths, TestOptions options) { IEnumerable <PathInfo> scriptPaths = Enumerable.Empty <PathInfo>(); // If the path list contains only chutzpah.json files then use those files for getting the list of test paths var testPathList = testPaths.ToList(); if (testPathList.All(testPath => Path.GetFileName(testPath).Equals(Constants.SettingsFileName, StringComparison.OrdinalIgnoreCase))) { ChutzpahTracer.TraceInformation("Using Chutzpah.json files to find tests"); foreach (var path in testPathList) { var chutzpahJsonPath = fileProbe.FindFilePath(path); if (chutzpahJsonPath == null) { ChutzpahTracer.TraceWarning("Supplied chutzpah.json path {0} does not exist", path); } // The FindSettingsFile api takes the directory of the file since it caches this for use in later test runs // this could be cleaned up to have two APIS one which lets you give the direct file var settingsFile = testSettingsService.FindSettingsFile(Path.GetDirectoryName(chutzpahJsonPath)); var pathInfos = fileProbe.FindScriptFiles(settingsFile); scriptPaths = scriptPaths.Concat(pathInfos); } } else { scriptPaths = fileProbe.FindScriptFiles(testPathList, options.TestingMode); } return(scriptPaths); }
private IEnumerable <PathInfo> FindTestFiles(IEnumerable <string> testPaths, TestOptions options) { IEnumerable <PathInfo> scriptPaths = Enumerable.Empty <PathInfo>(); // If the path list contains only chutzpah.json files then use those files for getting the list of test paths var testPathList = testPaths.Distinct(StringComparer.OrdinalIgnoreCase).ToList(); if (testPathList.All(testPath => Path.GetFileName(testPath).Equals(Constants.SettingsFileName, StringComparison.OrdinalIgnoreCase))) { ChutzpahTracer.TraceInformation("Using Chutzpah.json files to find tests"); foreach (var path in testPathList) { var chutzpahJsonPath = fileProbe.FindFilePath(path); if (chutzpahJsonPath == null) { ChutzpahTracer.TraceWarning("Supplied chutzpah.json path {0} does not exist", path); } var settingsFile = testSettingsService.FindSettingsFile(chutzpahJsonPath, options.ChutzpahSettingsFileEnvironments); var pathInfos = fileProbe.FindScriptFiles(settingsFile); scriptPaths = scriptPaths.Concat(pathInfos); } } else { scriptPaths = fileProbe.FindScriptFiles(testPathList); } return(scriptPaths .Where(x => x.FullPath != null) .ToList());; }