Пример #1
0
 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"));
     }
 }
Пример #2
0
 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"));
     }
 }
Пример #3
0
 public void RemoveZombie()
 {
     using (TemporaryDirectory temp = Utils.LoadResourceDirectory(@"Internal\SimpleChain"))
     {
         var tracker = new ModuleTracker(Path.Combine(temp.DirPath, "main.rs"));
         var reached = tracker.ExtractReachableAndMakeIncremental();
         Assert.AreEqual(2, reached.Count);
         File.Delete(Path.Combine(temp.DirPath, "foo.rs"));
         File.Delete(Path.Combine(temp.DirPath, "baz.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(1, diff.Added.Count);
         Assert.AreEqual(1, diff.Removed.Count);
         // Model check
         ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"));
         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 baz;");
             }
         }
         diff = tracker.Reparse(Path.Combine(temp.DirPath, "foo.rs"));
         // Return check
         Assert.AreEqual(1, diff.Added.Count);
         Assert.AreEqual(1, diff.Removed.Count);
         // Model check
         ModelCheck(tracker, Path.Combine(temp.DirPath, "main.rs"));
     }
 }
Пример #4
0
 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"));
     }
 }