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")); }
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); }
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); }
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); }
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); }
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); }
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)); }