public void CircularAddUnroot() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\CircularAdd")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(0, reached.Count); HashSet <string> added = tracker.AddRootModuleIncremental(Path.Combine(temp.DirPath, "foo.rs")); CollectionAssert.Contains(added, Path.Combine(temp.DirPath, "bar.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"), Path.Combine(temp.DirPath, "foo.rs")); var rem = tracker.DowngradeModule(Path.Combine(temp.DirPath, "foo.rs")); CollectionAssert.Contains(rem.Orphans, Path.Combine(temp.DirPath, "foo.rs")); CollectionAssert.Contains(rem.Orphans, Path.Combine(temp.DirPath, "bar.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs")); } }
public void CircularHard() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\Circular")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(0, reached.Count); var added = tracker.AddRootModuleIncremental(Path.Combine(temp.DirPath, "foo.rs")); Assert.AreEqual(2, added.Count); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"), Path.Combine(temp.DirPath, "foo.rs")); var del = tracker.DeleteModule(Path.Combine(temp.DirPath, "foo.rs")); Assert.AreEqual(3, del.Orphans.Count); Assert.False(del.IsReferenced); File.Delete(Path.Combine(temp.DirPath, "foo.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs")); } }
public void ExplicitlyAddRemoveExisting() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\CircularDowngrade")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(2, reached.Count); HashSet <string> added = tracker.AddRootModuleIncremental(Path.Combine(temp.DirPath, "foo.rs")); Assert.AreEqual(0, added.Count); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"), Path.Combine(temp.DirPath, "foo.rs")); var del = tracker.DeleteModule(Path.Combine(temp.DirPath, "foo.rs")); Assert.AreEqual(1, del.Orphans.Count); Assert.True(del.IsReferenced); File.Delete(Path.Combine(temp.DirPath, "foo.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs")); } }
public void CircularAddRemove() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\CircularAdd")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(0, reached.Count); HashSet<string> added = tracker.AddRootModuleIncremental(Path.Combine(temp.DirPath, "foo.rs")); CollectionAssert.Contains(added, Path.Combine(temp.DirPath, "bar.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"), Path.Combine(temp.DirPath, "foo.rs")); var rem = tracker.DeleteModule(Path.Combine(temp.DirPath, "foo.rs")); File.Delete(Path.Combine(temp.DirPath, "foo.rs")); Assert.AreEqual(2, rem.Orphans.Count); CollectionAssert.Contains(rem.Orphans, Path.Combine(temp.DirPath, "bar.rs")); CollectionAssert.Contains(rem.Orphans, Path.Combine(temp.DirPath, "foo.rs")); Assert.False(rem.IsReferenced); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs")); } }
public void ResolveToAlreadyExisting() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\ResolveNonAuthImport")) { // main file points to bar/mod.rs. project gets loaded var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(1, reached.Count); CollectionAssert.Contains(reached, Path.Combine(temp.DirPath, @"bar\mod.rs")); // in the mean time bar.rs gets created File.Create(Path.Combine(temp.DirPath, "bar.rs")).Close(); // newly added baz.rs should import existing bar\mod.rs // instead of touching the disk var rootAdd = tracker.AddRootModuleIncremental(Path.Combine(temp.DirPath, "baz.rs")); Assert.AreEqual(0, rootAdd.Count); // WARNING: Dont ModelCheck(...) incrementally created ModTracker with the fresh ones. // In this one case mod name resolution will be slightly different. // It is working as indended. } }
public void ExplicitlyAddUnrootExisting() { using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\CircularDowngrade")) { var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs")); var reached = tracker.ExtractReachableAndMakeIncremental(); Assert.AreEqual(2, reached.Count); HashSet<string> added = tracker.AddRootModuleIncremental(Path.Combine(temp.DirPath, "foo.rs")); Assert.AreEqual(0, added.Count); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"), Path.Combine(temp.DirPath, "foo.rs")); var unr = tracker.DowngradeModule(Path.Combine(temp.DirPath, "foo.rs")); Assert.AreEqual(0, unr.Orphans.Count); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs")); var del = tracker.DeleteModule(Path.Combine(temp.DirPath, "foo.rs")); Assert.AreEqual(1, del.Orphans.Count); Assert.True(del.IsReferenced); File.Delete(Path.Combine(temp.DirPath, "foo.rs")); ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs")); } }