public void Test_skip_second_copy() { CopyDir(sourceDir1, targetDir, NextStorage()); dir.CreateFile("modified", "sourceDir1", "file1"); CopyDir(sourceDir1, targetDir, NextStorage()); var originalSourceFile = dir.CreateFile("foo", "original"); FileAssert.AreEqual(originalSourceFile, dir.CreatePath("target", "file1")); }
public void TestExecute_executes_dependencies() { using (var tmpDir = new TmpDir()) { var fooTask = MockBuildTasks.GenerateFile("createFoo", "foo", "42").Object; var barTask = MockBuildTasks.GenerateFile("createBar", "bar", "9001", fooTask).Object; Builder.Execute(tmpDir.Path, tmpDir.CreateDir("out"), tmpDir.CreateDir(".bud"), barTask); FileAssert.AreEqual(tmpDir.CreateFile("42"), tmpDir.CreatePath("out", "foo")); FileAssert.AreEqual(tmpDir.CreateFile("9001"), tmpDir.CreatePath("out", "bar")); } }
public void Signature_of_file() { using (var dir = new TmpDir()) { var fooFile = dir.CreateFile("9001", "foo.txt"); var barFile = dir.CreateFile("42", "bar.txt"); AreEqual(new Sha256Signer().Digest(fooFile) .Digest(Encoding.UTF8.GetBytes("9001")) .Digest(barFile) .Digest(Encoding.UTF8.GetBytes("42")) .Finish() .Signature .ToArray(), new Sha256Signer().DigestSources(new[] { fooFile, barFile }).Finish().Signature.ToArray()); } }
public void TestExecute_places_output_into_OutputDir() { using (var tmpDir = new TmpDir()) { var fooTask = MockBuildTasks.GenerateFile("createFoo", "foo", "42").Object; Builder.Execute(tmpDir.Path, tmpDir.CreateDir("out"), tmpDir.CreateDir(".bud"), fooTask); FileAssert.AreEqual(tmpDir.CreateFile("42"), tmpDir.CreatePath("out", "foo")); } }
public void SetUp() { dir = new TmpDir(); sourceDir1 = dir.CreateDir("sourceDir1"); sourceDir2 = dir.CreateDir("sourceDir2"); sourceFile1 = dir.CreateFile("foo", "sourceDir1", "file1"); targetDir = dir.CreatePath("target"); storage = new BuildStorage(targetDir, new Dictionary <Uri, byte[]>()); }
public void TestExecute_passes_the_source_dir_to_tasks() { using (var tmpDir = new TmpDir()) { var sourceDir = tmpDir.CreateDir("src"); var outputDir = tmpDir.CreatePath("out"); var metaDir = tmpDir.CreatePath(".bud"); var sourceFile = tmpDir.CreateFile("42", "src", "foo"); var task1Mock = MockBuildTasks.CopySourceFile("task1", "foo", "bar"); Builder.Execute(sourceDir, outputDir, metaDir, task1Mock.Object); FileAssert.AreEqual(sourceFile, Path.Combine(outputDir, "bar")); } }
public void TestExecute_does_not_have_race_conditions() { for (int i = 0; i < 5; i++) { using (var tmpDir = new TmpDir()) { var sourceDir = tmpDir.CreateDir("src"); var outputDir = tmpDir.CreatePath("out"); var metaDir = tmpDir.CreatePath(".bud"); var generatedFiles = Enumerable.Range(0, 10).Select(idx => $"file_{idx}").ToList(); var fileGenerators = generatedFiles.Select(file => MockBuildTasks.GenerateFile(file, file, file).Object); Builder.Execute(sourceDir, outputDir, metaDir, fileGenerators); foreach (var generatedFile in generatedFiles) { FileAssert.AreEqual(tmpDir.CreateFile(generatedFile), Path.Combine(outputDir, generatedFile)); } } } }
public void TestExecute_cleans_unfinished_directories_before_starting_the_build() { using (var tmpDir = new TmpDir()) { var partialTask = MockBuildTasks.NoOp("task1") .WithExecuteAction((sourceDir, outputDir, deps) => { File.WriteAllText(Path.Combine(outputDir, "foo"), "42"); throw new Exception("Test exception"); }); try { Builder.Execute(tmpDir.Path, tmpDir.CreateDir("out"), tmpDir.CreateDir(".bud"), partialTask.Object); } catch (Exception) { // ignored } var fullTask = MockBuildTasks.NoOp("task1") .WithExecuteAction((sourceDir, outputDir, deps) => File.WriteAllText(Path.Combine(outputDir, "bar"), "9001")); Builder.Execute(tmpDir.Path, tmpDir.CreateDir("out"), tmpDir.CreateDir(".bud"), fullTask.Object); FileAssert.AreEqual(tmpDir.CreateFile("9001"), tmpDir.CreatePath("out", "bar")); FileAssert.DoesNotExist(tmpDir.CreatePath("out", "foo")); } }