3
0

patch.tests 935 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. # Copyright 2008 by Denys Vlasenko
  3. # Licensed under GPL v2, see file LICENSE for details.
  4. . testing.sh
  5. # testing "test name" "options" "expected result" "file input" "stdin"
  6. testing "patch with old_file == new_file" \
  7. "patch; echo $?; cat input" \
  8. "\
  9. patching file input
  10. 0
  11. qwe
  12. asd
  13. zxc
  14. " \
  15. "qwe\nzxc\n" \
  16. "\
  17. --- input Jan 01 01:01:01 2000
  18. +++ input Jan 01 01:01:01 2000
  19. @@ -1,2 +1,3 @@
  20. qwe
  21. +asd
  22. zxc
  23. " \
  24. testing "patch with nonexistent old_file" \
  25. "patch; echo $?; cat input" \
  26. "\
  27. patching file input
  28. 0
  29. qwe
  30. asd
  31. zxc
  32. " \
  33. "qwe\nzxc\n" \
  34. "\
  35. --- input.doesnt_exist Jan 01 01:01:01 2000
  36. +++ input Jan 01 01:01:01 2000
  37. @@ -1,2 +1,3 @@
  38. qwe
  39. +asd
  40. zxc
  41. " \
  42. testing "patch -R with nonexistent old_file" \
  43. "patch -R; echo $?; cat input" \
  44. "\
  45. patching file input
  46. 0
  47. qwe
  48. zxc
  49. " \
  50. "qwe\nasd\nzxc\n" \
  51. "\
  52. --- input.doesnt_exist Jan 01 01:01:01 2000
  53. +++ input Jan 01 01:01:01 2000
  54. @@ -1,2 +1,3 @@
  55. qwe
  56. +asd
  57. zxc
  58. " \
  59. exit $FAILCOUNT