changes_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. package archive // import "github.com/docker/docker/pkg/archive"
  2. import (
  3. "io/ioutil"
  4. "os"
  5. "os/exec"
  6. "path"
  7. "path/filepath"
  8. "runtime"
  9. "sort"
  10. "strconv"
  11. "strings"
  12. "syscall"
  13. "testing"
  14. "time"
  15. "github.com/Microsoft/hcsshim/osversion"
  16. "github.com/docker/docker/pkg/parsers/kernel"
  17. "github.com/docker/docker/pkg/system"
  18. "gotest.tools/v3/assert"
  19. "gotest.tools/v3/skip"
  20. )
  21. func max(x, y int) int {
  22. if x >= y {
  23. return x
  24. }
  25. return y
  26. }
  27. func copyDir(src, dst string) error {
  28. if runtime.GOOS != "windows" {
  29. return exec.Command("cp", "-a", src, dst).Run()
  30. }
  31. // Could have used xcopy src dst /E /I /H /Y /B. However, xcopy has the
  32. // unfortunate side effect of not preserving timestamps of newly created
  33. // directories in the target directory, so we don't get accurate changes.
  34. // Use robocopy instead. Note this isn't available in microsoft/nanoserver.
  35. // But it has gotchas. See https://weblogs.sqlteam.com/robv/archive/2010/02/17/61106.aspx
  36. err := exec.Command("robocopy", filepath.FromSlash(src), filepath.FromSlash(dst), "/SL", "/COPYALL", "/MIR").Run()
  37. if exiterr, ok := err.(*exec.ExitError); ok {
  38. if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
  39. if status.ExitStatus()&24 == 0 {
  40. return nil
  41. }
  42. }
  43. }
  44. return err
  45. }
  46. type FileType uint32
  47. const (
  48. Regular FileType = iota
  49. Dir
  50. Symlink
  51. )
  52. type FileData struct {
  53. filetype FileType
  54. path string
  55. contents string
  56. permissions os.FileMode
  57. }
  58. func createSampleDir(t *testing.T, root string) {
  59. files := []FileData{
  60. {filetype: Regular, path: "file1", contents: "file1\n", permissions: 0600},
  61. {filetype: Regular, path: "file2", contents: "file2\n", permissions: 0666},
  62. {filetype: Regular, path: "file3", contents: "file3\n", permissions: 0404},
  63. {filetype: Regular, path: "file4", contents: "file4\n", permissions: 0600},
  64. {filetype: Regular, path: "file5", contents: "file5\n", permissions: 0600},
  65. {filetype: Regular, path: "file6", contents: "file6\n", permissions: 0600},
  66. {filetype: Regular, path: "file7", contents: "file7\n", permissions: 0600},
  67. {filetype: Dir, path: "dir1", contents: "", permissions: 0740},
  68. {filetype: Regular, path: "dir1/file1-1", contents: "file1-1\n", permissions: 01444},
  69. {filetype: Regular, path: "dir1/file1-2", contents: "file1-2\n", permissions: 0666},
  70. {filetype: Dir, path: "dir2", contents: "", permissions: 0700},
  71. {filetype: Regular, path: "dir2/file2-1", contents: "file2-1\n", permissions: 0666},
  72. {filetype: Regular, path: "dir2/file2-2", contents: "file2-2\n", permissions: 0666},
  73. {filetype: Dir, path: "dir3", contents: "", permissions: 0700},
  74. {filetype: Regular, path: "dir3/file3-1", contents: "file3-1\n", permissions: 0666},
  75. {filetype: Regular, path: "dir3/file3-2", contents: "file3-2\n", permissions: 0666},
  76. {filetype: Dir, path: "dir4", contents: "", permissions: 0700},
  77. {filetype: Regular, path: "dir4/file3-1", contents: "file4-1\n", permissions: 0666},
  78. {filetype: Regular, path: "dir4/file3-2", contents: "file4-2\n", permissions: 0666},
  79. {filetype: Symlink, path: "symlink1", contents: "target1", permissions: 0666},
  80. {filetype: Symlink, path: "symlink2", contents: "target2", permissions: 0666},
  81. {filetype: Symlink, path: "symlink3", contents: root + "/file1", permissions: 0666},
  82. {filetype: Symlink, path: "symlink4", contents: root + "/symlink3", permissions: 0666},
  83. {filetype: Symlink, path: "dirSymlink", contents: root + "/dir1", permissions: 0740},
  84. }
  85. provisionSampleDir(t, root, files)
  86. }
  87. func provisionSampleDir(t *testing.T, root string, files []FileData) {
  88. now := time.Now()
  89. for _, info := range files {
  90. p := path.Join(root, info.path)
  91. if info.filetype == Dir {
  92. err := os.MkdirAll(p, info.permissions)
  93. assert.NilError(t, err)
  94. } else if info.filetype == Regular {
  95. err := ioutil.WriteFile(p, []byte(info.contents), info.permissions)
  96. assert.NilError(t, err)
  97. } else if info.filetype == Symlink {
  98. err := os.Symlink(info.contents, p)
  99. assert.NilError(t, err)
  100. }
  101. if info.filetype != Symlink {
  102. // Set a consistent ctime, atime for all files and dirs
  103. err := system.Chtimes(p, now, now)
  104. assert.NilError(t, err)
  105. }
  106. }
  107. }
  108. func TestChangeString(t *testing.T) {
  109. modifyChange := Change{"change", ChangeModify}
  110. toString := modifyChange.String()
  111. if toString != "C change" {
  112. t.Fatalf("String() of a change with ChangeModify Kind should have been %s but was %s", "C change", toString)
  113. }
  114. addChange := Change{"change", ChangeAdd}
  115. toString = addChange.String()
  116. if toString != "A change" {
  117. t.Fatalf("String() of a change with ChangeAdd Kind should have been %s but was %s", "A change", toString)
  118. }
  119. deleteChange := Change{"change", ChangeDelete}
  120. toString = deleteChange.String()
  121. if toString != "D change" {
  122. t.Fatalf("String() of a change with ChangeDelete Kind should have been %s but was %s", "D change", toString)
  123. }
  124. }
  125. func TestChangesWithNoChanges(t *testing.T) {
  126. rwLayer, err := ioutil.TempDir("", "docker-changes-test")
  127. assert.NilError(t, err)
  128. defer os.RemoveAll(rwLayer)
  129. layer, err := ioutil.TempDir("", "docker-changes-test-layer")
  130. assert.NilError(t, err)
  131. defer os.RemoveAll(layer)
  132. createSampleDir(t, layer)
  133. changes, err := Changes([]string{layer}, rwLayer)
  134. assert.NilError(t, err)
  135. if len(changes) != 0 {
  136. t.Fatalf("Changes with no difference should have detect no changes, but detected %d", len(changes))
  137. }
  138. }
  139. func TestChangesWithChanges(t *testing.T) {
  140. // Mock the readonly layer
  141. layer, err := ioutil.TempDir("", "docker-changes-test-layer")
  142. assert.NilError(t, err)
  143. defer os.RemoveAll(layer)
  144. createSampleDir(t, layer)
  145. os.MkdirAll(path.Join(layer, "dir1/subfolder"), 0740)
  146. // Mock the RW layer
  147. rwLayer, err := ioutil.TempDir("", "docker-changes-test")
  148. assert.NilError(t, err)
  149. defer os.RemoveAll(rwLayer)
  150. // Create a folder in RW layer
  151. dir1 := path.Join(rwLayer, "dir1")
  152. os.MkdirAll(dir1, 0740)
  153. deletedFile := path.Join(dir1, ".wh.file1-2")
  154. ioutil.WriteFile(deletedFile, []byte{}, 0600)
  155. modifiedFile := path.Join(dir1, "file1-1")
  156. ioutil.WriteFile(modifiedFile, []byte{0x00}, 01444)
  157. // Let's add a subfolder for a newFile
  158. subfolder := path.Join(dir1, "subfolder")
  159. os.MkdirAll(subfolder, 0740)
  160. newFile := path.Join(subfolder, "newFile")
  161. ioutil.WriteFile(newFile, []byte{}, 0740)
  162. changes, err := Changes([]string{layer}, rwLayer)
  163. assert.NilError(t, err)
  164. expectedChanges := []Change{
  165. {filepath.FromSlash("/dir1"), ChangeModify},
  166. {filepath.FromSlash("/dir1/file1-1"), ChangeModify},
  167. {filepath.FromSlash("/dir1/file1-2"), ChangeDelete},
  168. {filepath.FromSlash("/dir1/subfolder"), ChangeModify},
  169. {filepath.FromSlash("/dir1/subfolder/newFile"), ChangeAdd},
  170. }
  171. checkChanges(expectedChanges, changes, t)
  172. }
  173. // See https://github.com/docker/docker/pull/13590
  174. func TestChangesWithChangesGH13590(t *testing.T) {
  175. // TODO Windows. Needs further investigation to identify the failure
  176. if runtime.GOOS == "windows" {
  177. t.Skip("needs more investigation")
  178. }
  179. baseLayer, err := ioutil.TempDir("", "docker-changes-test.")
  180. assert.NilError(t, err)
  181. defer os.RemoveAll(baseLayer)
  182. dir3 := path.Join(baseLayer, "dir1/dir2/dir3")
  183. os.MkdirAll(dir3, 07400)
  184. file := path.Join(dir3, "file.txt")
  185. ioutil.WriteFile(file, []byte("hello"), 0666)
  186. layer, err := ioutil.TempDir("", "docker-changes-test2.")
  187. assert.NilError(t, err)
  188. defer os.RemoveAll(layer)
  189. // Test creating a new file
  190. if err := copyDir(baseLayer+"/dir1", layer+"/"); err != nil {
  191. t.Fatalf("Cmd failed: %q", err)
  192. }
  193. os.Remove(path.Join(layer, "dir1/dir2/dir3/file.txt"))
  194. file = path.Join(layer, "dir1/dir2/dir3/file1.txt")
  195. ioutil.WriteFile(file, []byte("bye"), 0666)
  196. changes, err := Changes([]string{baseLayer}, layer)
  197. assert.NilError(t, err)
  198. expectedChanges := []Change{
  199. {"/dir1/dir2/dir3", ChangeModify},
  200. {"/dir1/dir2/dir3/file1.txt", ChangeAdd},
  201. }
  202. checkChanges(expectedChanges, changes, t)
  203. // Now test changing a file
  204. layer, err = ioutil.TempDir("", "docker-changes-test3.")
  205. assert.NilError(t, err)
  206. defer os.RemoveAll(layer)
  207. if err := copyDir(baseLayer+"/dir1", layer+"/"); err != nil {
  208. t.Fatalf("Cmd failed: %q", err)
  209. }
  210. file = path.Join(layer, "dir1/dir2/dir3/file.txt")
  211. ioutil.WriteFile(file, []byte("bye"), 0666)
  212. changes, err = Changes([]string{baseLayer}, layer)
  213. assert.NilError(t, err)
  214. expectedChanges = []Change{
  215. {"/dir1/dir2/dir3/file.txt", ChangeModify},
  216. }
  217. checkChanges(expectedChanges, changes, t)
  218. }
  219. // Create a directory, copy it, make sure we report no changes between the two
  220. func TestChangesDirsEmpty(t *testing.T) {
  221. // Note we parse kernel.GetKernelVersion rather than system.GetOSVersion
  222. // as test binaries aren't manifested, so would otherwise report the wrong
  223. // build number.
  224. if runtime.GOOS == "windows" {
  225. v, err := kernel.GetKernelVersion()
  226. assert.NilError(t, err)
  227. build, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0])
  228. if build >= osversion.V19H1 {
  229. t.Skip("FIXME: broken on Windows 1903 and up; see #39846")
  230. }
  231. }
  232. src, err := ioutil.TempDir("", "docker-changes-test")
  233. assert.NilError(t, err)
  234. defer os.RemoveAll(src)
  235. createSampleDir(t, src)
  236. dst := src + "-copy"
  237. err = copyDir(src, dst)
  238. assert.NilError(t, err)
  239. defer os.RemoveAll(dst)
  240. changes, err := ChangesDirs(dst, src)
  241. assert.NilError(t, err)
  242. if len(changes) != 0 {
  243. t.Fatalf("Reported changes for identical dirs: %v", changes)
  244. }
  245. os.RemoveAll(src)
  246. os.RemoveAll(dst)
  247. }
  248. func mutateSampleDir(t *testing.T, root string) {
  249. // Remove a regular file
  250. err := os.RemoveAll(path.Join(root, "file1"))
  251. assert.NilError(t, err)
  252. // Remove a directory
  253. err = os.RemoveAll(path.Join(root, "dir1"))
  254. assert.NilError(t, err)
  255. // Remove a symlink
  256. err = os.RemoveAll(path.Join(root, "symlink1"))
  257. assert.NilError(t, err)
  258. // Rewrite a file
  259. err = ioutil.WriteFile(path.Join(root, "file2"), []byte("fileNN\n"), 0777)
  260. assert.NilError(t, err)
  261. // Replace a file
  262. err = os.RemoveAll(path.Join(root, "file3"))
  263. assert.NilError(t, err)
  264. err = ioutil.WriteFile(path.Join(root, "file3"), []byte("fileMM\n"), 0404)
  265. assert.NilError(t, err)
  266. // Touch file
  267. err = system.Chtimes(path.Join(root, "file4"), time.Now().Add(time.Second), time.Now().Add(time.Second))
  268. assert.NilError(t, err)
  269. // Replace file with dir
  270. err = os.RemoveAll(path.Join(root, "file5"))
  271. assert.NilError(t, err)
  272. err = os.MkdirAll(path.Join(root, "file5"), 0666)
  273. assert.NilError(t, err)
  274. // Create new file
  275. err = ioutil.WriteFile(path.Join(root, "filenew"), []byte("filenew\n"), 0777)
  276. assert.NilError(t, err)
  277. // Create new dir
  278. err = os.MkdirAll(path.Join(root, "dirnew"), 0766)
  279. assert.NilError(t, err)
  280. // Create a new symlink
  281. err = os.Symlink("targetnew", path.Join(root, "symlinknew"))
  282. assert.NilError(t, err)
  283. // Change a symlink
  284. err = os.RemoveAll(path.Join(root, "symlink2"))
  285. assert.NilError(t, err)
  286. err = os.Symlink("target2change", path.Join(root, "symlink2"))
  287. assert.NilError(t, err)
  288. // Replace dir with file
  289. err = os.RemoveAll(path.Join(root, "dir2"))
  290. assert.NilError(t, err)
  291. err = ioutil.WriteFile(path.Join(root, "dir2"), []byte("dir2\n"), 0777)
  292. assert.NilError(t, err)
  293. // Touch dir
  294. err = system.Chtimes(path.Join(root, "dir3"), time.Now().Add(time.Second), time.Now().Add(time.Second))
  295. assert.NilError(t, err)
  296. }
  297. func TestChangesDirsMutated(t *testing.T) {
  298. // Note we parse kernel.GetKernelVersion rather than system.GetOSVersion
  299. // as test binaries aren't manifested, so would otherwise report the wrong
  300. // build number.
  301. if runtime.GOOS == "windows" {
  302. v, err := kernel.GetKernelVersion()
  303. assert.NilError(t, err)
  304. build, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0])
  305. if build >= osversion.V19H1 {
  306. t.Skip("FIXME: broken on Windows 1903 and up; see #39846")
  307. }
  308. }
  309. src, err := ioutil.TempDir("", "docker-changes-test")
  310. assert.NilError(t, err)
  311. createSampleDir(t, src)
  312. dst := src + "-copy"
  313. err = copyDir(src, dst)
  314. assert.NilError(t, err)
  315. defer os.RemoveAll(src)
  316. defer os.RemoveAll(dst)
  317. mutateSampleDir(t, dst)
  318. changes, err := ChangesDirs(dst, src)
  319. assert.NilError(t, err)
  320. sort.Sort(changesByPath(changes))
  321. expectedChanges := []Change{
  322. {filepath.FromSlash("/dir1"), ChangeDelete},
  323. {filepath.FromSlash("/dir2"), ChangeModify},
  324. }
  325. // Note there is slight difference between the Linux and Windows
  326. // implementations here. Due to https://github.com/moby/moby/issues/9874,
  327. // and the fix at https://github.com/moby/moby/pull/11422, Linux does not
  328. // consider a change to the directory time as a change. Windows on NTFS
  329. // does. See https://github.com/moby/moby/pull/37982 for more information.
  330. //
  331. // Note also: https://github.com/moby/moby/pull/37982#discussion_r223523114
  332. // that differences are ordered in the way the test is currently written, hence
  333. // this is in the middle of the list of changes rather than at the start or
  334. // end. Potentially can be addressed later.
  335. if runtime.GOOS == "windows" {
  336. expectedChanges = append(expectedChanges, Change{filepath.FromSlash("/dir3"), ChangeModify})
  337. }
  338. expectedChanges = append(expectedChanges, []Change{
  339. {filepath.FromSlash("/dirnew"), ChangeAdd},
  340. {filepath.FromSlash("/file1"), ChangeDelete},
  341. {filepath.FromSlash("/file2"), ChangeModify},
  342. {filepath.FromSlash("/file3"), ChangeModify},
  343. {filepath.FromSlash("/file4"), ChangeModify},
  344. {filepath.FromSlash("/file5"), ChangeModify},
  345. {filepath.FromSlash("/filenew"), ChangeAdd},
  346. {filepath.FromSlash("/symlink1"), ChangeDelete},
  347. {filepath.FromSlash("/symlink2"), ChangeModify},
  348. {filepath.FromSlash("/symlinknew"), ChangeAdd},
  349. }...)
  350. for i := 0; i < max(len(changes), len(expectedChanges)); i++ {
  351. if i >= len(expectedChanges) {
  352. t.Fatalf("unexpected change %s\n", changes[i].String())
  353. }
  354. if i >= len(changes) {
  355. t.Fatalf("no change for expected change %s\n", expectedChanges[i].String())
  356. }
  357. if changes[i].Path == expectedChanges[i].Path {
  358. if changes[i] != expectedChanges[i] {
  359. t.Fatalf("Wrong change for %s, expected %s, got %s\n", changes[i].Path, changes[i].String(), expectedChanges[i].String())
  360. }
  361. } else if changes[i].Path < expectedChanges[i].Path {
  362. t.Fatalf("unexpected change %q %q\n", changes[i].String(), expectedChanges[i].Path)
  363. } else {
  364. t.Fatalf("no change for expected change %s != %s\n", expectedChanges[i].String(), changes[i].String())
  365. }
  366. }
  367. }
  368. func TestApplyLayer(t *testing.T) {
  369. // TODO Windows. This is very close to working, but it fails with changes
  370. // to \symlinknew and \symlink2. The destination has an updated
  371. // Access/Modify/Change/Birth date to the source (~3/100th sec different).
  372. // Needs further investigation as to why, but I currently believe this is
  373. // just the way NTFS works. I don't think it's a bug in this test or archive.
  374. if runtime.GOOS == "windows" {
  375. t.Skip("needs further investigation")
  376. }
  377. src, err := ioutil.TempDir("", "docker-changes-test")
  378. assert.NilError(t, err)
  379. createSampleDir(t, src)
  380. defer os.RemoveAll(src)
  381. dst := src + "-copy"
  382. err = copyDir(src, dst)
  383. assert.NilError(t, err)
  384. mutateSampleDir(t, dst)
  385. defer os.RemoveAll(dst)
  386. changes, err := ChangesDirs(dst, src)
  387. assert.NilError(t, err)
  388. layer, err := ExportChanges(dst, changes, nil, nil)
  389. assert.NilError(t, err)
  390. layerCopy, err := NewTempArchive(layer, "")
  391. assert.NilError(t, err)
  392. _, err = ApplyLayer(src, layerCopy)
  393. assert.NilError(t, err)
  394. changes2, err := ChangesDirs(src, dst)
  395. assert.NilError(t, err)
  396. if len(changes2) != 0 {
  397. t.Fatalf("Unexpected differences after reapplying mutation: %v", changes2)
  398. }
  399. }
  400. func TestChangesSizeWithHardlinks(t *testing.T) {
  401. // TODO Windows. Needs further investigation. Likely in ChangeSizes not
  402. // coping correctly with hardlinks on Windows.
  403. if runtime.GOOS == "windows" {
  404. t.Skip("needs further investigation")
  405. }
  406. srcDir, err := ioutil.TempDir("", "docker-test-srcDir")
  407. assert.NilError(t, err)
  408. defer os.RemoveAll(srcDir)
  409. destDir, err := ioutil.TempDir("", "docker-test-destDir")
  410. assert.NilError(t, err)
  411. defer os.RemoveAll(destDir)
  412. creationSize, err := prepareUntarSourceDirectory(100, destDir, true)
  413. assert.NilError(t, err)
  414. changes, err := ChangesDirs(destDir, srcDir)
  415. assert.NilError(t, err)
  416. got := ChangesSize(destDir, changes)
  417. if got != int64(creationSize) {
  418. t.Errorf("Expected %d bytes of changes, got %d", creationSize, got)
  419. }
  420. }
  421. func TestChangesSizeWithNoChanges(t *testing.T) {
  422. size := ChangesSize("/tmp", nil)
  423. if size != 0 {
  424. t.Fatalf("ChangesSizes with no changes should be 0, was %d", size)
  425. }
  426. }
  427. func TestChangesSizeWithOnlyDeleteChanges(t *testing.T) {
  428. changes := []Change{
  429. {Path: "deletedPath", Kind: ChangeDelete},
  430. }
  431. size := ChangesSize("/tmp", changes)
  432. if size != 0 {
  433. t.Fatalf("ChangesSizes with only delete changes should be 0, was %d", size)
  434. }
  435. }
  436. func TestChangesSize(t *testing.T) {
  437. parentPath, err := ioutil.TempDir("", "docker-changes-test")
  438. assert.NilError(t, err)
  439. defer os.RemoveAll(parentPath)
  440. addition := path.Join(parentPath, "addition")
  441. err = ioutil.WriteFile(addition, []byte{0x01, 0x01, 0x01}, 0744)
  442. assert.NilError(t, err)
  443. modification := path.Join(parentPath, "modification")
  444. err = ioutil.WriteFile(modification, []byte{0x01, 0x01, 0x01}, 0744)
  445. assert.NilError(t, err)
  446. changes := []Change{
  447. {Path: "addition", Kind: ChangeAdd},
  448. {Path: "modification", Kind: ChangeModify},
  449. }
  450. size := ChangesSize(parentPath, changes)
  451. if size != 6 {
  452. t.Fatalf("Expected 6 bytes of changes, got %d", size)
  453. }
  454. }
  455. func checkChanges(expectedChanges, changes []Change, t *testing.T) {
  456. skip.If(t, runtime.GOOS != "windows" && os.Getuid() != 0, "skipping test that requires root")
  457. sort.Sort(changesByPath(expectedChanges))
  458. sort.Sort(changesByPath(changes))
  459. for i := 0; i < max(len(changes), len(expectedChanges)); i++ {
  460. if i >= len(expectedChanges) {
  461. t.Fatalf("unexpected change %s\n", changes[i].String())
  462. }
  463. if i >= len(changes) {
  464. t.Fatalf("no change for expected change %s\n", expectedChanges[i].String())
  465. }
  466. if changes[i].Path == expectedChanges[i].Path {
  467. if changes[i] != expectedChanges[i] {
  468. t.Fatalf("Wrong change for %s, expected %s, got %s\n", changes[i].Path, changes[i].String(), expectedChanges[i].String())
  469. }
  470. } else if changes[i].Path < expectedChanges[i].Path {
  471. t.Fatalf("unexpected change %s\n", changes[i].String())
  472. } else {
  473. t.Fatalf("no change for expected change %s != %s\n", expectedChanges[i].String(), changes[i].String())
  474. }
  475. }
  476. }