diff options
author | John Keeping <john@keeping.me.uk> | 2013-04-01 23:09:05 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-04-09 05:27:11 (JST) |
commit | c95cc5ec56dbb7394015eb18201403be6d80f69b (patch) | |
tree | 7014b96a1a1408b5291532c0c442082aba693a80 /tests/t0107-snapshot.sh | |
parent | 8a92df033e974af6338b530a0d78d1bdb0b0f918 (diff) | |
download | cgit-c95cc5ec56dbb7394015eb18201403be6d80f69b.zip cgit-c95cc5ec56dbb7394015eb18201403be6d80f69b.tar.gz |
tests: use Git's test framework
This allows tests to run in parallel as well as letting us use "prove"
or another TAP harness to run the tests.
Git's test framework requires Git to be fully built before letting any
tests run, so add a new target to the top-level Makefile which builds
all of Git instead of just libgit.a and make the "test" target depend on
that.
Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'tests/t0107-snapshot.sh')
-rwxr-xr-x | tests/t0107-snapshot.sh | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index 132d2e9..4fbe45e 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh | |||
@@ -1,77 +1,76 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | test_description='Verify snapshot' | ||
3 | . ./setup.sh | 4 | . ./setup.sh |
4 | 5 | ||
5 | prepare_tests "Verify snapshot" | 6 | test_expect_success 'get foo/snapshot/master.tar.gz' ' |
6 | 7 | cgit_url "foo/snapshot/master.tar.gz" >tmp | |
7 | run_test 'get foo/snapshot/master.tar.gz' ' | ||
8 | cgit_url "foo/snapshot/master.tar.gz" >trash/tmp | ||
9 | ' | 8 | ' |
10 | 9 | ||
11 | run_test 'check html headers' ' | 10 | test_expect_success 'check html headers' ' |
12 | head -n 1 trash/tmp | | 11 | head -n 1 tmp | |
13 | grep "Content-Type: application/x-gzip" && | 12 | grep "Content-Type: application/x-gzip" && |
14 | 13 | ||
15 | head -n 2 trash/tmp | | 14 | head -n 2 tmp | |
16 | grep "Content-Disposition: inline; filename=.master.tar.gz." | 15 | grep "Content-Disposition: inline; filename=.master.tar.gz." |
17 | ' | 16 | ' |
18 | 17 | ||
19 | run_test 'strip off the header lines' ' | 18 | test_expect_success 'strip off the header lines' ' |
20 | tail -n +6 trash/tmp > trash/master.tar.gz | 19 | tail -n +6 tmp > master.tar.gz |
21 | ' | 20 | ' |
22 | 21 | ||
23 | run_test 'verify gzip format' ' | 22 | test_expect_success 'verify gzip format' ' |
24 | gunzip --test trash/master.tar.gz | 23 | gunzip --test master.tar.gz |
25 | ' | 24 | ' |
26 | 25 | ||
27 | run_test 'untar' ' | 26 | test_expect_success 'untar' ' |
28 | rm -rf trash/master && | 27 | rm -rf master && |
29 | tar -xf trash/master.tar.gz -C trash | 28 | tar -xf master.tar.gz |
30 | ' | 29 | ' |
31 | 30 | ||
32 | run_test 'count files' ' | 31 | test_expect_success 'count files' ' |
33 | c=$(ls -1 trash/master/ | wc -l) && | 32 | ls master/ >output && |
34 | test $c = 5 | 33 | test_line_count = 5 output |
35 | ' | 34 | ' |
36 | 35 | ||
37 | run_test 'verify untarred file-5' ' | 36 | test_expect_success 'verify untarred file-5' ' |
38 | grep "^5$" trash/master/file-5 && | 37 | grep "^5$" master/file-5 && |
39 | test $(cat trash/master/file-5 | wc -l) = 1 | 38 | test_line_count = 1 master/file-5 |
40 | ' | 39 | ' |
41 | 40 | ||
42 | run_test 'get foo/snapshot/master.zip' ' | 41 | test_expect_success 'get foo/snapshot/master.zip' ' |
43 | cgit_url "foo/snapshot/master.zip" >trash/tmp | 42 | cgit_url "foo/snapshot/master.zip" >tmp |
44 | ' | 43 | ' |
45 | 44 | ||
46 | run_test 'check HTML headers (zip)' ' | 45 | test_expect_success 'check HTML headers (zip)' ' |
47 | head -n 1 trash/tmp | | 46 | head -n 1 tmp | |
48 | grep "Content-Type: application/x-zip" && | 47 | grep "Content-Type: application/x-zip" && |
49 | 48 | ||
50 | head -n 2 trash/tmp | | 49 | head -n 2 tmp | |
51 | grep "Content-Disposition: inline; filename=.master.zip." | 50 | grep "Content-Disposition: inline; filename=.master.zip." |
52 | ' | 51 | ' |
53 | 52 | ||
54 | run_test 'strip off the header lines (zip)' ' | 53 | test_expect_success 'strip off the header lines (zip)' ' |
55 | tail -n +6 trash/tmp >trash/master.zip | 54 | tail -n +6 tmp >master.zip |
56 | ' | 55 | ' |
57 | 56 | ||
58 | run_test 'verify zip format' ' | 57 | test_expect_success 'verify zip format' ' |
59 | unzip -t trash/master.zip | 58 | unzip -t master.zip |
60 | ' | 59 | ' |
61 | 60 | ||
62 | run_test 'unzip' ' | 61 | test_expect_success 'unzip' ' |
63 | rm -rf trash/master && | 62 | rm -rf master && |
64 | unzip trash/master.zip -d trash | 63 | unzip master.zip |
65 | ' | 64 | ' |
66 | 65 | ||
67 | run_test 'count files (zip)' ' | 66 | test_expect_success 'count files (zip)' ' |
68 | c=$(ls -1 trash/master/ | wc -l) && | 67 | ls master/ >output && |
69 | test $c = 5 | 68 | test_line_count = 5 output |
70 | ' | 69 | ' |
71 | 70 | ||
72 | run_test 'verify unzipped file-5' ' | 71 | test_expect_success 'verify unzipped file-5' ' |
73 | grep "^5$" trash/master/file-5 && | 72 | grep "^5$" master/file-5 && |
74 | test $(cat trash/master/file-5 | wc -l) = 1 | 73 | test_line_count = 1 master/file-5 |
75 | ' | 74 | ' |
76 | 75 | ||
77 | tests_done | 76 | test_done |