PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/test_coopy.sh

https://github.com/paulfitz/coopy
Shell | 135 lines | 113 code | 9 blank | 13 comment | 13 complexity | cc9a13119400c7ef955c73ae6728f95e MD5 | raw file
  1. #!/bin/bash
  2. BUILD_DIR=$PWD
  3. BIN_DIR=$PWD/bin
  4. SSFORMAT=$BIN_DIR/ssformat
  5. COOPY="$BIN_DIR/coopy --delay"
  6. BASE=$BUILD_DIR/test_coopy
  7. rm -rf $BASE
  8. mkdir -p $BASE
  9. cd $BASE || exit 1
  10. # make an empty repository in "store"
  11. mkdir -p store
  12. cd store || exit 1
  13. echo "* Creating empty repository in $PWD"
  14. coopy --new || exit 1
  15. echo " "
  16. # fossil new repository.coopy || exit 1
  17. # fossil gets upset if ancestor isn't clearly older
  18. sleep 1
  19. # clone and view repository in "clone1"
  20. cd $BASE
  21. mkdir -p clone1
  22. cd clone1 || exit 1
  23. CLONE1=$PWD
  24. echo "* Cloning repository in $PWD"
  25. coopy --clone=../store
  26. #fossil clone ../store/repository.coopy repository.coopy || exit 1
  27. #fossil open repository.coopy || exit 1
  28. echo " "
  29. # clone and view repository in "clone2"
  30. cd $BASE
  31. mkdir -p clone2
  32. cd clone2 || exit 1
  33. CLONE2=$PWD
  34. echo "* Cloning repository in $PWD"
  35. coopy --clone=../store
  36. #fossil clone ../store/repository.coopy repository.coopy || exit 1
  37. #fossil open repository.coopy || exit 1
  38. echo " "
  39. # okay, we are ready to start pushing data
  40. cd $CLONE1 || exit 1
  41. (
  42. cat<<EOF
  43. == People ==
  44. Name,Age,Zip
  45. ------------
  46. Paul,36,02139
  47. Leo,3,99999
  48. Noemi,33,07028
  49. EOF
  50. ) > people.sheets
  51. ssformat people.sheets ../people.xls
  52. echo "* Add people.xls to clone1"
  53. $COOPY --add=../people.xls --key=people || exit 1
  54. echo "* Push clone1"
  55. $COOPY -m "add people" --push || exit 1
  56. # okay, we are ready to start pulling data
  57. cd $CLONE2 || exit 1
  58. $COOPY --pull || exit 1
  59. ls people.csvs || exit 1
  60. $COOPY --key=people --export=../people2.xls || exit 1
  61. # modify data
  62. sleep 1
  63. echo "* Modify data"
  64. ssformat ../people2.xls > tmp.sheet
  65. sed -i "s/Noemi/Nomers/" tmp.sheet
  66. ssdiff --apply ../people2.xls tmp.sheet
  67. $COOPY -m "change Noemi's name" --push || exit 1
  68. # check change propagated
  69. echo "* Check modification propagated"
  70. cd $CLONE1 || exit 1
  71. $COOPY --pull || exit 1
  72. ssformat ../people.xls | grep Nomers || exit 1
  73. echo Success
  74. # pair of changes
  75. cd $BASE
  76. sleep 1
  77. sspatch --inplace people.xls --cmd "= |Name=Paul|Age:*->37|"
  78. sspatch --inplace people2.xls --cmd "= |Name=Leo|Age:*->4|"
  79. # commit 1
  80. echo "CHANGE PAUL"
  81. cd $CLONE1
  82. $COOPY -m "change Paul" --push
  83. # commit 2
  84. echo "CHANGE LEO"
  85. cd $CLONE2
  86. $COOPY --pull
  87. $COOPY -m "change Leo" --push
  88. # pull 2
  89. cd $CLONE1
  90. $COOPY --pull
  91. cd $BASE
  92. ssdiff --equal people.xls people2.xls || exit 1
  93. echo Success
  94. # pair of incompatible changes
  95. cd $BASE
  96. sleep 1
  97. sspatch --inplace people.xls --cmd "= |Name=Paul|Zip:*->07028|"
  98. sspatch --inplace people2.xls --cmd "= |Name=Paul|Zip:*->99999|"
  99. # commit 1
  100. echo "CHANGE PAUL"
  101. cd $CLONE1
  102. $COOPY -m "change Paul" --push
  103. # commit 2
  104. echo "CHANGE LEO"
  105. cd $CLONE2
  106. $COOPY --pull
  107. # $COOPY -m "change Leo" --push
  108. # pull 2
  109. # cd $CLONE1
  110. # $COOPY --pull
  111. # cd $BASE
  112. # ssdiff --equal people.xls people2.xls || exit 1