diff.test 917 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. #testing "name" "command" "result" "infile" "stdin"
  3. seq 10 > left
  4. seq 11 > right
  5. testing "unknown argument" 'diff --oops left right 2>/dev/null ; echo $?' "2\n" "" ""
  6. testing "missing" 'diff missing1 missing2 2>/dev/null ; echo $?' "2\n" "" ""
  7. testing "- -" 'diff - - ; echo $?' "0\n" "" "whatever"
  8. expected='--- lll
  9. +++ rrr
  10. @@ -8,3 +8,4 @@
  11. 8
  12. 9
  13. 10
  14. +11
  15. '
  16. # Hm this only gives unified diffs?
  17. testing "simple" "diff -L lll -L rrr left right" "$expected" "" ""
  18. expected='--- tree1/file
  19. +++ tree2/file
  20. @@ -1 +1 @@
  21. -foo
  22. +food
  23. '
  24. mkdir -p tree1 tree2
  25. echo foo > tree1/file
  26. echo food > tree2/file
  27. testing "-r" "diff -r -L tree1/file -L tree2/file tree1 tree2 |tee out" "$expected" "" ""
  28. echo -e "hello\r\nworld\r\n"> a
  29. echo -e "hello\nworld\n"> b
  30. testing "--strip-trailing-cr off" "diff -q a b" "Files a and b differ\n" "" ""
  31. testing "--strip-trailing-cr on" "diff -u --strip-trailing-cr a b" "" "" ""