annotate scripts/test/head.test @ 952:ce0519f6457c

Add timeout, factoring out common code from sleep.
author Rob Landley <rob@landley.net>
date Wed, 17 Jul 2013 17:22:46 -0500
parents f4cc0a2aa440
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
451
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
1 #!/bin/bash
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
2
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
4
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
5 #testing "name" "command" "result" "infile" "stdin"
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
6
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
7 testing "head, stdin" "head -n 1 && echo yes" "one\nyes\n" "" "one\ntwo"
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
8 testing "head, stdin via -" "head -n 1 - && echo yes" "one\nyes\n" "" "one\ntwo"
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
9 testing "head, file" "head input -n 1 && echo yes" "one\nyes\n" "one\ntwo" ""
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
10 testing "head, default lines" "head" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" "" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12"
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
11
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
12 echo "foo
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
13 bar
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
14 baz" > file1
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
15 testing "head, multiple files" "head -n 2 input file1" "==> input <==\none\ntwo\n\n==> file1 <==\nfoo\nbar\n" "one\ntwo\nthree\n" ""
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
16 rm file1
f4cc0a2aa440 Add tests for head
Timothy Elliott <tle@holymonkey.com>
parents:
diff changeset
17