Inheritance: IFileSystemDirectory
コード例 #1
0
        /// <summary>
        /// Gets the relative path from this directory to another directory (in any depth)
        ///
        /// <para>If the given argument is not a child of this directory, an <see cref="ArgumentException"/>will
        /// be thrown.</para>
        /// </summary>
        /// <param name="childDirectory">The child directory to get path to</param>
        /// <returns>Returns the path</returns>
        public string GetRelativePath(IFileSystemDirectory childDirectory)
        {
            var testChild = childDirectory as TestFileSystemDirectory;

            if (testChild != null)
            {
                var dirs = new List <TestFileSystemDirectory>();
                TestFileSystemDirectory current = testChild;
                while (current != this)
                {
                    dirs.Add(current);
                    current = current.parent;
                }

                dirs.Reverse();

                var result = new StringBuilder();
                for (int i = 0; i < dirs.Count; i++)
                {
                    if (i > 0)
                    {
                        result.Append(Path.DirectorySeparatorChar);
                    }

                    result.Append(dirs[i].Name);
                }

                return(result.ToString());
            }
            else
            {
                throw new NotSupportedException();
            }
        }
コード例 #2
0
ファイル: SuiteTest.cs プロジェクト: zvrana/bari
        public void StoresReferenceToRoot()
        {
            var fs = new TestFileSystemDirectory("root");
            var suite = new Suite(fs);

            suite.SuiteRoot.Should().Be(fs);
        }
コード例 #3
0
        public void ExistingModulesMergedWithDiscoveredOnes()
        {
            var fs = new TestFileSystemDirectory("root",
                                                 new TestFileSystemDirectory("src",
                                                                             new TestFileSystemDirectory("Module1",
                                                                                                         new TestFileSystemDirectory
                                                                                                             ("Project11"))));

            var suite = new Suite(fs);

            var module1 = suite.GetModule("Module1");
            var projectA = module1.GetProject("ProjectA");

            module1.Projects.Should().HaveCount(1);
            module1.Projects.Should().HaveElementAt(0, projectA);

            var discovery = new ModuleProjectDiscovery(fs);
            discovery.ExtendWithDiscoveries(suite);

            suite.Modules.Should().HaveCount(1);
            suite.Modules.Should().HaveElementAt(0, module1);
            module1.Projects.Should().HaveCount(2);
            module1.Projects.Should().Contain(projectA);
            module1.Projects.Should().Contain(p => p.Name == "Project11");
        }
コード例 #4
0
        public void ProjectsDiscovered()
        {
            var fs = new TestFileSystemDirectory("root",
                                     new TestFileSystemDirectory("src",
                                                                 new TestFileSystemDirectory("Module1",
                                                                     new TestFileSystemDirectory("Project11")),
                                                                 new TestFileSystemDirectory("Module2"),
                                                                 new TestFileSystemDirectory("Module3",
                                                                     new TestFileSystemDirectory("Project31"),
                                                                     new TestFileSystemDirectory("Project32"))),
                                     new TestFileSystemDirectory("output"));

            var suite = new Suite(fs);

            suite.Modules.Should().BeEmpty();

            var discovery = new ModuleProjectDiscovery(fs);
            discovery.ExtendWithDiscoveries(suite);

            suite.Modules.Should().HaveCount(3);
            suite.Modules.Should().OnlyContain(m => m.Name == "Module1" ||
                                                    m.Name == "Module2" ||
                                                    m.Name == "Module3");

            suite.GetModule("Module1").Projects.Should().HaveCount(1);
            suite.GetModule("Module1").Projects.Should().Contain(p => p.Name == "Project11");
            suite.GetModule("Module2").Projects.Should().HaveCount(0);
            suite.GetModule("Module3").Projects.Should().HaveCount(2);
            suite.GetModule("Module3").Projects.Should().Contain(p => p.Name == "Project31");
            suite.GetModule("Module3").Projects.Should().Contain(p => p.Name == "Project32");
        }
コード例 #5
0
        public void SetUp()
        {
            var root = new TestFileSystemDirectory("root");
            var goalx86 = new Goal("debug-x86", new[] { Suite.DebugGoal, new Goal("x86") });
            var goalx64 = new Goal("debug-x64", new[] { Suite.DebugGoal, new Goal("x64") });

            x86Suite = new Suite(root, new[] {goalx86, goalx64}, goalx86);
            x64Suite = new Suite(root, new[] {goalx86, goalx64}, goalx64);
        }
コード例 #6
0
        public void SetUp()
        {
            var root = new TestFileSystemDirectory("root");
            debugSuite = new Suite(root, new[] {Suite.DebugGoal, Suite.ReleaseGoal}, Suite.DebugGoal);
            releaseSuite = new Suite(root, new[] { Suite.DebugGoal, Suite.ReleaseGoal }, Suite.ReleaseGoal);

            var customDebug = new Goal("test-debug", new[] {Suite.DebugGoal});
            var customRelease = new Goal("test-release", new[] { Suite.ReleaseGoal });

            customDebugSuite = new Suite(root, new[] { customDebug, customRelease }, customDebug);
            customReleaseSuite = new Suite(root, new[] { customDebug, customRelease }, customRelease);
        }
コード例 #7
0
ファイル: TestProjectTest.cs プロジェクト: zvrana/bari
        public void RootDirectoryIsSubdirectoryOfModulesTestDirectory()
        {
            var projdir = new TestFileSystemDirectory("test");
            var fs = new TestFileSystemDirectory(
                "root", new TestFileSystemDirectory(
                            "src", new TestFileSystemDirectory(
                                       "testmod", new TestFileSystemDirectory(
                                                      "tests", projdir))));
            var module = new Module("testmod", new Suite(fs));
            var project = new TestProject("test", module);

            project.RootDirectory.Should().Be(projdir);
        }
コード例 #8
0
ファイル: CacheCleanerTest.cs プロジェクト: vigoo/bari
        public void DeletesCacheDirectory()
        {
            var be = new Mock<IBuilderEnumerator>();
            be.Setup(b => b.GetAllPersistentBuilders()).Returns(new Type[0]);

            var parameters = new Mock<ICleanParameters>();
            var predicates = new SoftCleanPredicates();
            var cdir = new TestFileSystemDirectory("cache");
            var cleaner = new CacheCleaner(new Lazy<IFileSystemDirectory>(() => cdir), be.Object, () => predicates);

            cdir.IsDeleted.Should().BeFalse();
            cleaner.Clean(parameters.Object);
            cdir.IsDeleted.Should().BeTrue();
        }
コード例 #9
0
        public void SetUp()
        {
            kernel = new StandardKernel();
            kernel.Bind<IFSRepositoryFingerprintFactory>().ToFactory();

            repository = new Mock<IFileSystemRepositoryAccess>();

            depRoot = new TestFileSystemDirectory("dep")
                {
                    Files = new[] {"x"}
                };
            repository.Setup(r => r.GetDirectory("test\\x")).Returns(depRoot);

        }
コード例 #10
0
        public void NoSourceDirectoryDoesNotCauseError()
        {
            var fs = new TestFileSystemDirectory("root",
                                     new TestFileSystemDirectory("abc"),
                                     new TestFileSystemDirectory("output"));

            var suite = new Suite(fs);

            suite.Modules.Should().BeEmpty();

            var discovery = new ModuleProjectDiscovery(fs);
            discovery.ExtendWithDiscoveries(suite);

            suite.Modules.Should().BeEmpty();
        }
コード例 #11
0
ファイル: CleanTest.cs プロジェクト: zvrana/bari
        public void SetUp()
        {
            kernel = new StandardKernel();
            Kernel.RegisterCoreBindings(kernel);
            kernel.Bind<IFileSystemDirectory>().ToConstant(new TestFileSystemDirectory("root")).WhenTargetHas
                <SuiteRootAttribute>();

            target = new TestFileSystemDirectory("target");
            kernel.Bind<IFileSystemDirectory>().ToConstant(target).WhenTargetHas
                <TargetRootAttribute>();

            kernel.Bind<IUserOutput>().To<TestUserOutput>();

            suite = kernel.Get<Suite>();
            suite.Name = "test suite";
        }
コード例 #12
0
ファイル: CachedBuilderTest.cs プロジェクト: zvrana/bari
        public void RunsBuilderOnlyOnceIfFingerprintRemains()
        {
            // Setting up the test
            var resultSet = new HashSet<TargetRelativePath>
                {
                    new TargetRelativePath(String.Empty, @"a\b\c"), 
                    new TargetRelativePath(String.Empty, @"c\d"), 
                    new TargetRelativePath(String.Empty, @"e")
                };

            var realBuilder = new Mock<IBuilder>();
            var realBuilderDeps = new Mock<IDependencies>();
            var initialFingerprint = new Mock<IDependencyFingerprint>();
            var buildContext = new Mock<IBuildContext>();
            var cache = new Mock<IBuildCache>();
            var targetDir = new TestFileSystemDirectory("target");

            realBuilderDeps.Setup(dep => dep.CreateFingerprint()).Returns(initialFingerprint.Object);
            
            realBuilder.Setup(b => b.Dependencies).Returns(realBuilderDeps.Object);
            realBuilder.Setup(b => b.Uid).Returns("");
            realBuilder.Setup(b => b.Run(buildContext.Object)).Returns(resultSet);

            // Creating the builder
            var cachedBuilder = new CachedBuilder(realBuilder.Object, cache.Object, targetDir);

            cachedBuilder.Dependencies.Should().Be(realBuilderDeps.Object);            
            
            // Running the builder for the first time
            var result1 = cachedBuilder.Run(buildContext.Object);

            // ..verifying
            result1.Should().BeEquivalentTo(resultSet);
            realBuilder.Verify(b => b.Run(buildContext.Object), Times.Once());

            // Modifying cache behavior
            cache.Setup(c => c.Contains(new BuildKey(realBuilder.Object.GetType(), ""), initialFingerprint.Object)).Returns(true);
            cache.Setup(c => c.Restore(new BuildKey(realBuilder.Object.GetType(), ""), targetDir)).Returns(resultSet);

            // Running the builder for the second time
            var result2 = cachedBuilder.Run(buildContext.Object);

            // ..verifying
            result2.Should().BeEquivalentTo(resultSet);
            realBuilder.Verify(b => b.Run(buildContext.Object), Times.Once());
        }
コード例 #13
0
ファイル: CacheCleanerTest.cs プロジェクト: vigoo/bari
        public void KeepsPersistentReferences()
        {
            var cdir = new TestFileSystemDirectory("cache",
                new[]
                {
                    new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"),
                    new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"),
                    new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"),
                    new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4")
                });

            var be = new Mock<IBuilderEnumerator>();
            be.Setup(b => b.GetAllPersistentBuilders()).Returns(new[] {typeof(PersistentReference)});

            var predicates = new SoftCleanPredicates();
            var cleaner = new CacheCleaner(new Lazy<IFileSystemDirectory>(() => cdir), be.Object, () => predicates);

            cdir.IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory) cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"))
                .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"))
                .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"))
                .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4"))
                .IsDeleted.Should().BeFalse();

            var parameters = new Mock<ICleanParameters>();
            parameters.SetupGet(p => p.KeepReferences).Returns(true);

            cleaner.Clean(parameters.Object);

            cdir.IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"))
                .IsDeleted.Should().BeTrue();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"))
                .IsDeleted.Should().BeTrue();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"))
                .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4"))
                .IsDeleted.Should().BeFalse();
        }
コード例 #14
0
 private static TestFileSystemDirectory CreateFsWithSourcesAndTests()
 {
     var fs = new TestFileSystemDirectory(
         "root",
         new TestFileSystemDirectory(
             "src",
             new TestFileSystemDirectory(
                 "Module1",
                 new TestFileSystemDirectory
                     ("Project11",
                      new TestFileSystemDirectory
                          ("cs",
                           new TestFileSystemDirectory
                               ("subdir")
                           {
                               Files = new[] { "source3.cs" }
                           })
                      {
                          Files = new[] { "source1.cs", "source2.cs" }
                      },
                      new TestFileSystemDirectory
                          ("fs")
                      {
                          Files = new[] { "a.fs" }
                      })),
             new TestFileSystemDirectory(
                 "Module2"),
             new TestFileSystemDirectory(
                 "Module3",
                 new TestFileSystemDirectory
                     ("Project31"),
                 new TestFileSystemDirectory
                     ("Project32"),
                 new TestFileSystemDirectory(
                     ("tests"),
                     new TestFileSystemDirectory("Project31.Test",
                         new TestFileSystemDirectory("cs")
                             {
                                 Files = new[] { "test1.cs"}
                             }),
                     new TestFileSystemDirectory("Project32.Test",
                         new TestFileSystemDirectory("cs")
                             {
                                 Files = new[] { "test2.cs, test3.cs" }
                             })))),
         new TestFileSystemDirectory("target"));
     return fs;
 }
コード例 #15
0
ファイル: ModuleTest.cs プロジェクト: zvrana/bari
        public void ModuleRootIsChildOfSuiteRoot()
        {
            var fs = new TestFileSystemDirectory(
                "root", new TestFileSystemDirectory(
                            "src", new TestFileSystemDirectory("test")));
            var module = new Module("test", new Suite(fs));

            module.RootDirectory.Should().Be(
                fs.GetChildDirectory("src").GetChildDirectory("test"));
        }
コード例 #16
0
ファイル: SourceSetFilteringTest.cs プロジェクト: zvrana/bari
 public void SetUp()
 {
     sourceSetRoot = new TestFileSystemDirectory("cpp");
 }