annotate scripts/test/cmp.test @ 587:82ffae226c40

Convert another realpath use to xrealpath().
author Rob Landley <rob@landley.net>
date Fri, 01 Jun 2012 17:59:11 -0500
parents 716344d1eacd
children 7894d4afc39c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
473
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
1 #/bin/bash
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
2
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
4
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
5 testing "cmp not enough arguments [fail]" "cmp input 2>/dev/null || echo yes" "yes\n" "foo" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
6 testing "cmp missing file1 [fail]" "cmp file1 input 2>/dev/null || echo yes" "yes\n" "foo" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
7
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
8 #mkdir dir
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
9 #testing "cmp directory [fail]" "cmp dir dir 2>/dev/null || echo yes" \
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
10 #"yes\n" "" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
11 #rmdir dir
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
12
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
13 echo "ab
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
14 c" > input2
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
15
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
16 testing "cmp identical files, stdout" "cmp input input2" "" "ab\nc\n" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
17 testing "cmp identical files, return code" "cmp input input2 && echo yes" "yes\n" "ab\nc\n" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
18
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
19 testing "cmp EOF, stderr" "cmp input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
20 testing "cmp EOF, return code" "cmp input input2 2>/dev/null || echo yes" "yes\n" "ab\nc\nx" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
21 testing "cmp diff, stdout" "cmp input input2" "input input2 differ: char 4, line 2\n" "ab\nx\nx" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
22 testing "cmp diff, return code" "cmp input input2 > /dev/null || echo yes" "yes\n" "ab\nx\nx" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
23
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
24 testing "cmp -s EOF, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nc\nx" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
25 testing "cmp -s diff, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nx\nx" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
26
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
27 testing "cmp -l EOF, stderr" "cmp -l input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
28 testing "cmp -l diff and EOF, stdout and stderr" "cmp -l input input2 2>&1" "cmp: EOF on input2\n4 170 143\n" "ab\nx\nx" ""
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
29
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
30 rm input2
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
31
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
32 testing "cmp stdin and file" "cmp input -" "input - differ: char 4, line 2\n" "ab\nc\n" "ab\nx\n"
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
33 #testing "cmp stdin and stdin" "cmp input -" "" "" "ab\nc\n"
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
34