コード例 #1
0
 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"));
     }
 }
コード例 #2
0
 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"));
     }
 }
コード例 #3
0
 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"));
     }
 }
コード例 #4
0
 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"));
     }
 }
コード例 #5
0
 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.
     }
 }
コード例 #6
0
 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.
     }
 }
コード例 #7
0
 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"));
     }
 }
コード例 #8
0
 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"));
     }
 }