2009-08-25 07:03:48 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009 Mark Rada
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='gitweb as standalone script (http status tests).
|
|
|
|
|
|
|
|
This test runs gitweb (git web interface) as a CGI script from the
|
|
|
|
commandline, and checks that it returns the expected HTTP status
|
|
|
|
code and message.'
|
|
|
|
|
|
|
|
|
2020-11-19 00:44:43 +01:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-19 00:44:19 +01:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
revisions API: have release_revisions() release "cmdline"
Extend the the release_revisions() function so that it frees the
"cmdline" in the "struct rev_info". This in combination with a
preceding change to free "commits" and "mailmap" means that we can
whitelist another test under "TEST_PASSES_SANITIZE_LEAK=true".
There was a proposal in [1] to do away with xstrdup()-ing this
add_rev_cmdline(), perhaps that would be worthwhile, but for now let's
just free() it.
We could also make that a "char *" in "struct rev_cmdline_entry"
itself, but since we own it let's expose it as a constant to outside
callers. I proposed that in [2] but have since changed my mind. See
14d30cdfc04 (ref-filter: fix memory leak in `free_array_item()`,
2019-07-10), c514c62a4fd (checkout: fix leak of non-existent branch
names, 2020-08-14) and other log history hits for "free((char *)" for
prior art.
This includes the tests we had false-positive passes on before my
6798b08e848 (perl Git.pm: don't ignore signalled failure in
_cmd_close(), 2022-02-01), now they pass for real.
Since there are 66 tests matching t/t[0-9]*git-svn*.sh it's easier to
list those that don't pass than to touch most of those 66. So let's
introduce a "TEST_FAILS_SANITIZE_LEAK=true", which if set in the tests
won't cause lib-git-svn.sh to set "TEST_PASSES_SANITIZE_LEAK=true.
This change also marks all the tests that we removed
"TEST_FAILS_SANITIZE_LEAK=true" from in an earlier commit due to
removing the UNLEAK() from cmd_format_patch(), we can now assert that
its API use doesn't leak any "struct rev_info" memory.
This change also made commit "t5503-tagfollow.sh" pass on current
master, but that would regress when combined with
ps/fetch-atomic-fixup's de004e848a9 (t5503: simplify setup of test
which exercises failure of backfill, 2022-03-03) (through no fault of
that topic, that change started using "git clone" in the test, which
has an outstanding leak). Let's leave that test out for now to avoid
in-flight semantic conflicts.
1. https://lore.kernel.org/git/YUj%2FgFRh6pwrZalY@carlos-mbp.lan/
2. https://lore.kernel.org/git/87o88obkb1.fsf@evledraar.gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-04-13 22:01:47 +02:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2021-02-09 22:41:53 +01:00
|
|
|
. ./lib-gitweb.sh
|
2009-08-25 07:03:48 +02:00
|
|
|
|
2012-06-12 20:09:38 +02:00
|
|
|
#
|
|
|
|
# Gitweb only provides the functionality tested by the 'modification times'
|
|
|
|
# tests if it can access a date parser from one of these modules:
|
|
|
|
#
|
|
|
|
perl -MHTTP::Date -e 0 >/dev/null 2>&1 && test_set_prereq DATE_PARSER
|
|
|
|
perl -MTime::ParseDate -e 0 >/dev/null 2>&1 && test_set_prereq DATE_PARSER
|
|
|
|
|
2009-08-25 07:03:48 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# snapshot settings
|
|
|
|
|
2010-03-20 09:29:11 +01:00
|
|
|
test_expect_success 'setup' "
|
2010-12-14 19:26:38 +01:00
|
|
|
test_commit 'SnapshotTests' 'i can has snapshot'
|
2010-03-20 09:29:11 +01:00
|
|
|
"
|
|
|
|
|
2009-08-25 07:03:48 +02:00
|
|
|
|
|
|
|
cat >>gitweb_config.perl <<\EOF
|
|
|
|
$feature{'snapshot'}{'override'} = 0;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'snapshots: tgz only default format enabled' \
|
|
|
|
'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
|
|
|
|
grep "Status: 200 OK" gitweb.output &&
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
|
|
|
|
grep "403 - Unsupported snapshot format" gitweb.output &&
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
|
|
|
|
grep "403 - Snapshot format not allowed" gitweb.output &&
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
|
|
|
|
grep "403 - Unsupported snapshot format" gitweb.output'
|
|
|
|
|
|
|
|
|
|
|
|
cat >>gitweb_config.perl <<\EOF
|
|
|
|
$feature{'snapshot'}{'default'} = ['tgz','tbz2','txz','zip'];
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'snapshots: all enabled in default, use default disabled value' \
|
|
|
|
'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
|
|
|
|
grep "Status: 200 OK" gitweb.output &&
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
|
|
|
|
grep "Status: 200 OK" gitweb.output &&
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
|
|
|
|
grep "403 - Snapshot format not allowed" gitweb.output &&
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
|
|
|
|
grep "Status: 200 OK" gitweb.output'
|
|
|
|
|
|
|
|
|
|
|
|
cat >>gitweb_config.perl <<\EOF
|
|
|
|
$known_snapshot_formats{'zip'}{'disabled'} = 1;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'snapshots: zip explicitly disabled' \
|
|
|
|
'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
|
|
|
|
grep "403 - Snapshot format not allowed" gitweb.output'
|
|
|
|
test_debug 'cat gitweb.output'
|
|
|
|
|
|
|
|
|
|
|
|
cat >>gitweb_config.perl <<\EOF
|
|
|
|
$known_snapshot_formats{'tgz'}{'disabled'} = 0;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'snapshots: tgz explicitly enabled' \
|
|
|
|
'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
|
|
|
|
grep "Status: 200 OK" gitweb.output'
|
2010-01-30 23:30:38 +01:00
|
|
|
test_debug 'cat gitweb.headers'
|
2009-08-25 07:03:48 +02:00
|
|
|
|
|
|
|
|
2009-09-26 19:46:08 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# snapshot hash ids
|
|
|
|
|
|
|
|
test_expect_success 'snapshots: good tree-ish id' '
|
2020-11-19 00:44:43 +01:00
|
|
|
gitweb_run "p=.git;a=snapshot;h=main;sf=tgz" &&
|
2009-09-26 19:46:08 +02:00
|
|
|
grep "Status: 200 OK" gitweb.output
|
|
|
|
'
|
2010-01-30 23:30:38 +01:00
|
|
|
test_debug 'cat gitweb.headers'
|
2009-09-26 19:46:08 +02:00
|
|
|
|
|
|
|
test_expect_success 'snapshots: bad tree-ish id' '
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=frizzumFrazzum;sf=tgz" &&
|
|
|
|
grep "404 - Object does not exist" gitweb.output
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.output'
|
|
|
|
|
|
|
|
test_expect_success 'snapshots: bad tree-ish id (tagged object)' '
|
|
|
|
echo object > tag-object &&
|
|
|
|
git add tag-object &&
|
2012-03-29 14:45:48 +02:00
|
|
|
test_tick && git commit -m "Object to be tagged" &&
|
2016-01-12 12:49:37 +01:00
|
|
|
git tag tagged-object $(git hash-object tag-object) &&
|
2009-09-26 19:46:08 +02:00
|
|
|
gitweb_run "p=.git;a=snapshot;h=tagged-object;sf=tgz" &&
|
|
|
|
grep "400 - Object is not a tree-ish" gitweb.output
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.output'
|
|
|
|
|
|
|
|
test_expect_success 'snapshots: good object id' '
|
2016-01-12 12:49:37 +01:00
|
|
|
ID=$(git rev-parse --verify HEAD) &&
|
2009-09-26 19:46:08 +02:00
|
|
|
gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
|
|
|
|
grep "Status: 200 OK" gitweb.output
|
|
|
|
'
|
2010-01-30 23:30:38 +01:00
|
|
|
test_debug 'cat gitweb.headers'
|
2009-09-26 19:46:08 +02:00
|
|
|
|
|
|
|
test_expect_success 'snapshots: bad object id' '
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=abcdef01234;sf=tgz" &&
|
|
|
|
grep "404 - Object does not exist" gitweb.output
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.output'
|
|
|
|
|
2012-03-29 14:45:48 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# modification times (Last-Modified and If-Modified-Since)
|
|
|
|
|
2012-06-12 20:09:38 +02:00
|
|
|
test_expect_success DATE_PARSER 'modification: feed last-modified' '
|
2020-11-19 00:44:43 +01:00
|
|
|
gitweb_run "p=.git;a=atom;h=main" &&
|
2012-03-29 14:45:48 +02:00
|
|
|
grep "Status: 200 OK" gitweb.headers &&
|
|
|
|
grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
|
|
|
|
2012-06-12 20:09:38 +02:00
|
|
|
test_expect_success DATE_PARSER 'modification: feed if-modified-since (modified)' '
|
2013-04-26 11:18:07 +02:00
|
|
|
HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" &&
|
|
|
|
export HTTP_IF_MODIFIED_SINCE &&
|
2012-03-29 14:45:48 +02:00
|
|
|
test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
|
2020-11-19 00:44:43 +01:00
|
|
|
gitweb_run "p=.git;a=atom;h=main" &&
|
2012-03-29 14:45:48 +02:00
|
|
|
grep "Status: 200 OK" gitweb.headers
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
|
|
|
|
2012-06-12 20:09:38 +02:00
|
|
|
test_expect_success DATE_PARSER 'modification: feed if-modified-since (unmodified)' '
|
2013-04-26 11:18:07 +02:00
|
|
|
HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" &&
|
|
|
|
export HTTP_IF_MODIFIED_SINCE &&
|
2012-03-29 14:45:48 +02:00
|
|
|
test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
|
2020-11-19 00:44:43 +01:00
|
|
|
gitweb_run "p=.git;a=atom;h=main" &&
|
2012-03-29 14:45:48 +02:00
|
|
|
grep "Status: 304 Not Modified" gitweb.headers
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
2009-09-26 19:46:08 +02:00
|
|
|
|
2012-06-12 20:09:38 +02:00
|
|
|
test_expect_success DATE_PARSER 'modification: snapshot last-modified' '
|
2020-11-19 00:44:43 +01:00
|
|
|
gitweb_run "p=.git;a=snapshot;h=main;sf=tgz" &&
|
2012-03-29 14:45:49 +02:00
|
|
|
grep "Status: 200 OK" gitweb.headers &&
|
|
|
|
grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
|
|
|
|
2012-06-12 20:09:38 +02:00
|
|
|
test_expect_success DATE_PARSER 'modification: snapshot if-modified-since (modified)' '
|
2013-04-26 11:18:07 +02:00
|
|
|
HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" &&
|
|
|
|
export HTTP_IF_MODIFIED_SINCE &&
|
2012-03-29 14:45:49 +02:00
|
|
|
test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
|
2020-11-19 00:44:43 +01:00
|
|
|
gitweb_run "p=.git;a=snapshot;h=main;sf=tgz" &&
|
2012-03-29 14:45:49 +02:00
|
|
|
grep "Status: 200 OK" gitweb.headers
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
|
|
|
|
2012-06-12 20:09:38 +02:00
|
|
|
test_expect_success DATE_PARSER 'modification: snapshot if-modified-since (unmodified)' '
|
2013-04-26 11:18:07 +02:00
|
|
|
HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" &&
|
|
|
|
export HTTP_IF_MODIFIED_SINCE &&
|
2012-03-29 14:45:49 +02:00
|
|
|
test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
|
2020-11-19 00:44:43 +01:00
|
|
|
gitweb_run "p=.git;a=snapshot;h=main;sf=tgz" &&
|
2012-03-29 14:45:49 +02:00
|
|
|
grep "Status: 304 Not Modified" gitweb.headers
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
|
|
|
|
2012-06-12 20:09:38 +02:00
|
|
|
test_expect_success DATE_PARSER 'modification: tree snapshot' '
|
2016-01-12 12:49:37 +01:00
|
|
|
ID=$(git rev-parse --verify HEAD^{tree}) &&
|
2013-04-26 11:18:07 +02:00
|
|
|
HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" &&
|
|
|
|
export HTTP_IF_MODIFIED_SINCE &&
|
2012-03-29 14:45:49 +02:00
|
|
|
test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
|
|
|
|
gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
|
|
|
|
grep "Status: 200 OK" gitweb.headers &&
|
|
|
|
! grep -i "last-modified" gitweb.headers
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
|
|
|
|
2010-01-30 23:30:39 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# load checking
|
|
|
|
|
|
|
|
# always hit the load limit
|
|
|
|
cat >>gitweb_config.perl <<\EOF
|
2010-02-06 15:50:03 +01:00
|
|
|
our $maxload = -1;
|
2010-01-30 23:30:39 +01:00
|
|
|
EOF
|
|
|
|
|
2010-02-06 15:50:03 +01:00
|
|
|
test_expect_success 'load checking: load too high (default action)' '
|
2010-01-30 23:30:39 +01:00
|
|
|
gitweb_run "p=.git" &&
|
|
|
|
grep "Status: 503 Service Unavailable" gitweb.headers &&
|
|
|
|
grep "503 - The load average on the server is too high" gitweb.body
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
|
|
|
|
|
|
|
# turn off load checking
|
|
|
|
cat >>gitweb_config.perl <<\EOF
|
|
|
|
our $maxload = undef;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
2012-02-28 19:41:47 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# invalid arguments
|
|
|
|
|
|
|
|
test_expect_success 'invalid arguments: invalid regexp (in project search)' '
|
|
|
|
gitweb_run "a=project_list;s=*\.git;sr=1" &&
|
|
|
|
grep "Status: 400" gitweb.headers &&
|
|
|
|
grep "400 - Invalid.*regexp" gitweb.body
|
|
|
|
'
|
|
|
|
test_debug 'cat gitweb.headers'
|
|
|
|
|
2009-08-25 07:03:48 +02:00
|
|
|
test_done
|