1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 04:49:43 +01:00
git/t/interop
Jeff King 22ef5f02a8 t/interop: allow per-version make options
Building older versions of Git may require tweaking some build knobs. In
particular, very old versions of Git will fail to build with recent
OpenSSL, because the bignum type switched from a struct to a pointer.

The i5500 interop test uses Git v1.0.0 by default, which triggers this
problem. You can work around it by setting NO_OPENSSL in your
GIT_TEST_MAKE_OPTS variable. But there are two downsides:

  1. You have to know to do this, and it's not at all obvious.

  2. That sets the options for _all_ versions of Git that we build. And
     it's possible for two versions to require conflicting knobs. E.g.,
     building with "make NO_OPENSSL=Nope OPENSSL_SHA1=Yes" causes
     imap-send.c to barf, because it declares a fallback typedef for SSL.
     This is something we may want to fix, but of course many historical
     versions are affected, and the interop scripts should be flexible
     enough to build everything.

So let's introduce per-version make options, along with the ability for
scripts to specify knobs that match their default versions. That should
make everything build out of the box, but also allow testers flexibility
if they are testing interoperability between non-default versions.

We'll set NO_OPENSSL by default for v1.0.0 in i5500. It doesn't have to
worry about the conflict with OPENSSL_SHA1 because imap-send did not
exist back then (but if it did, it could also just explicitly use a
different hash implementation).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-12 13:27:36 -07:00
..
.gitignore
i0000-basic.sh
i5500-git-daemon.sh t/interop: allow per-version make options 2024-09-12 13:27:36 -07:00
i5700-protocol-transition.sh
interop-lib.sh t/interop: allow per-version make options 2024-09-12 13:27:36 -07:00
Makefile
README t/interop: allow per-version make options 2024-09-12 13:27:36 -07:00

Git version interoperability tests
==================================

This directory has interoperability tests for git. Each script is
similar to the normal test scripts found in t/, but with the added twist
that two special versions of git, "git.a" and "git.b", are available in
the PATH. Individual tests can then check the interaction between the
two versions.

When you add a feature that handles backwards compatibility between git
versions, it's encouraged to add a test here to make sure it behaves as
you expect.


Running Tests
-------------

The easiest way to run tests is to say "make".  This runs all
the tests against their default versions.

You can run a single test like:

    $ ./i0000-basic.sh
    ok 1 - bare git is forbidden
    ok 2 - git.a version (v1.6.6.3)
    ok 3 - git.b version (v2.11.1)
    # passed all 3 test(s)
    1..3

Each test contains default versions to run against. You may override
these by setting `GIT_TEST_VERSION_A` and `GIT_TEST_VERSION_B` in the
environment. Note that not all combinations will give sensible outcomes
for all tests (e.g., a test checking for a specific old/new interaction
may want something "old" enough" and something "new" enough; see
individual tests for details).

Version names should be resolvable as revisions in the current
repository. They will be exported and built as needed using the
config.mak files found at the root of your working tree.

The exception is the special version "." which uses the currently-built
contents of your working tree.

You can set the following variables (in the environment or in your config.mak):

    GIT_INTEROP_MAKE_OPTS
	Options to pass to `make` when building a git version (e.g.,
	`-j8`).

You can also pass any command-line options taken by ordinary git tests (e.g.,
"-v").


Naming Tests
------------

The interop test files are named like:

	iNNNN-short-description.sh

where N is a decimal digit.  The same conventions for choosing NNNN as
for normal tests apply.


Writing Tests
-------------

An interop test script starts like a normal script, declaring a few
variables and then including interop-lib.sh (which includes test-lib.sh).
Besides test_description, you should also set the $VERSION_A and $VERSION_B
variables to give the default versions to test against. See t0000-basic.sh for
an example.

You can then use test_expect_success as usual, with a few differences:

  1. The special commands "git.a" and "git.b" correspond to the
     two versions.

  2. You cannot call a bare "git". This is to prevent accidents where
     you meant "git.a" or "git.b".

  3. The trash directory is _not_ a git repository by default. You
     should create one with the appropriate version of git.

At the end of the script, call test_done as usual.

Some older versions may need a few build knobs tweaked (e.g., ancient
versions of Git no longer build with modern OpenSSL). Your script can
set MAKE_OPTS_A and MAKE_OPTS_B, which will be passed alongside
GIT_INTEROP_MAKE_OPTS. Users can override them per-script by setting
GIT_INTEROP_MAKE_OPTS_{A,B} in the environment, just like they can set
GIT_TEST_VERSION_{A,B}.