From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Mon, 8 Apr 2013 20:12:35 +0100 Subject: [PATCH 06/12] tests: remove "trash" directory In-Reply-To: References: Message-ID: <0b4e1af131d668a4ef1e504e43725880a3724bd2.1365448308.git.john@keeping.me.uk> Now that we're using Git's test framework, it generates a suitable trash directory for us to use, so we don't need to create a "trash" subdirectory. This patch was generated with "sed -i -e 's!trash/!!g' tests/*.sh" with the t0107-snapshot.sh tests fixed to avoid passing "-C trash" to tar or "-d trash" to unzip. Signed-off-by: John Keeping --- tests/setup.sh | 28 ++++++++++++++-------------- tests/t0010-validate-html.sh | 6 +++--- tests/t0020-validate-cache.sh | 18 +++++++++--------- tests/t0101-index.sh | 20 ++++++++++---------- tests/t0102-summary.sh | 26 +++++++++++++------------- tests/t0103-log.sh | 26 +++++++++++++------------- tests/t0104-tree.sh | 20 ++++++++++---------- tests/t0105-commit.sh | 26 +++++++++++++------------- tests/t0106-diff.sh | 12 ++++++------ tests/t0107-snapshot.sh | 40 ++++++++++++++++++++-------------------- tests/t0108-patch.sh | 16 ++++++++-------- 11 files changed, 119 insertions(+), 119 deletions(-) diff --git a/tests/setup.sh b/tests/setup.sh index 962d96b..f4bdafd 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -48,15 +48,15 @@ mkrepo() { setup_repos() { - rm -rf trash/cache - mkdir -p trash/cache - mkrepo trash/repos/foo 5 >/dev/null - mkrepo trash/repos/bar 50 >/dev/null - mkrepo trash/repos/foo+bar 10 testplus >/dev/null - mkrepo "trash/repos/with space" 2 >/dev/null - cat >trash/cgitrc </dev/null + mkrepo repos/bar 50 >/dev/null + mkrepo repos/foo+bar 10 testplus >/dev/null + mkrepo "repos/with space" 2 >/dev/null + cat >cgitrc <trash/tidy-$test_count || return - sed -ie "1,4d" trash/tidy-$test_count || return - "$tidy" $tidy_opt trash/tidy-$test_count + cgit_url "$1" >tidy-$test_count || return + sed -ie "1,4d" tidy-$test_count || return + "$tidy" $tidy_opt tidy-$test_count rc=$? # tidy returns with exitcode 1 on warnings, 2 on error diff --git a/tests/t0020-validate-cache.sh b/tests/t0020-validate-cache.sh index b6a12c7..135b24d 100755 --- a/tests/t0020-validate-cache.sh +++ b/tests/t0020-validate-cache.sh @@ -5,8 +5,8 @@ test_description='Validate cache' test_expect_success 'verify cache-size=0' ' - rm -f trash/cache/* && - sed -i -e "s/cache-size=1021$/cache-size=0/" trash/cgitrc && + rm -f cache/* && + sed -i -e "s/cache-size=1021$/cache-size=0/" cgitrc && cgit_url "" && cgit_url "foo" && cgit_url "foo/refs" && @@ -20,13 +20,13 @@ test_expect_success 'verify cache-size=0' ' cgit_url "bar/log" && cgit_url "bar/diff" && cgit_url "bar/patch" && - test 0 -eq $(ls trash/cache | wc -l) + test 0 -eq $(ls cache | wc -l) ' test_expect_success 'verify cache-size=1' ' - rm -f trash/cache/* && - sed -i -e "s/cache-size=0$/cache-size=1/" trash/cgitrc && + rm -f cache/* && + sed -i -e "s/cache-size=0$/cache-size=1/" cgitrc && cgit_url "" && cgit_url "foo" && cgit_url "foo/refs" && @@ -40,13 +40,13 @@ test_expect_success 'verify cache-size=1' ' cgit_url "bar/log" && cgit_url "bar/diff" && cgit_url "bar/patch" && - test 1 -eq $(ls trash/cache | wc -l) + test 1 -eq $(ls cache | wc -l) ' test_expect_success 'verify cache-size=1021' ' - rm -f trash/cache/* && - sed -i -e "s/cache-size=1$/cache-size=1021/" trash/cgitrc && + rm -f cache/* && + sed -i -e "s/cache-size=1$/cache-size=1021/" cgitrc && cgit_url "" && cgit_url "foo" && cgit_url "foo/refs" && @@ -60,7 +60,7 @@ test_expect_success 'verify cache-size=1021' ' cgit_url "bar/log" && cgit_url "bar/diff" && cgit_url "bar/patch" && - test 13 -eq $(ls trash/cache | wc -l) + test 13 -eq $(ls cache | wc -l) ' test_done diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index 69c92d1..82ef9b0 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh @@ -3,15 +3,15 @@ test_description='Check content on index page' . ./setup.sh -test_expect_success 'generate index page' 'cgit_url "" >trash/tmp' -test_expect_success 'find foo repo' 'grep "foo" trash/tmp' -test_expect_success 'find foo description' 'grep "\[no description\]" trash/tmp' -test_expect_success 'find bar repo' 'grep "bar" trash/tmp' -test_expect_success 'find bar description' 'grep "the bar repo" trash/tmp' -test_expect_success 'find foo+bar repo' 'grep ">foo+bar<" trash/tmp' -test_expect_success 'verify foo+bar link' 'grep "/foo+bar/" trash/tmp' -test_expect_success 'verify "with%20space" link' 'grep "/with%20space/" trash/tmp' -test_expect_success 'no tree-link' '! grep "foo/tree" trash/tmp' -test_expect_success 'no log-link' '! grep "foo/log" trash/tmp' +test_expect_success 'generate index page' 'cgit_url "" >tmp' +test_expect_success 'find foo repo' 'grep "foo" tmp' +test_expect_success 'find foo description' 'grep "\[no description\]" tmp' +test_expect_success 'find bar repo' 'grep "bar" tmp' +test_expect_success 'find bar description' 'grep "the bar repo" tmp' +test_expect_success 'find foo+bar repo' 'grep ">foo+bar<" tmp' +test_expect_success 'verify foo+bar link' 'grep "/foo+bar/" tmp' +test_expect_success 'verify "with%20space" link' 'grep "/with%20space/" tmp' +test_expect_success 'no tree-link' '! grep "foo/tree" tmp' +test_expect_success 'no log-link' '! grep "foo/log" tmp' test_done diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh index 470f89e..b8864cb 100755 --- a/tests/t0102-summary.sh +++ b/tests/t0102-summary.sh @@ -3,23 +3,23 @@ test_description='Check content on summary page' . ./setup.sh -test_expect_success 'generate foo summary' 'cgit_url "foo" >trash/tmp' -test_expect_success 'find commit 1' 'grep "commit 1" trash/tmp' -test_expect_success 'find commit 5' 'grep "commit 5" trash/tmp' -test_expect_success 'find branch master' 'grep "master" trash/tmp' -test_expect_success 'no tags' '! grep "tags" trash/tmp' +test_expect_success 'generate foo summary' 'cgit_url "foo" >tmp' +test_expect_success 'find commit 1' 'grep "commit 1" tmp' +test_expect_success 'find commit 5' 'grep "commit 5" tmp' +test_expect_success 'find branch master' 'grep "master" tmp' +test_expect_success 'no tags' '! grep "tags" tmp' test_expect_success 'clone-url expanded correctly' ' - grep "git://example.org/foo.git" trash/tmp + grep "git://example.org/foo.git" tmp ' -test_expect_success 'generate bar summary' 'cgit_url "bar" >trash/tmp' -test_expect_success 'no commit 45' '! grep "commit 45" trash/tmp' -test_expect_success 'find commit 46' 'grep "commit 46" trash/tmp' -test_expect_success 'find commit 50' 'grep "commit 50" trash/tmp' -test_expect_success 'find branch master' 'grep "master" trash/tmp' -test_expect_success 'no tags' '! grep "tags" trash/tmp' +test_expect_success 'generate bar summary' 'cgit_url "bar" >tmp' +test_expect_success 'no commit 45' '! grep "commit 45" tmp' +test_expect_success 'find commit 46' 'grep "commit 46" tmp' +test_expect_success 'find commit 50' 'grep "commit 50" tmp' +test_expect_success 'find branch master' 'grep "master" tmp' +test_expect_success 'no tags' '! grep "tags" tmp' test_expect_success 'clone-url expanded correctly' ' - grep "git://example.org/bar.git" trash/tmp + grep "git://example.org/bar.git" tmp ' test_done diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh index ec873bc..bdf1435 100755 --- a/tests/t0103-log.sh +++ b/tests/t0103-log.sh @@ -3,22 +3,22 @@ test_description='Check content on log page' . ./setup.sh -test_expect_success 'generate foo/log' 'cgit_url "foo/log" >trash/tmp' -test_expect_success 'find commit 1' 'grep "commit 1" trash/tmp' -test_expect_success 'find commit 5' 'grep "commit 5" trash/tmp' +test_expect_success 'generate foo/log' 'cgit_url "foo/log" >tmp' +test_expect_success 'find commit 1' 'grep "commit 1" tmp' +test_expect_success 'find commit 5' 'grep "commit 5" tmp' -test_expect_success 'generate bar/log' 'cgit_url "bar/log" >trash/tmp' -test_expect_success 'find commit 1' 'grep "commit 1" trash/tmp' -test_expect_success 'find commit 50' 'grep "commit 50" trash/tmp' +test_expect_success 'generate bar/log' 'cgit_url "bar/log" >tmp' +test_expect_success 'find commit 1' 'grep "commit 1" tmp' +test_expect_success 'find commit 50' 'grep "commit 50" tmp' test_expect_success 'generate "with%20space/log?qt=grep&q=commit+1"' ' - cgit_url "with+space/log&qt=grep&q=commit+1" >trash/tmp + cgit_url "with+space/log&qt=grep&q=commit+1" >tmp ' -test_expect_success 'find commit 1' 'grep "commit 1" trash/tmp' -test_expect_success 'find link with %20 in path' 'grep "/with%20space/log/?qt=grep" trash/tmp' -test_expect_success 'find link with + in arg' 'grep "/log/?qt=grep&q=commit+1" trash/tmp' -test_expect_success 'no links with space in path' '! grep "href=./with space/" trash/tmp' -test_expect_success 'no links with space in arg' '! grep "q=commit 1" trash/tmp' -test_expect_success 'commit 2 is not visible' '! grep "commit 2" trash/tmp' +test_expect_success 'find commit 1' 'grep "commit 1" tmp' +test_expect_success 'find link with %20 in path' 'grep "/with%20space/log/?qt=grep" tmp' +test_expect_success 'find link with + in arg' 'grep "/log/?qt=grep&q=commit+1" tmp' +test_expect_success 'no links with space in path' '! grep "href=./with space/" tmp' +test_expect_success 'no links with space in arg' '! grep "q=commit 1" tmp' +test_expect_success 'commit 2 is not visible' '! grep "commit 2" tmp' test_done diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index ecf96e6..100b026 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -3,30 +3,30 @@ test_description='Check content on tree page' . ./setup.sh -test_expect_success 'generate bar/tree' 'cgit_url "bar/tree" >trash/tmp' -test_expect_success 'find file-1' 'grep "file-1" trash/tmp' -test_expect_success 'find file-50' 'grep "file-50" trash/tmp' +test_expect_success 'generate bar/tree' 'cgit_url "bar/tree" >tmp' +test_expect_success 'find file-1' 'grep "file-1" tmp' +test_expect_success 'find file-50' 'grep "file-50" tmp' -test_expect_success 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >trash/tmp' +test_expect_success 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >tmp' test_expect_success 'find line 1' ' - grep "1" trash/tmp + grep "1" tmp ' test_expect_success 'no line 2' ' - ! grep "2" trash/tmp + ! grep "2" tmp ' -test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp' +test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >tmp' test_expect_success 'verify a+b link' ' - grep "/foo+bar/tree/a+b" trash/tmp + grep "/foo+bar/tree/a+b" tmp ' -test_expect_success 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&h=1%2b2" >trash/tmp' +test_expect_success 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&h=1%2b2" >tmp' test_expect_success 'verify a+b?h=1+2 link' ' - grep "/foo+bar/tree/a+b?h=1%2b2" trash/tmp + grep "/foo+bar/tree/a+b?h=1%2b2" tmp ' test_done diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh index ae6bd94..9cdf55c 100755 --- a/tests/t0105-commit.sh +++ b/tests/t0105-commit.sh @@ -3,34 +3,34 @@ test_description='Check content on commit page' . ./setup.sh -test_expect_success 'generate foo/commit' 'cgit_url "foo/commit" >trash/tmp' -test_expect_success 'find tree link' 'grep "" trash/tmp' -test_expect_success 'find parent link' 'grep -E "" trash/tmp' +test_expect_success 'generate foo/commit' 'cgit_url "foo/commit" >tmp' +test_expect_success 'find tree link' 'grep "" tmp' +test_expect_success 'find parent link' 'grep -E "" tmp' test_expect_success 'find commit subject' ' - grep "
commit 5<" trash/tmp + grep "
commit 5<" tmp ' -test_expect_success 'find commit msg' 'grep "
" trash/tmp' -test_expect_success 'find diffstat' 'grep "" trash/tmp' +test_expect_success 'find commit msg' 'grep "
" tmp' +test_expect_success 'find diffstat' 'grep "
" tmp' test_expect_success 'find diff summary' ' - grep "1 files changed, 1 insertions, 0 deletions" trash/tmp + grep "1 files changed, 1 insertions, 0 deletions" tmp ' test_expect_success 'get root commit' ' - root=$(cd trash/repos/foo && git rev-list --reverse HEAD | head -1) && - cgit_url "foo/commit&id=$root" >trash/tmp && - grep "" trash/tmp + root=$(cd repos/foo && git rev-list --reverse HEAD | head -1) && + cgit_url "foo/commit&id=$root" >tmp && + grep "" tmp ' test_expect_success 'root commit contains diffstat' ' - grep "file-1" trash/tmp + grep "file-1" tmp ' test_expect_success 'root commit contains diff' ' - grep ">diff --git a/file-1 b/file-1<" trash/tmp && - grep "
+1
" trash/tmp + grep ">diff --git a/file-1 b/file-1<" tmp && + grep "
+1
" tmp ' test_done diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh index 427ad29..82b645e 100755 --- a/tests/t0106-diff.sh +++ b/tests/t0106-diff.sh @@ -3,17 +3,17 @@ test_description='Check content on diff page' . ./setup.sh -test_expect_success 'generate foo/diff' 'cgit_url "foo/diff" >trash/tmp' -test_expect_success 'find diff header' 'grep "a/file-5 b/file-5" trash/tmp' -test_expect_success 'find blob link' 'grep "tmp' +test_expect_success 'find diff header' 'grep "a/file-5 b/file-5" tmp' +test_expect_success 'find blob link' 'grep "@@ -0,0 +1 @@" trash/tmp + grep "
@@ -0,0 +1 @@
" tmp ' test_expect_success 'find added line' ' - grep "
+5
" trash/tmp + grep "
+5
" tmp ' test_done diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index 271cdb4..e244968 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh @@ -4,73 +4,73 @@ test_description='Verify snapshot' . ./setup.sh test_expect_success 'get foo/snapshot/master.tar.gz' ' - cgit_url "foo/snapshot/master.tar.gz" >trash/tmp + cgit_url "foo/snapshot/master.tar.gz" >tmp ' test_expect_success 'check html headers' ' - head -n 1 trash/tmp | + head -n 1 tmp | grep "Content-Type: application/x-gzip" && - head -n 2 trash/tmp | + head -n 2 tmp | grep "Content-Disposition: inline; filename=.master.tar.gz." ' test_expect_success 'strip off the header lines' ' - tail -n +6 trash/tmp > trash/master.tar.gz + tail -n +6 tmp > master.tar.gz ' test_expect_success 'verify gzip format' ' - gunzip --test trash/master.tar.gz + gunzip --test master.tar.gz ' test_expect_success 'untar' ' - rm -rf trash/master && - tar -xf trash/master.tar.gz -C trash + rm -rf master && + tar -xf master.tar.gz ' test_expect_success 'count files' ' - c=$(ls -1 trash/master/ | wc -l) && + c=$(ls -1 master/ | wc -l) && test $c = 5 ' test_expect_success 'verify untarred file-5' ' - grep "^5$" trash/master/file-5 && - test $(cat trash/master/file-5 | wc -l) = 1 + grep "^5$" master/file-5 && + test $(cat master/file-5 | wc -l) = 1 ' test_expect_success 'get foo/snapshot/master.zip' ' - cgit_url "foo/snapshot/master.zip" >trash/tmp + cgit_url "foo/snapshot/master.zip" >tmp ' test_expect_success 'check HTML headers (zip)' ' - head -n 1 trash/tmp | + head -n 1 tmp | grep "Content-Type: application/x-zip" && - head -n 2 trash/tmp | + head -n 2 tmp | grep "Content-Disposition: inline; filename=.master.zip." ' test_expect_success 'strip off the header lines (zip)' ' - tail -n +6 trash/tmp >trash/master.zip + tail -n +6 tmp >master.zip ' test_expect_success 'verify zip format' ' - unzip -t trash/master.zip + unzip -t master.zip ' test_expect_success 'unzip' ' - rm -rf trash/master && - unzip trash/master.zip -d trash + rm -rf master && + unzip master.zip ' test_expect_success 'count files (zip)' ' - c=$(ls -1 trash/master/ | wc -l) && + c=$(ls -1 master/ | wc -l) && test $c = 5 ' test_expect_success 'verify unzipped file-5' ' - grep "^5$" trash/master/file-5 && - test $(cat trash/master/file-5 | wc -l) = 1 + grep "^5$" master/file-5 && + test $(cat master/file-5 | wc -l) = 1 ' test_done diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh index 8bf6914..3b5bae4 100755 --- a/tests/t0108-patch.sh +++ b/tests/t0108-patch.sh @@ -4,35 +4,35 @@ test_description='Check content on patch page' . ./setup.sh test_expect_success 'generate foo/patch' ' - cgit_query "url=foo/patch" >trash/tmp + cgit_query "url=foo/patch" >tmp ' test_expect_success 'find `From:` line' ' - grep "^From: " trash/tmp + grep "^From: " tmp ' test_expect_success 'find `Date:` line' ' - grep "^Date: " trash/tmp + grep "^Date: " tmp ' test_expect_success 'find `Subject:` line' ' - grep "^Subject: commit 5" trash/tmp + grep "^Subject: commit 5" tmp ' test_expect_success 'find `cgit` signature' ' - tail -1 trash/tmp | grep "^cgit" + tail -1 tmp | grep "^cgit" ' test_expect_success 'find initial commit' ' - root=$(git --git-dir="$PWD/trash/repos/foo/.git" rev-list HEAD | tail -1) + root=$(git --git-dir="$PWD/repos/foo/.git" rev-list HEAD | tail -1) ' test_expect_success 'generate patch for initial commit' ' - cgit_query "url=foo/patch&id=$root" >trash/tmp + cgit_query "url=foo/patch&id=$root" >tmp ' test_expect_success 'find `cgit` signature' ' - tail -1 trash/tmp | grep "^cgit" + tail -1 tmp | grep "^cgit" ' test_done -- 1.8.2.694.ga76e9c3.dirty