public void AddCircularRoot() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\Circular")) { File.Delete(Path.Combine(temp.DirPath, "foo.rs")); File.Create(Path.Combine(temp.DirPath, "foo.rs")).Close(); var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); tracker.AddRootModule(Path.Combine(temp.DirPath, "foo.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(0, reached.Count); File.Delete(Path.Combine(temp.DirPath, "foo.rs")); using (var stream = File.Open(Path.Combine(temp.DirPath, "foo.rs"), FileMode.CreateNew)) { using (var textStream = new StreamWriter(stream)) { textStream.Write("mod bar;"); } } var diff = tracker.Reparse(Path.Combine(temp.DirPath, "foo.rs")); // Return check Assert.AreEqual(2, diff.Added.Count); Assert.AreEqual(0, diff.Removed.Count); // Model check ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"), Path.Combine(temp.DirPath, "foo.rs")); } }
private static void ModelCheck(ModuleTracker t, string root, params string[] additionalRoots) { #if TEST // Dirty hack ModuleTracker model = new ModuleTracker(root); foreach (string r in additionalRoots) model.AddRootModule(r); model.ExtractReachableAndMakeIncremental(); Assert.True(t.IsEquivalnet(model)); #endif }
private static void ModelCheck(ModuleTracker t, string root, params string[] additionalRoots) { #if TEST // Dirty hack ModuleTracker model = new ModuleTracker(root); foreach (string r in additionalRoots) { model.AddRootModule(r); } model.ExtractReachableAndMakeIncremental(); Assert.True(t.IsEquivalnet(model)); #endif }
public void NonIncrRootRemoval() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\CircularMultiRoot")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "lib.rs")); tracker.AddRootModule(Path.Combine(temp.DirPath, "foo.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(1, reached.Count); HashSet <string> orphans = tracker.DowngradeModule(Path.Combine(temp.DirPath, "foo.rs")).Orphans; Assert.AreEqual(2, orphans.Count); ModelCheck(tracker, Path.Combine(temp.DirPath, "lib.rs")); } }
public void ClearCircularRoot() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\Circular")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); tracker.AddRootModule(Path.Combine(temp.DirPath, "foo.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(2, reached.Count); CollectionAssert.Contains(reached, Path.Combine(temp.DirPath, "baz.rs")); CollectionAssert.Contains(reached, Path.Combine(temp.DirPath, "bar.rs")); File.Delete(Path.Combine(temp.DirPath, "foo.rs")); File.Create(Path.Combine(temp.DirPath, "foo.rs")).Close(); var diff = tracker.Reparse(Path.Combine(temp.DirPath, "foo.rs")); // Return check Assert.AreEqual(0, diff.Added.Count); Assert.AreEqual(2, diff.Removed.Count); // Model check ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"), Path.Combine(temp.DirPath, "foo.rs")); } }
public void UpgradeAndDowngrade() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\CircularConnected")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); tracker.AddRootModule(Path.Combine(temp.DirPath, "foo.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(2, reached.Count); CollectionAssert.Contains(reached, Path.Combine(temp.DirPath, "baz.rs")); CollectionAssert.Contains(reached, Path.Combine(temp.DirPath, "bar.rs")); var res = tracker.DowngradeModule(Path.Combine(temp.DirPath, "foo.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs")); tracker.UpgradeModule(Path.Combine(temp.DirPath, "baz.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"), Path.Combine(temp.DirPath, "baz.rs")); res = tracker.DowngradeModule(Path.Combine(temp.DirPath, "baz.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs")); Assert.AreEqual(0, res.Orphans.Count); Assert.True(res.IsReferenced); } }
public void NonIncrRootRemoval() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\CircularMultiRoot")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "lib.rs")); tracker.AddRootModule(Path.Combine(temp.DirPath, "foo.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(1, reached.Count); HashSet<string> orphans = tracker.DowngradeModule(Path.Combine(temp.DirPath, "foo.rs")).Orphans; Assert.AreEqual(2, orphans.Count); ModelCheck(tracker, Path.Combine(temp.DirPath, "lib.rs")); } }