Exemplo n.º 1
0
        public void Hardlink()
        {
            var root = new TestRoot
            {
                new TestDirectory("dir")
                {
                    new TestFile("file"),
                    new TestFile("executable")
                    {
                        IsExecutable = true
                    },
                    new TestSymlink("symlink", "target")
                }
            };

            root.Build(SourceDirectory);

            FileUtils.EnableWriteProtection(SourceDirectory); // Hard linking logic should work around write-protection by temporarily removing it
            try
            {
                new CloneDirectory(SourceDirectory, TargetDirectory)
                {
                    UseHardlinks = true
                }.Run();
            }
            finally
            {
                FileUtils.DisableWriteProtection(SourceDirectory);
            }

            root.Verify(TargetDirectory);
            FileUtils.AreHardlinked(Path.Combine(SourceDirectory, "dir", "file"), Path.Combine(TargetDirectory, "dir", "file"));
            FileUtils.AreHardlinked(Path.Combine(SourceDirectory, "dir", "executable"), Path.Combine(TargetDirectory, "dir", "executable"));
        }
Exemplo n.º 2
0
        private string DeployPackage(string id, TestRoot root)
        {
            string path = Path.Combine(_tempDir, id);

            root.Build(path);
            ManifestTest.CreateDotFile(path, ManifestFormat.FromPrefix(id), _handler);
            FileUtils.EnableWriteProtection(path);
            return(path);
        }
Exemplo n.º 3
0
        private static void Test(TestRoot root, params ManifestNode[] expected)
        {
            using var sourceDirectory = new TemporaryDirectory("0install-unit-tests");
            root.Build(sourceDirectory);
            var generator = new ManifestGenerator(sourceDirectory, ManifestFormat.Sha1New);

            generator.Run();
            generator.Manifest.Should().Equal(expected);
        }
Exemplo n.º 4
0
        public void OverwriteWithSymlink()
        {
            var root = new TestRoot {
                new TestSymlink("fileA", "target")
            };

            root.Build(SourceDirectory);
            new TestRoot {
                new TestFile("fileB")
            }.Build(TargetDirectory);

            new CloneDirectory(SourceDirectory, TargetDirectory).Run();

            root.Verify(TargetDirectory);
        }
Exemplo n.º 5
0
        public void OverwriteFile()
        {
            var root = new TestRoot {
                new TestFile("fileA")
            };

            root.Build(SourceDirectory);
            new TestRoot {
                new TestFile("fileB")
                {
                    LastWrite = new DateTime(2000, 2, 2), Contents = "wrong", IsExecutable = true
                }
            }.Build(TargetDirectory);

            new CloneDirectory(SourceDirectory, TargetDirectory).Run();

            root.Verify(TargetDirectory);
        }
Exemplo n.º 6
0
        public void Copy()
        {
            var root = new TestRoot
            {
                new TestDirectory("dir")
                {
                    new TestFile("file"),
                    new TestFile("executable")
                    {
                        IsExecutable = true
                    },
                    new TestSymlink("symlink", "target")
                }
            };

            root.Build(SourceDirectory);

            new CloneDirectory(SourceDirectory, TargetDirectory).Run();

            root.Verify(TargetDirectory);
        }
Exemplo n.º 7
0
        public void CopySuffix()
        {
            var root = new TestRoot
            {
                new TestDirectory("dir")
                {
                    new TestFile("file"),
                    new TestFile("executable")
                    {
                        IsExecutable = true
                    },
                    new TestSymlink("symlink", "target")
                }
            };

            root.Build(SourceDirectory);

            new CloneDirectory(SourceDirectory, TargetDirectory)
            {
                TargetSuffix = "suffix"
            }.Run();

            root.Verify(Path.Combine(TargetDirectory, "suffix"));
        }
 protected Stream BuildArchive(TestRoot root)
 {
     using var tempDir = new TemporaryDirectory("0install-unit-tests");
     root.Build(tempDir);
     return(BuildArchive(tempDir));
 }