10f66f451Sopenharmony_ci#!/bin/bash
20f66f451Sopenharmony_ci
30f66f451Sopenharmony_ci#testing "name" "command" "result" "infile" "stdin"
40f66f451Sopenharmony_ci
50f66f451Sopenharmony_ciseq 10 > left
60f66f451Sopenharmony_ciseq 11 > right
70f66f451Sopenharmony_ci
80f66f451Sopenharmony_citesting "unknown argument" 'diff --oops left right 2>/dev/null ; echo $?' "2\n" "" ""
90f66f451Sopenharmony_citesting "missing" 'diff missing1 missing2 2>/dev/null ; echo $?' "2\n" "" ""
100f66f451Sopenharmony_ci
110f66f451Sopenharmony_citesting "- -" 'diff - - ; echo $?' "0\n" "" "whatever"
120f66f451Sopenharmony_ci
130f66f451Sopenharmony_ciexpected='--- lll
140f66f451Sopenharmony_ci+++ rrr
150f66f451Sopenharmony_ci@@ -8,3 +8,4 @@
160f66f451Sopenharmony_ci 8
170f66f451Sopenharmony_ci 9
180f66f451Sopenharmony_ci 10
190f66f451Sopenharmony_ci+11
200f66f451Sopenharmony_ci'
210f66f451Sopenharmony_ci# Hm this only gives unified diffs?
220f66f451Sopenharmony_citesting "simple" "diff -L lll -L rrr left right" "$expected" "" ""
230f66f451Sopenharmony_ci
240f66f451Sopenharmony_ci
250f66f451Sopenharmony_ciexpected='--- tree1/file
260f66f451Sopenharmony_ci+++ tree2/file
270f66f451Sopenharmony_ci@@ -1 +1 @@
280f66f451Sopenharmony_ci-foo
290f66f451Sopenharmony_ci+food
300f66f451Sopenharmony_ci'
310f66f451Sopenharmony_cimkdir -p tree1 tree2
320f66f451Sopenharmony_ciecho foo > tree1/file
330f66f451Sopenharmony_ciecho food > tree2/file
340f66f451Sopenharmony_ci
350f66f451Sopenharmony_citesting "-r" "diff -r -L tree1/file -L tree2/file tree1 tree2 |tee out" "$expected" "" ""
360f66f451Sopenharmony_ci
370f66f451Sopenharmony_ciecho -e "hello\r\nworld\r\n"> a
380f66f451Sopenharmony_ciecho -e "hello\nworld\n"> b
390f66f451Sopenharmony_citesting "--strip-trailing-cr off" "diff -q a b" "Files a and b differ\n" "" ""
400f66f451Sopenharmony_citesting "--strip-trailing-cr on" "diff -u --strip-trailing-cr a b" "" "" ""
41