Mercurial > hg > toybox
annotate tests/cmp.test @ 1650:a740a876c76c draft
Cleanup pass on printf.
Alas, passing a union as the last argument to printf does not appear to work
reliably, and there's no obvious way to manually assemble varargs in a portable
manner. So I have to repeat the printf once for each data type. Oh well.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 11 Jan 2015 01:22:36 -0600 |
parents | 8700cbe1cb29 |
children |
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 | 2 |
3 [ -f testing.sh ] && . testing.sh | |
4 | |
5 testing "cmp not enough arguments [fail]" "cmp input 2>/dev/null || echo yes" "yes\n" "foo" "" | |
6 testing "cmp missing file1 [fail]" "cmp file1 input 2>/dev/null || echo yes" "yes\n" "foo" "" | |
7 | |
8 #mkdir dir | |
9 #testing "cmp directory [fail]" "cmp dir dir 2>/dev/null || echo yes" \ | |
10 #"yes\n" "" "" | |
11 #rmdir dir | |
12 | |
13 echo "ab | |
14 c" > input2 | |
15 | |
16 testing "cmp identical files, stdout" "cmp input input2" "" "ab\nc\n" "" | |
17 testing "cmp identical files, return code" "cmp input input2 && echo yes" "yes\n" "ab\nc\n" "" | |
18 | |
19 testing "cmp EOF, stderr" "cmp input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" "" | |
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 | 22 testing "cmp diff, stdout" "cmp input input2" "input input2 differ: char 4, line 2\n" "ab\nx\nx" "" |
23 testing "cmp diff, return code" "cmp input input2 > /dev/null || echo yes" "yes\n" "ab\nx\nx" "" | |
24 | |
25 testing "cmp -s EOF, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nc\nx" "" | |
26 testing "cmp -s diff, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nx\nx" "" | |
27 | |
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 | 30 |
31 rm input2 | |
32 | |
33 testing "cmp stdin and file" "cmp input -" "input - differ: char 4, line 2\n" "ab\nc\n" "ab\nx\n" | |
34 #testing "cmp stdin and stdin" "cmp input -" "" "" "ab\nc\n" | |
35 |