public IEnumerable <string> GetAllAssemblies()
        {
            var assemblies = _directoryWrapper
                             .EnumerateFiles(Utils.GetGaugeBinDir(), "*.dll", SearchOption.TopDirectoryOnly)
                             .ToList();
            var gaugeAdditionalLibsPath = Environment.GetEnvironmentVariable("GAUGE_ADDITIONAL_LIBS");

            if (string.IsNullOrEmpty(gaugeAdditionalLibsPath))
            {
                return(assemblies);
            }

            var additionalLibPaths = gaugeAdditionalLibsPath.Split(',').Select(s => Path.GetFullPath(s.Trim()));

            foreach (var libPath in additionalLibPaths)
            {
                if (Path.HasExtension(libPath))
                {
                    AddFile(libPath, assemblies);
                    continue;
                }

                AddFilesFromDirectory(libPath, assemblies);
            }

            return(assemblies);
        }
Example #2
0
        public AssemblyPath GetTestAssembly()
        {
            var gaugeBinDir = Utils.GetGaugeBinDir();

            try
            {
                return(_directoryWrapper
                       .EnumerateFiles(gaugeBinDir, "*.deps.json", SearchOption.TopDirectoryOnly)
                       .First().Replace(".deps.json", ".dll"));
            }
            catch (System.InvalidOperationException)
            {
                throw new GaugeTestAssemblyNotFoundException(gaugeBinDir);
            }
        }
        public void ManageBackups(
            string path,
            IPathWrapper pathWrapper,
            IDirectoryWrapper directoryWrapper,
            IFileWrapper fileWrapper)
        {
            string dataFileFilter = Path.ChangeExtension(
                string.Format("{0}*", Path.GetFileNameWithoutExtension(DataFile)),
                Path.GetExtension(DataFile));
            var backupFiles = directoryWrapper.EnumerateFiles(
                pathWrapper.GetDirectoryName(path),
                dataFileFilter).Where(f => f != FullDataFilePath).OrderByDescending(f => f);
            //first save of day - delete old backups
            int backupcount = backupFiles.Count();
            int skipfiles   = 7; //backups to keep

            if (backupcount > skipfiles)
            {
                foreach (string s in backupFiles.Skip(skipfiles))
                {
                    fileWrapper.Delete(s);
                }
            }
        }
Example #4
0
        public void LoadImplementations()
        {
            if (!string.IsNullOrEmpty(Utils.TryReadEnvValue("GAUGE_CUSTOM_BUILD_PATH")))
            {
                Logger.Debug("GAUGE_CUSTOM_BUILD_PATH is set, skipping static loading");
                return;
            }

            var classFiles = _directoryWrapper.EnumerateFiles(Utils.GaugeProjectRoot, "*.cs",
                                                              SearchOption.AllDirectories).ToList();
            var attributes = _attributesLoader.GetRemovedAttributes();

            foreach (var attribute in attributes)
            {
                classFiles.Remove(Path.Combine(Utils.GaugeProjectRoot, attribute.Value));
            }
            var removedFiles = FileHelper.GetRemovedDirFiles();
            var wantedFiles  = classFiles.Except(removedFiles);

            foreach (var f in wantedFiles)
            {
                LoadStepsFromText(File.ReadAllText(f), f);
            }
        }
Example #5
0
        public IReadOnlyDictionary <int, string> GetSortedByNumberInFileName()
        {
            var fileNamesSorted = new SortedList <int, string>();

            string searchPattern = Path.GetFileNameWithoutExtension(FileName) + "*.txt";

            foreach (var file in _directoryWrapper.EnumerateFiles(LogPath, searchPattern, SearchOption.TopDirectoryOnly))
            {
                string name       = Path.GetFileNameWithoutExtension(file);
                int    indexOfNum = name.IndexOfNumberEndingPathBegging();

                if (indexOfNum < 0)
                {
                    fileNamesSorted.Add(0, file);
                    continue;
                }

                int fileNum = int.Parse(name.Substring(indexOfNum, name.Length - indexOfNum));

                fileNamesSorted.Add(fileNum, file);
            }

            return(fileNamesSorted);
        }