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 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_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_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")); } }
public void Test_initial_copy() { CopyDir(sourceDir1, targetDir, NextStorage()); FileAssert.AreEqual(sourceFile1, dir.CreatePath("target", "file1")); }