annotate tests/cmp.test @ 1766:190ecf70fbe5 draft

Fix an obvious typo in Makefile.
author Elliott Hughes <enh@google.com>
date Sat, 28 Mar 2015 13:13:42 -0500
parents 8700cbe1cb29
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
682
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents: 473
diff changeset
1 #!/bin/bash
473
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" ""
801
9155a0813ffc Tweak cmp test to be a little more deterministic.
Rob Landley <rob@landley.net>
parents: 682
diff changeset
21 # The gnu/dammit version fails this because posix says "char" and they don't.
473
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
22 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
23 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
24
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
25 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
26 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
27
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
28 testing "cmp -l EOF, stderr" "cmp -l input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" ""
801
9155a0813ffc Tweak cmp test to be a little more deterministic.
Rob Landley <rob@landley.net>
parents: 682
diff changeset
29 testing "cmp -l diff and EOF, stdout and stderr" "cmp -l input input2 2>&1 | sort" "4 170 143\ncmp: EOF on input2\n" "ab\nx\nx" ""
473
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
30
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
31 rm input2
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
32
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
33 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
34 #testing "cmp stdin and stdin" "cmp input -" "" "" "ab\nc\n"
716344d1eacd Add tests for cmp.
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
35