eden/fs/inodes/test/DiffTest.cpp
// Test file adds/removes/modifications with various orderings of names between
// the TreeInode entries and Tree entries.  This exercises the code that walks
// through the two entry lists comparing entry names.
Test file adds/removes/modifications with various orderings of names between
the TreeInode entries and Tree entries.  This exercises the code that walks
through the two entry lists comparing entry names.
Test file adds / removes / modifications with various orderings of names between the TreeInode entries and Tree entries . This exercises the code that walks through the two entry lists comparing entry names .
TEST(DiffTest, pathOrdering) {
  DiffTest test({
      {"one/bbb.txt", "test\n"},
      {"one/xxx.txt", "test\n"},
      {"two/aaa.txt", "test\n"},
      {"two/bbb.txt", "test\n"},
      {"two/mmm.txt", "test\n"},
      {"two/xxx.txt", "test\n"},
      {"two/zzz.txt", "test\n"},
      {"three/aaa.txt", "test\n"},
      {"three/bbb.txt", "test\n"},
      {"three/mmm.txt", "test\n"},
      {"three/xxx.txt", "test\n"},
      {"three/zzz.txt", "test\n"},
  });
  auto& mount = test.getMount();
  mount.addFile("one/aaa.txt", "test");
  mount.addFile("one/mmm.txt", "test");
  mount.addFile("one/zzz.txt", "test");
  mount.deleteFile("two/aaa.txt");
  mount.deleteFile("two/mmm.txt");
  mount.deleteFile("two/zzz.txt");
  mount.overwriteFile("three/aaa.txt", "updated contents\n");
  mount.overwriteFile("three/mmm.txt", "updated contents\n");
  mount.overwriteFile("three/zzz.txt", "updated contents\n");
  auto result = test.diff();
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(),
      UnorderedElementsAre(
          RelativePath{"one/aaa.txt"},
          RelativePath{"one/mmm.txt"},
          RelativePath{"one/zzz.txt"}));
  EXPECT_THAT(result.getIgnored(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getRemoved(),
      UnorderedElementsAre(
          RelativePath{"two/aaa.txt"},
          RelativePath{"two/mmm.txt"},
          RelativePath{"two/zzz.txt"}));
  EXPECT_THAT(
      result.getModified(),
      UnorderedElementsAre(
          RelativePath{"three/aaa.txt"},
          RelativePath{"three/mmm.txt"},
          RelativePath{"three/zzz.txt"}));
}
TEST ( DiffTest , pathOrdering ) { DiffTest test ( { { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , } ) ; auto & mount = test . getMount ( ) ; mount . addFile ( " " , " " ) ; mount . addFile ( " " , " " ) ; mount . addFile ( " " , " " ) ; mount . deleteFile ( " " ) ; mount . deleteFile ( " " ) ; mount . deleteFile ( " " ) ; mount . overwriteFile ( " " , " \n " ) ; mount . overwriteFile ( " " , " \n " ) ; mount . overwriteFile ( " " , " \n " ) ; auto result = test . diff ( ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getRemoved ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getModified ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } , RelativePath { " " } ) ) ; }
Test file adds/removes/modifications with various orderings of names between
the TreeInode entries and Tree entries.
Test file adds / removes / modifications with various orderings of names between the TreeInode entries and Tree entries .
// In directory one: // Add a file so that the TreeInode has the first entry, with no // corresponding entry in the source control tree. // Add a file in the middle of the two entries in the source control Tree // Add a file so that the TreeInode has the last entry, with no // corresponding entry in the source control tree. // In directory two, remove the opposite entries, so that the source control // Tree has the first and last entries. // In directory three, overwrite these 3 entries, so that the first and last // files are modified, plus one in the middle. // Perform the diff