tests: define GIT_TEST_PROTOCOL_VERSION
Define a GIT_TEST_PROTOCOL_VERSION environment variable meant to be used from tests. When set, this ensures protocol.version is at least the given value, allowing the entire test suite to be run as if this configuration is in place for all repositories. As of this patch, all tests pass whether GIT_TEST_PROTOCOL_VERSION is unset or set to 0. Some tests fail when GIT_TEST_PROTOCOL_VERSION is set to 1 or 2, but this will be dealt with in subsequent patches. This is based on work by Ævar Arnfjörð Bjarmason. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Tan committed
Feb 25, 2019 at 13:54 UTC
8cbeba063250bf55f73921702209df10ed186e9e
4 files changed
+21
-4
protocol.c
+15
-2
@@ -17,6 +17,10 @@ static enum protocol_version parse_protocol_version(const char *value)
17
enum protocol_version get_protocol_version_config(void)
18
{
19
const char *value;
20
+ enum protocol_version retval = protocol_v0;
21
+ const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION";
22
+ const char *git_test_v = getenv(git_test_k);
23
+
24
if (!git_config_get_string_const("protocol.version", &value)) {
25
enum protocol_version version = parse_protocol_version(value);
26
@@ -24,10 +28,19 @@ enum protocol_version get_protocol_version_config(void)
28
die("unknown value for config 'protocol.version': %s",
29
value);
30
27
- return version;
31
+ retval = version;
32
+ }
33
+
34
+ if (git_test_v && *git_test_v) {
35
+ enum protocol_version env = parse_protocol_version(git_test_v);
36
+
37
+ if (env == protocol_unknown_version)
38
+ die("unknown value for %s: %s", git_test_k, git_test_v);
39
+ if (retval < env)
40
+ retval = env;
41
}
42
30
- return protocol_v0;
43
+ return retval;
44
}
45
46
enum protocol_version determine_protocol_version_server(void)
t/README
+3
@@ -327,6 +327,9 @@ marked strings" in po/README for details.
327
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
328
test suite. Accept any boolean values that are accepted by git-config.
329
330
+GIT_TEST_PROTOCOL_VERSION=<n>, when set, overrides the
331
+'protocol.version' setting to n if it is less than n.
332
+
333
GIT_TEST_FULL_IN_PACK_ARRAY=<boolean> exercises the uncommon
334
pack-objects code path where there are more than 1024 packs even if
335
the actual number of packs in repository is below this limit. Accept
t/t5400-send-pack.sh
+1
-1
@@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' '
288
$shared .have
289
EOF
290
291
- GIT_TRACE_PACKET=$(pwd)/trace \
291
+ GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION= \
292
git push \
293
--receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \
294
fork HEAD:foo &&
t/t5551-http-fetch-smart.sh
+2
-1
@@ -43,7 +43,8 @@ test_expect_success 'clone http repository' '
43
< Cache-Control: no-cache, max-age=0, must-revalidate
44
< Content-Type: application/x-git-upload-pack-result
45
EOF
46
- GIT_TRACE_CURL=true git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
46
+ GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION= \
47
+ git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
48
test_cmp file clone/file &&
49
tr '\''\015'\'' Q <err |
50
sed -e "