Browse Source

t/gitweb-lib.sh: Ensure that errors are shown for --debug --immediate

Because '--immediate' stops test suite after first error, therefore in
this mode

  test_debug 'cat gitweb.log'

was never ran, thus in effect negating effect of '--debug' option.
This made finidng the cause of errors in gitweb test sute difficult.

Modify the gitweb_run test subroutine to run test_debug itself in the
case of errors (and also remove "test_debug 'cat gitweb.log'" from
gitweb tests).

This makes it possible to run *gitweb tests* with --immediate ---debug
combination of options; also it makes gitweb tests to not output
spurious debug data that is not considered error.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Ævar Arnfjörð Bjarmason 14 years ago committed by Junio C Hamano
parent
commit
49151d8b2c
  1. 7
      t/gitweb-lib.sh
  2. 86
      t/t9500-gitweb-standalone-no-errors.sh
  3. 1
      t/t9501-gitweb-standalone-http-status.sh

7
t/gitweb-lib.sh

@ -82,7 +82,12 @@ gitweb_run () { @@ -82,7 +82,12 @@ gitweb_run () {
}
close O;
' gitweb.output &&
if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
if grep '^[[]' gitweb.log >/dev/null 2>&1; then
test_debug 'cat gitweb.log >&2' &&
false
else
true
fi

# gitweb.log is left for debugging
# gitweb.output is used to parse HTTP output

86
t/t9500-gitweb-standalone-no-errors.sh

@ -18,42 +18,34 @@ or warnings to log.' @@ -18,42 +18,34 @@ or warnings to log.'
test_expect_success \
'no commits: projects_list (implicit)' \
'gitweb_run'
test_debug 'cat gitweb.log'

test_expect_success \
'no commits: projects_index' \
'gitweb_run "a=project_index"'
test_debug 'cat gitweb.log'

test_expect_success \
'no commits: .git summary (implicit)' \
'gitweb_run "p=.git"'
test_debug 'cat gitweb.log'

test_expect_success \
'no commits: .git commit (implicit HEAD)' \
'gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'

test_expect_success \
'no commits: .git commitdiff (implicit HEAD)' \
'gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'no commits: .git tree (implicit HEAD)' \
'gitweb_run "p=.git;a=tree"'
test_debug 'cat gitweb.log'

test_expect_success \
'no commits: .git heads' \
'gitweb_run "p=.git;a=heads"'
test_debug 'cat gitweb.log'

test_expect_success \
'no commits: .git tags' \
'gitweb_run "p=.git;a=tags"'
test_debug 'cat gitweb.log'


# ----------------------------------------------------------------------
@ -69,52 +61,42 @@ test_expect_success \ @@ -69,52 +61,42 @@ test_expect_success \
test_expect_success \
'projects_list (implicit)' \
'gitweb_run'
test_debug 'cat gitweb.log'

test_expect_success \
'projects_index' \
'gitweb_run "a=project_index"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git summary (implicit)' \
'gitweb_run "p=.git"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git commit (implicit HEAD)' \
'gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git commitdiff (implicit HEAD, root commit)' \
'gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git commitdiff_plain (implicit HEAD, root commit)' \
'gitweb_run "p=.git;a=commitdiff_plain"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git commit (HEAD)' \
'gitweb_run "p=.git;a=commit;h=HEAD"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git tree (implicit HEAD)' \
'gitweb_run "p=.git;a=tree"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git blob (file)' \
'gitweb_run "p=.git;a=blob;f=file"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git blob_plain (file)' \
'gitweb_run "p=.git;a=blob_plain;f=file"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# nonexistent objects
@ -122,37 +104,30 @@ test_debug 'cat gitweb.log' @@ -122,37 +104,30 @@ test_debug 'cat gitweb.log'
test_expect_success \
'.git commit (non-existent)' \
'gitweb_run "p=.git;a=commit;h=non-existent"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git commitdiff (non-existent)' \
'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git commitdiff (non-existent vs HEAD)' \
'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git tree (0000000000000000000000000000000000000000)' \
'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git tag (0000000000000000000000000000000000000000)' \
'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git blob (non-existent)' \
'gitweb_run "p=.git;a=blob;f=non-existent"'
test_debug 'cat gitweb.log'

test_expect_success \
'.git blob_plain (non-existent)' \
'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
test_debug 'cat gitweb.log'


# ----------------------------------------------------------------------
@ -161,7 +136,6 @@ test_debug 'cat gitweb.log' @@ -161,7 +136,6 @@ test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): root' \
'gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): file added' \
@ -169,21 +143,18 @@ test_expect_success \ @@ -169,21 +143,18 @@ test_expect_success \
git add new_file &&
git commit -a -m "File added." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): mode change' \
'test_chmod +x new_file &&
git commit -a -m "Mode changed." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): file renamed' \
'git mv new_file renamed_file &&
git commit -a -m "File renamed." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success SYMLINKS \
'commitdiff(0): file to symlink' \
@ -191,7 +162,6 @@ test_expect_success SYMLINKS \ @@ -191,7 +162,6 @@ test_expect_success SYMLINKS \
ln -s file renamed_file &&
git commit -a -m "File to symlink." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): file deleted' \
@ -199,7 +169,6 @@ test_expect_success \ @@ -199,7 +169,6 @@ test_expect_success \
rm -f renamed_file &&
git commit -a -m "File removed." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): file copied / new file' \
@ -207,7 +176,6 @@ test_expect_success \ @@ -207,7 +176,6 @@ test_expect_success \
git add file2 &&
git commit -a -m "File copied." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): mode change and modified' \
@ -215,7 +183,6 @@ test_expect_success \ @@ -215,7 +183,6 @@ test_expect_success \
test_chmod +x file2 &&
git commit -a -m "Mode change and modification." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): renamed and modified' \
@ -233,7 +200,6 @@ EOF @@ -233,7 +200,6 @@ EOF
echo "Propter nomen suum." >> file3 &&
git commit -a -m "File rename and modification." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): renamed, mode change and modified' \
@ -242,7 +208,6 @@ test_expect_success \ @@ -242,7 +208,6 @@ test_expect_success \
test_chmod +x file2 &&
git commit -a -m "File rename, mode change and modification." &&
gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# commitdiff testing (taken from t4114-apply-typechange.sh)
@ -279,42 +244,34 @@ test_expect_success SYMLINKS 'setup typechange commits' ' @@ -279,42 +244,34 @@ test_expect_success SYMLINKS 'setup typechange commits' '
test_expect_success \
'commitdiff(2): file renamed from foo to foo/baz' \
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(2): file renamed from foo/baz to foo' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(2): directory becomes file' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(2): file becomes directory' \
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(2): file becomes symlink' \
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(2): symlink becomes file' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(2): symlink becomes directory' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(2): directory becomes symlink' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# commit, commitdiff: merge, large
@ -330,12 +287,10 @@ test_expect_success \ @@ -330,12 +287,10 @@ test_expect_success \
test_expect_success \
'commit(0): merge commit' \
'gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(0): merge commit' \
'gitweb_run "p=.git;a=commitdiff"'
test_debug 'cat gitweb.log'

test_expect_success \
'Prepare large commit' \
@ -371,12 +326,10 @@ test_expect_success \ @@ -371,12 +326,10 @@ test_expect_success \
test_expect_success \
'commit(1): large commit' \
'gitweb_run "p=.git;a=commit;h=b"'
test_debug 'cat gitweb.log'

test_expect_success \
'commitdiff(1): large commit' \
'gitweb_run "p=.git;a=commitdiff;h=b"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# tags testing
@ -394,17 +347,14 @@ test_expect_success \ @@ -394,17 +347,14 @@ test_expect_success \
git tag lightweight/tag-tree HEAD^{tree} &&
git tag lightweight/tag-blob HEAD:file &&
gitweb_run "p=.git;a=tags"'
test_debug 'cat gitweb.log'

test_expect_success \
'tag: Tag to commit object' \
'gitweb_run "p=.git;a=tag;h=tag-commit"'
test_debug 'cat gitweb.log'

test_expect_success \
'tag: on lightweight tag (invalid)' \
'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# logs
@ -412,22 +362,18 @@ test_debug 'cat gitweb.log' @@ -412,22 +362,18 @@ test_debug 'cat gitweb.log'
test_expect_success \
'logs: log (implicit HEAD)' \
'gitweb_run "p=.git;a=log"'
test_debug 'cat gitweb.log'

test_expect_success \
'logs: shortlog (implicit HEAD)' \
'gitweb_run "p=.git;a=shortlog"'
test_debug 'cat gitweb.log'

test_expect_success \
'logs: history (implicit HEAD, file)' \
'gitweb_run "p=.git;a=history;f=file"'
test_debug 'cat gitweb.log'

test_expect_success \
'logs: history (implicit HEAD, non-existent file)' \
'gitweb_run "p=.git;a=history;f=non-existent"'
test_debug 'cat gitweb.log'

test_expect_success \
'logs: history (implicit HEAD, deleted file)' \
@ -438,55 +384,45 @@ test_expect_success \ @@ -438,55 +384,45 @@ test_expect_success \
git rm deleted_file &&
git commit -m "Delete file" &&
gitweb_run "p=.git;a=history;f=deleted_file"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# path_info links
test_expect_success \
'path_info: project' \
'gitweb_run "" "/.git"'
test_debug 'cat gitweb.log'

test_expect_success \
'path_info: project/branch' \
'gitweb_run "" "/.git/b"'
test_debug 'cat gitweb.log'

test_expect_success \
'path_info: project/branch:file' \
'gitweb_run "" "/.git/master:file"'
test_debug 'cat gitweb.log'

test_expect_success \
'path_info: project/branch:dir/' \
'gitweb_run "" "/.git/master:foo/"'
test_debug 'cat gitweb.log'

test_expect_success \
'path_info: project/branch:file (non-existent)' \
'gitweb_run "" "/.git/master:non-existent"'
test_debug 'cat gitweb.log'

test_expect_success \
'path_info: project/branch:dir/ (non-existent)' \
'gitweb_run "" "/.git/master:non-existent/"'
test_debug 'cat gitweb.log'


test_expect_success \
'path_info: project/branch:/file' \
'gitweb_run "" "/.git/master:/file"'
test_debug 'cat gitweb.log'

test_expect_success \
'path_info: project/:/file (implicit HEAD)' \
'gitweb_run "" "/.git/:/file"'
test_debug 'cat gitweb.log'

test_expect_success \
'path_info: project/:/ (implicit HEAD, top tree)' \
'gitweb_run "" "/.git/:/"'
test_debug 'cat gitweb.log'


# ----------------------------------------------------------------------
@ -495,17 +431,14 @@ test_debug 'cat gitweb.log' @@ -495,17 +431,14 @@ test_debug 'cat gitweb.log'
test_expect_success \
'feeds: OPML' \
'gitweb_run "a=opml"'
test_debug 'cat gitweb.log'

test_expect_success \
'feed: RSS' \
'gitweb_run "p=.git;a=rss"'
test_debug 'cat gitweb.log'

test_expect_success \
'feed: Atom' \
'gitweb_run "p=.git;a=atom"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# encoding/decoding
@ -517,7 +450,6 @@ test_expect_success \ @@ -517,7 +450,6 @@ test_expect_success \
git add file &&
git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'

test_expect_success \
'encode(commit): iso-8859-1' \
@ -528,12 +460,10 @@ test_expect_success \ @@ -528,12 +460,10 @@ test_expect_success \
git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
git config --unset i18n.commitencoding &&
gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'

test_expect_success \
'encode(log): utf-8 and iso-8859-1' \
'gitweb_run "p=.git;a=log"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# extra options
@ -541,27 +471,22 @@ test_debug 'cat gitweb.log' @@ -541,27 +471,22 @@ test_debug 'cat gitweb.log'
test_expect_success \
'opt: log --no-merges' \
'gitweb_run "p=.git;a=log;opt=--no-merges"'
test_debug 'cat gitweb.log'

test_expect_success \
'opt: atom --no-merges' \
'gitweb_run "p=.git;a=log;opt=--no-merges"'
test_debug 'cat gitweb.log'

test_expect_success \
'opt: "file" history --no-merges' \
'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
test_debug 'cat gitweb.log'

test_expect_success \
'opt: log --no-such-option (invalid option)' \
'gitweb_run "p=.git;a=log;opt=--no-such-option"'
test_debug 'cat gitweb.log'

test_expect_success \
'opt: tree --no-merges (invalid option for action)' \
'gitweb_run "p=.git;a=tree;opt=--no-merges"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# testing config_to_multi / cloneurl
@ -569,14 +494,12 @@ test_debug 'cat gitweb.log' @@ -569,14 +494,12 @@ test_debug 'cat gitweb.log'
test_expect_success \
'URL: no project URLs, no base URL' \
'gitweb_run "p=.git;a=summary"'
test_debug 'cat gitweb.log'

test_expect_success \
'URL: project URLs via gitweb.url' \
'git config --add gitweb.url git://example.com/git/trash.git &&
git config --add gitweb.url http://example.com/git/trash.git &&
gitweb_run "p=.git;a=summary"'
test_debug 'cat gitweb.log'

cat >.git/cloneurl <<\EOF
git://example.com/git/trash.git
@ -586,7 +509,6 @@ EOF @@ -586,7 +509,6 @@ EOF
test_expect_success \
'URL: project URLs via cloneurl file' \
'gitweb_run "p=.git;a=summary"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# gitweb config and repo config
@ -604,12 +526,10 @@ EOF @@ -604,12 +526,10 @@ EOF
test_expect_success \
'config override: projects list (implicit)' \
'gitweb_run'
test_debug 'cat gitweb.log'

test_expect_success \
'config override: tree view, features not overridden in repo config' \
'gitweb_run "p=.git;a=tree"'
test_debug 'cat gitweb.log'

test_expect_success \
'config override: tree view, features disabled in repo config' \
@ -617,14 +537,12 @@ test_expect_success \ @@ -617,14 +537,12 @@ test_expect_success \
git config gitweb.snapshot none &&
git config gitweb.avatar gravatar &&
gitweb_run "p=.git;a=tree"'
test_debug 'cat gitweb.log'

test_expect_success \
'config override: tree view, features enabled in repo config (1)' \
'git config gitweb.blame yes &&
git config gitweb.snapshot "zip,tgz, tbz2" &&
gitweb_run "p=.git;a=tree"'
test_debug 'cat gitweb.log'

cat >.git/config <<\EOF
# testing noval and alternate separator
@ -635,7 +553,6 @@ EOF @@ -635,7 +553,6 @@ EOF
test_expect_success \
'config override: tree view, features enabled in repo config (2)' \
'gitweb_run "p=.git;a=tree"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# non-ASCII in README.html
@ -645,7 +562,6 @@ test_expect_success \ @@ -645,7 +562,6 @@ test_expect_success \
'echo "<b>UTF-8 example:</b><br />" > .git/README.html &&
cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >> .git/README.html &&
gitweb_run "p=.git;a=summary"'
test_debug 'cat gitweb.log'

# ----------------------------------------------------------------------
# syntax highlighting
@ -666,7 +582,6 @@ test_expect_success HIGHLIGHT \ @@ -666,7 +582,6 @@ test_expect_success HIGHLIGHT \
'syntax highlighting (no highlight, unknown syntax)' \
'git config gitweb.highlight yes &&
gitweb_run "p=.git;a=blob;f=file"'
test_debug 'cat gitweb.log'

test_expect_success HIGHLIGHT \
'syntax highlighting (highlighted, shell script)' \
@ -675,6 +590,5 @@ test_expect_success HIGHLIGHT \ @@ -675,6 +590,5 @@ test_expect_success HIGHLIGHT \
git add test.sh &&
git commit -m "Add test.sh" &&
gitweb_run "p=.git;a=blob;f=test.sh"'
test_debug 'cat gitweb.log'

test_done

1
t/t9501-gitweb-standalone-http-status.sh

@ -126,7 +126,6 @@ test_expect_success 'load checking: load too high (default action)' ' @@ -126,7 +126,6 @@ test_expect_success 'load checking: load too high (default action)' '
grep "Status: 503 Service Unavailable" gitweb.headers &&
grep "503 - The load average on the server is too high" gitweb.body
'
test_debug 'cat gitweb.log' # just in case
test_debug 'cat gitweb.headers'

# turn off load checking

Loading…
Cancel
Save