| #!/bin/bash |
| |
| #testing "name" "command" "result" "infile" "stdin" |
| |
| seq 10 > left |
| seq 11 > right |
| |
| testing "unknown argument" 'diff --oops left right 2>/dev/null ; echo $?' "2\n" "" "" |
| testing "missing" 'diff missing1 missing2 2>/dev/null ; echo $?' "2\n" "" "" |
| |
| testing "- -" 'diff - - ; echo $?' "0\n" "" "whatever" |
| |
| expected='--- lll |
| +++ rrr |
| @@ -8,3 +8,4 @@ |
| 8 |
| 9 |
| 10 |
| +11 |
| ' |
| # Hm this only gives unified diffs? |
| testing "simple" "diff -L lll -L rrr left right" "$expected" "" "" |
| |
| |
| expected='--- tree1/file |
| +++ tree2/file |
| @@ -1 +1 @@ |
| -foo |
| +food |
| ' |
| mkdir -p tree1 tree2 |
| echo foo > tree1/file |
| echo food > tree2/file |
| |
| testing "-r" "diff -r -L tree1/file -L tree2/file tree1 tree2 |tee out" "$expected" "" "" |
| |
| echo -e "hello\r\nworld\r\n"> a |
| echo -e "hello\nworld\n"> b |
| testing "--strip-trailing-cr off" "diff -q a b" "Files a and b differ\n" "" "" |
| testing "--strip-trailing-cr on" "diff -u --strip-trailing-cr a b" "" "" "" |