static void Main(string[] args) { string packageroot = "A"; string packagedescriptions = @"\pkgs\descriptions"; string packagesource = @"\src"; string testroot = @"C:\tmp"; GraphBuilder gb = new GraphBuilder($"{testroot}{packagedescriptions}"); if (gb.Graph.IsCyclic) { Console.WriteLine("Build graph contains cyclic dependencies."); return; } DirectoryInfo di = new DirectoryInfo($"{testroot}{packagesource}"); List <string> paths = di.GetDirectories().Select(d => d.FullName).ToList(); var task = Task.Run(async() => await PackageHasher.HashFoldersAsync(paths, testroot)); Dictionary <string, string> packageSourceHash = task.Result; PackageBuilder pb = new PackageBuilder(testroot); Dictionary <string, bool> buildResults = pb.Build(packageroot, $"{testroot}{packagesource}", packageSourceHash, gb.Graph); foreach (string key in buildResults.Keys) { Console.WriteLine($"package {key} build : {buildResults[key]}"); } }
public void SimpleBuilderTest3() { // // A, B, and C should build // string cwd = Directory.GetCurrentDirectory(); string testroot = $"{cwd}\\testcases\\simple3"; GraphBuilder gb = new GraphBuilder($"{testroot}{packagedescriptions}"); DirectoryInfo di = new DirectoryInfo($"{testroot}{packagesource}"); List <string> paths = di.GetDirectories().Select(d => d.FullName).ToList(); var task = Task.Run(async() => await PackageHasher.HashFoldersAsync(paths, testroot)); // package source to package source hash mapping Dictionary <string, string> packageSourceHash = task.Result; CleanCache(testroot); { CleanOutput(testroot); PackageBuilder pb = new PackageBuilder(testroot); Dictionary <string, bool> buildResults = pb.Build("A", $"{testroot}{packagesource}", packageSourceHash, gb.Graph); Assert.IsTrue(buildResults["A"]); Assert.IsTrue(buildResults["B"]); Assert.IsTrue(buildResults["C"]); } }
public void IntermediateBuilderTest1() { // // cache contains a pre built A and B. A and B do not build. C will build. // string cwd = Directory.GetCurrentDirectory(); string testroot = $"{cwd}\\testcases\\intermediate1"; GraphBuilder gb = new GraphBuilder($"{testroot}{packagedescriptions}"); DirectoryInfo di = new DirectoryInfo($"{testroot}{packagesource}"); List <string> paths = di.GetDirectories().Select(d => d.FullName).ToList(); var task = Task.Run(async() => await PackageHasher.HashFoldersAsync(paths, testroot)); // package source to package source hash mapping Dictionary <string, string> packageSourceHash = task.Result; List <string> excludeList = new List <string>(); //excludeList.Add(packageSourceHash["A"]); //excludeList.Add(packageSourceHash["B"]); CleanCache(testroot, excludeList); { CleanOutput(testroot); PackageBuilder pb = new PackageBuilder(testroot); Dictionary <string, bool> buildResults = pb.Build("A", $"{testroot}{packagesource}", packageSourceHash, gb.Graph); Assert.IsTrue(buildResults["A"]); Assert.IsTrue(buildResults["B"]); Assert.IsTrue(buildResults["C"]); Assert.IsTrue(buildResults["D"]); Assert.IsTrue(buildResults["E"]); } }
public void SimpleHashTest1() { string cwd = Directory.GetCurrentDirectory(); string root = $"{cwd}\\testcases\\simple1"; List <string> paths = new List <string>(); paths.Add($"{root}\\package1"); var task = Task.Run(async() => await PackageHasher.HashFoldersAsync(paths, root)); var result = task.Result; Assert.AreEqual(1, result.Keys.Count); Assert.IsTrue(result.ContainsKey("package1")); }
public void CompareHashTest1() { // compare hash of same folder and contents from 2 different roots. Should have the smae hash value. string cwd = Directory.GetCurrentDirectory(); string root1 = $"{cwd}\\testcases\\simple1"; string root2 = $"{cwd}\\testcases\\simple2"; List <string> paths1 = new List <string>(); paths1.Add($"{root1}\\package1"); List <string> paths2 = new List <string>(); paths2.Add($"{root2}\\package1"); var task1 = Task.Run(async() => await PackageHasher.HashFoldersAsync(paths1, root1)); var result1 = task1.Result; var task2 = Task.Run(async() => await PackageHasher.HashFoldersAsync(paths2, root2)); var result2 = task2.Result; Assert.AreEqual(result1["package1"], result2["package1"]); }