Esempio n. 1
0
        public void DiscoverProjectFileReturnsNullIfNoProjectFileIsPresent()
        {
            var fileSystem = new FileSystemMock();

            fileSystem
            .AddDirectory(@"d:\foo")
            .AddDirectory(@"bar");

            var provider = new ProjectFileDiscoveryProvider(fileSystem);
            var project  = provider.GetProjectFromAnyPath(new FullPath(@"d:\foo\bar\" + ConfigurationFileNames.ProjectFileName));

            Assert.IsNull(project);
        }
Esempio n. 2
0
        public void DiscoverObsoleteProjectFileWorks()
        {
            var fileSystem = new FileSystemMock();

            fileSystem
            .AddDirectory(@"d:\foo")
            .AddFile(@"bar.txt", "some text content")
            .Parent.AddDirectory(@"bar");

            Assert.IsFalse(fileSystem.GetFileInfoSnapshot(new FullPath(@"d:\foo\bar2")).Exists);
            Assert.IsTrue(fileSystem.GetFileInfoSnapshot(new FullPath(@"d:\foo\bar")).IsDirectory);
            Assert.IsTrue(fileSystem.GetFileInfoSnapshot(new FullPath(@"d:\foo\bar.txt")).IsFile);
        }
Esempio n. 3
0
        public void DiscoverProjectFileFromProjectFileWorks()
        {
            var fileSystem = new FileSystemMock();

            fileSystem
            .AddDirectory(@"d:\foo")
            .AddDirectory(@"bar")
            .AddFile(ConfigurationFileNames.ProjectFileName, "invalid content");

            var provider = new ProjectFileDiscoveryProvider(fileSystem);
            var project  = provider.GetProjectFromAnyPath(new FullPath(@"d:\foo\bar\" + ConfigurationFileNames.ProjectFileName));

            Assert.IsNotNull(project);
        }
Esempio n. 4
0
        public void DiscoverObsoleteProjectFileWorks()
        {
            var fileSystem = new FileSystemMock();

            fileSystem
            .AddDirectory(@"d:\foo")
            .AddDirectory(@"bar")
            .AddFile(@"test.txt", "some text content")
            .Parent.AddFile(ConfigurationFileNames.ProjectFileNameObsolete, "invalid content");

            var provider = new ProjectFileDiscoveryProvider(fileSystem);
            var project  = provider.GetProjectFromAnyPath(new FullPath(@"d:\foo\bar\test.txt"));

            Assert.IsNotNull(project);
        }
Esempio n. 5
0
        public void DiscoverProjectFileFiltersWorks()
        {
            var fileSystem = new FileSystemMock();

            fileSystem
            .AddDirectory(@"d:\foo")
            .AddDirectory(@"bar")
            .AddDirectory(@".git")
            .Parent
            .AddFile(@"test.txt", @"some text")
            .Parent
            .AddFile(ConfigurationFileNames.ProjectFileName,
                     @"
[SourceExplorer.ignore]
.git/
*.sdf
*.opensdf
*.suo

[SearchableFiles.ignore]
Binaries/
obj/
Debug/
x64/
*.png
*.ico
*.ipch
*.pch
*.dll
*.pdb

[SearchableFiles.include]
*
");

            var provider = new ProjectFileDiscoveryProvider(fileSystem);
            var project  = provider.GetProjectFromAnyPath(new FullPath(@"d:\foo\bar\test.txt"));

            Assert.IsNotNull(project);
            Assert.AreEqual(@"d:\foo\bar", project.RootPath.Value);
            Assert.IsFalse(project.FileFilter.Include(new RelativePath("test.sdf")));
            Assert.IsTrue(project.FileFilter.Include(new RelativePath(".git")));
            Assert.IsFalse(project.DirectoryFilter.Include(new RelativePath(".git")));
            Assert.IsTrue(project.SearchableFilesFilter.Include(new RelativePath("none.txt")));
            Assert.IsFalse(project.SearchableFilesFilter.Include(new RelativePath("none.png")));
        }
Esempio n. 6
0
        public void DiscoverProjectFileInSubFolderWorks()
        {
            var fileSystem = new FileSystemMock();

            fileSystem
            .AddDirectory(@"d:\foo")
            .AddDirectory(@"bar")
            .AddFile(@"test.txt", "some text content")
            .Parent
            .AddFile(ConfigurationFileNames.ProjectFileName, "invalid content");

            var provider = new ProjectFileDiscoveryProvider(fileSystem);
            var project  = provider.GetProjectFromAnyPath(new FullPath(@"d:\foo\bar\test.txt"));

            Assert.IsNotNull(project);
            Assert.AreEqual(@"d:\foo\bar", project.RootPath.Value);
            Assert.IsTrue(project.FileFilter.Include(new RelativePath("none.txt")));
            Assert.IsTrue(project.DirectoryFilter.Include(new RelativePath("none")));
            Assert.IsFalse(project.SearchableFilesFilter.Include(new RelativePath("none.txt")));
        }
        public void DiscoverProjectFileInSubFolderWorks()
        {
            var fileSystem = new FileSystemMock();

            fileSystem
            .AddDirectory(@"d:\foo")
            .AddDirectory(@"bar")
            .AddDirectory(@"base").Parent
            .AddDirectory(@"chrome").Parent
            .AddDirectory(@"content").Parent
            .AddFile(@"presubmit.py", "hello").Parent
            .AddFile(@"test.txt", "some text content");

            // Add configuration directory
            AddConfigFile(fileSystem, ConfigurationFileNames.ChromiumEnlistmentDetectionPatterns);
            AddConfigFile(fileSystem, ConfigurationSectionNames.SourceExplorerIgnoreObsolete);
            AddConfigFile(fileSystem, ConfigurationSectionNames.SearchableFilesIgnore);
            AddConfigFile(fileSystem, ConfigurationSectionNames.SearchableFilesInclude);

            var locator  = new ConfigurationFileLocator(fileSystem);
            var provider = new ChromiumProjectDiscoveryProvider(locator, fileSystem);
            var project  = provider.GetProjectFromAnyPath(new FullPath(@"d:\foo\bar\test.txt"));

            Assert.IsNotNull(project);
            Assert.AreEqual(@"d:\foo\bar", project.RootPath.Value);
            Assert.IsTrue(project.FileFilter.Include(new RelativePath("none.txt")));
            Assert.IsTrue(project.DirectoryFilter.Include(new RelativePath("none")));
            Assert.IsTrue(project.SearchableFilesFilter.Include(new RelativePath("source.cpp")));


            project = provider.GetProjectFromAnyPath(new FullPath(@"d:\foo\bar"));
            Assert.IsNotNull(project);
            Assert.AreEqual(@"d:\foo\bar", project.RootPath.Value);

            project = provider.GetProjectFromAnyPath(new FullPath(@"d:\foo"));
            Assert.IsNull(project);
        }