Commit Graph

13 Commits

Author SHA1 Message Date
David M. Carr
c0ec4f8882 tests: remove mercurial version check from test-pull-after-strip.t
This test was being skipped in Mercurial < 1.5.  We don't support Mercurial
that old any more, so there isn't a need to worry about it in the tests.
2012-11-03 19:20:39 -04:00
David M. Carr
7fc5793d3d tests: convert echos to comments
Now that we're in the unified test format, there isn't a need to use echo
to provide context to command output.  This technique actually ends up resulting
in redundant output.  To preserve the original context, but eliminate the
redundancy, such echo statements have been converted into comment lines.
2012-11-03 19:14:17 -04:00
David M. Carr
ef24ee33fc tests: avoid changing the current directory
Mercurial allows specifying which repository to use via the -R/--repository
option.  Git allows a similar function using the --git-dir option.  By using
these options, in many cases we can avoid checking the current directory.
This makes tests easier to understand, as you don't need to remember which
directory you're in to understand what's going on.  It also makes tests easier
to write, as you don't need to remember to cd out of a directory when you're
done doing things there.

Thanks to Felipe Contreras for the patch which this was based on.
2012-11-03 19:12:08 -04:00
David M. Carr
33f1efdddf tests: extract git command-line client and dulwich requirements into testutil
One or both of these requirements were in almost every test in exactly the same
way.  Now, these checks are performed in every test that uses the testutil.
This makes it easier for test authors to add these checks into new tests (just
add a reference to the testutil, which you'd probably want anyway).

We considered having each test declare their requirements (currently, either
"git" or "dulwich"), but in this case, preferred the simplicity of having the
check always performed (even if a particular test doesn't need one or the
other).  You can't perform any meaningful testing of Hg-Git without both of
these dependencies properly configured.  The main value to checking for them
in the tests (rather than just letting the tests fail) is that it gives a
meaningful error message to help people figure out how to fix their environment.
In the case that either git or dulwich is missing, the information will be
just as clearly conveyed regardless of whether its all the tests that are
skipped, or just most of them.

I didn't add dulwich to hghave (even though this is clearly the sort of thing
that hghave is intended for) because hghave is currently pulled from Mercurial
completely unchanged, and it's probably best to keep it that way.

Tested by running the tests in three configurations:
 * No dulwich installed (ran 0, skipped 28, failed 0, output:
        Skipped *: missing feature: dulwich)
 * Bad git on path (ran 1, skipped 27, failed 0, output:
        Skipped *: missing feature: git command line client)
 * Working git and correct version of dulwich installed
        (ran 28, skipped 0, failed 0)

Thanks to Felipe Contreras for the idea to extract this logic into a library.
2012-11-03 19:11:50 -04:00
David M. Carr
905e581176 tests: let git init create directories when applicable
It's functionally equivalent to create a directory, cd into it, git init, and
cd out of the directory, or simply git init with the directory specified.

In several cases, we were doing the former without performing any other
operations in the git repo, which just made the test unneccesarily complex.
Even in the case where we still want to cd into the directory, calling git
init with the directory name eliminates the need for a separate mkdir command.

This changeset converts the former approach to the latter with the goal of
increasing the readability of the tests.

Thanks to Felipe Contreras for the patch which this was based on.
2012-10-31 00:01:03 -04:00
David M. Carr
d1a4bffd12 tests: extract commonly used commit/tag functions into testutil library
Thanks to Felipe Contreras for the patch which this was based on.

The functions were renamed to make it clearer that these are shell functions
rather than normal git/hg commands, and to make it clearer which tool is being
invoked.

Old name | New name
------------------------
commit   | fn_git_commit
tag      | fn_git_tag
hgcommit | fn_hg_commit
hgtag    | fn_hg_tag

Extraction from test-encoding.t was left for a subsequent patch, as I was seeing
unexpected output changes when I attempted the extraction.

The gitcommit and hgcommit functions in test-bookmark-workflow.t were left
as-is for now, as they have a different behavior than the standard version
(separate counters for each).
2012-10-30 22:59:20 -04:00
David M. Carr
8d69bf5e9a tests: extract extension configuration into a testutil library
Thanks to Felipe Contreras for the patch which this was based on.

Even though the MQ extension was only used in a single test
(test-pull-after-strip.t), I included it in the testutil.  It shouldn't hurt
anything to have it enabled and not used, and saves us from having to deal
with enabling extensions in individual tests at all.

Similarly, this changeset results in the graphlog extension being enabled
for all tests, even though there were some that didn't use it before.  This is
even less significant in Mercurial 2.3+, since in those versions, graphlog is
part of core, and is available even when the extension is disabled.
2012-10-30 20:03:26 -04:00
David M. Carr
57982de0d4 tests: uncomment calls to hghave git
Now that hghave git works properly, uncomment the calls, and add ones that were
missing.
2012-10-29 00:17:55 -04:00
David M. Carr
7168922e8f gitrepo: initial support for listkeys
This changeset adds test coverage for comparing "hg outgoing -B" in normal
Mercurial usage with Hg-Git usage.  This didn't match, since previously, gitrepo
didn't provide a meaningful listkeys implementation.  Now, it does.

gitrepo now has access to a GitHandler when a localrepo is available.  This
handler is used to access the information needed to implement listkeys for
namespaces (currently, only bookmarks) and bookmarks.

A couple of other tests were testing "divergent bookmark" scenarios.  These
tests have been updated to filter out the divergent bookmark output, as it isn't
consistent across the supported Mercurial versions.
2012-10-25 20:49:08 -04:00
David M. Carr
f6564520bb tests: eliminate use of git-daemon
Dulwich now supports local repositories just fine.  Not using the daemon makes
the tests easier to read and more reliable (less likely to be skipped because
a stray daemon is holding onto the port).
2012-09-13 20:49:45 -04:00
David M. Carr
77a9e3062f tests: remove piping of command git init to remove leading path
In many cases we were piping to a python script to strip out the varying leading
path to the test repos.  This is no longer needed, as the modern run-test.py
automatically substitutes the leading path as $TESTTMP.  Eliminating the piping
makes the tests easier to read and write, as well as allowing the exit codes
to be verified by the test.
2012-09-13 20:49:42 -04:00
David M. Carr
91ca9b4626 tests: remove configuration of bookmarks extension
All of our supported Hg versions include bookmarks in core.  Thus, actovating
it in the hgrc and setting bookmarks.track.current are no longer needed.
2012-09-13 20:48:11 -04:00
David M. Carr
4665bf2530 tests: unify test-pull-after-strip 2012-09-10 00:27:44 -04:00