Commit Graph

7202 Commits

Author SHA1 Message Date
Steven Brown
b97c015cd5 check-code: check for consistent usage of the websub filter in hgweb templates
The check-code tool now expects the "desc" keyword to be followed by the
"websub" filter, with the following exceptions:
a) It has no filters at all, e.g. a changeset description in the raw style
   templates or the repository description in the summary page.
b) It is followed by the "firstline" filter, e.g. the first line of the
   changeset description is displayed as a summary or title.
2014-05-17 17:11:06 +08:00
Steven Brown
1226430636 hgweb: apply websub filter to the changeset description in rss and atom feeds
For example, this is useful for linking from the feed reader to a bug tracker.

This follows the existing pattern used within the hgweb templates. With the
exception of the raw style, all usages of the changeset "desc" keyword are now
followed by either the "firstline" filter or the "websub" filter. When "websub"
is used, it always follows the "escape" filter.
2014-05-17 17:10:23 +08:00
Steven Brown
5f0b1e4110 tests: write the hgrc file for test-hgweb-commands.t with cat instead of echo
To improve the readability.
2014-05-17 17:09:46 +08:00
Steven Brown
3b270bc2bf tests: tests for the rss feeds
This matches the existing tests for the atom feeds.
2014-05-17 17:09:10 +08:00
Gregory Szorc
5b136e830c run-tests: execute tests via unittest
Now that unittest mode is functionally equivalent to the default mode,
we switch the default execution mode to unittest and remove the choice
of different execution modes.
2014-04-20 16:44:45 -07:00
Gregory Szorc
3a52928608 run-tests: implement Test.__str__
unittest sometimes does a str(test) and the default implementation
doesn't do the right thing. So we override it.
2014-04-22 13:37:27 -07:00
Gregory Szorc
1da160e9f3 run-tests: make failure reporting in unittest mode equivalent to default
Unlike unittest's defaults, our result formatter does not print stack
traces. Here, we change TestResult.addFailure() to be compatible with
the existing/default execution mode.
2014-04-21 12:15:55 -07:00
Gregory Szorc
9b379f8c82 run-tests: ignore failures from rmtree
rmtree() may fail under certain conditions. We ignore failures at the
individual test level because they can interfere with test execution.
Furthermore, we'll reattempt deletion in the high-level test runner
after all tests have finished.

Note that this patch is not a code refactor like most of the patches
before it. This change logically makes sense given the execution
behavior of the tests.
2014-04-20 16:54:51 -07:00
Gregory Szorc
1275a4e261 run-tests: abort tests after first failure in unittest mode
There is an execution mode on run-tests.py that stops after the first
failure. unittest mode was previously not obeying this option. This
patch fixes that.
2014-04-20 16:53:49 -07:00
Gregory Szorc
e6a894b09e run-tests: print compatible output from TextTestRunner
Our unittest TextTestRunner now prints output similar to the output
from the default execution mode - the output people expect from
run-tests.py.
2014-04-20 16:39:05 -07:00
Gregory Szorc
6eb1131c5c run-tests: don't print results in unittest mode
A subsequent patch will have unittest print tests for us. Don't perform
old-style printing when in unittest mode.
2014-04-20 16:17:18 -07:00
Gregory Szorc
15b613915a run-tests: move errpath deletion to setUp() 2014-04-20 15:53:25 -07:00
Gregory Szorc
1cba8e1ca6 run-tests: kill daemons during tearDown() 2014-04-20 15:46:34 -07:00
Gregory Szorc
960b628f9a run-tests: move err file writing to tearDown() 2014-04-21 09:30:11 -07:00
Gregory Szorc
8cee2c5a3b run-tests: refactor testtmp
testtmp is now a member variable of our test class. It's value is
computed during instance creation and the directory is managed via the
lifetime of the test object.
2014-04-20 15:40:22 -07:00
Gregory Szorc
5f83d4f3ae run-tests: store skipped state on Test
As code is being moved between functions, we need a member variable to
hold skipped state.
2014-04-20 15:19:21 -07:00
Gregory Szorc
57a48ec516 run-tests: move some functionality to Test.tearDown() 2014-04-20 15:16:29 -07:00
Gregory Szorc
6571ca3b17 run-tests: store last result in Test._result
Subsequent patches move post-test actions into tearDown(). This requires
tearDown() to have access to the last result.
2014-04-20 15:08:05 -07:00
Gregory Szorc
9692484ea6 run-tests: report test duration in Test.tearDown() 2014-04-20 15:00:13 -07:00
Gregory Szorc
33fe327c22 run-tests: store test return code and output in Test instance
A subsequent patch that will introduce tearDown() requires test
execution state be stored in the instance.
2014-04-20 14:58:36 -07:00
Gregory Szorc
879667e23b run-tests: keep track of test start and stop in MercurialTest.run()
This brings run() more compatible with unittest.TestCase.run()
2014-04-20 14:55:33 -07:00
Gregory Szorc
3e73bf2558 run-tests: keep track of test execution state in Test
This patch starts a mini series of moving functionality into the
newly-established setUp() and tearDown() methods.
2014-04-20 14:52:57 -07:00
Gregory Szorc
ecba404b77 run-tests: support setUp() and tearDown() in TestCase wrapper
unittest.TestCase.run() calls setUp() and tearDown() during run(). We
emulate that implementation.
2014-04-20 14:41:11 -07:00
Gregory Szorc
ed53d7b15f run-tests: fail tests by raising an exception
When in unittest mode, Test.run() will now raise for all non-success
cases. This makes it behave like TestCase.run().
2014-04-20 14:34:03 -07:00
Gregory Szorc
213e98d278 run-tests: record warnings by raising WarnTest
We continue the conversion of recording test results by raising
exceptions.
2014-04-20 14:32:03 -07:00
Gregory Szorc
6e670d3e0a run-tests: record ignored tests by raising IgnoreTest 2014-04-20 14:28:29 -07:00
Gregory Szorc
b081b3f5c7 run-tests: record skips by raising SkipTest
The unittest way of recording a skipped test is to raise an exception
(at least with modern unittest implementation). We change Test to raise
a SkipTest when operating in unittest mode.

This does prevent some "tear down" activities from running in unittest
mode. This will be fixed in subsequent patches. Since unittest mode
is experimental, this should be OK.
2014-04-20 14:23:50 -07:00
Gregory Szorc
d51445e339 run-tests: implement TestCase.run()
Simply wrapping TestCase.run() is not sufficient for robust results
reporting because unittest in Python 2.4 does not know about things
like skipped tests and reports them as success or failures instead of
skips.

We will reimplement TestCase.run() with knowledge and semantics present
in modern Python releases.
2014-04-20 14:19:59 -07:00
Gregory Szorc
a0c6a9e1c4 run-tests: don't print progress from Test when in unittest mode
unittest does its own printing of progress indicators as part of
TestResult. So, there is no need to print them when running in unittest
mode.

This will fix the double output of progress indicators that had been
occurring in unittest mode.
2014-04-20 14:04:37 -07:00
Gregory Szorc
b876964617 run-tests: define a custom TestSuite that uses _executetests()
We now have a custom unittest.TestSuite implementation that uses
_executetests() and thus knows how to execute tests concurrently.
Running tests in --unittest mode will use this TestSuite.

Since the TestSuite handles concurrency, the warnings around --jobs and
--loop have been removed.
2014-04-20 13:04:19 -07:00
Gregory Szorc
96ddafcb17 run-tests: pass an optional TestResult into _executetests()
If the result is passed, we execute tests in the unittest way. A
subsequent patch will actually do this.
2014-04-20 13:00:40 -07:00
Gregory Szorc
797b5410f7 run-tests: pass Test instances into TestRunner._executetests()
Test instances (not paths) are passed into _executetests(). This means
the logic for instantiating Test instances has been moved outside of
_executetests(). This was done because an upcoming patch will reuse the
logic in _executetests().

As part of this change, test counts are no longer managed by
_executetests().
2014-04-20 12:49:43 -07:00
Gregory Szorc
30b889d02b run-tests: define cleanup() on unittest class
We need a cleanup() on our unittest TestCase class to conform with the
execution API. This will eventually be replaced by tearDown().
2014-05-17 12:35:44 -07:00
Gregory Szorc
1642f0bd4a run-tests: rename Test._test to Test.name
A lot of the attributes in Test could probably be renamed. This one is
needed for an upcoming patch.
2014-04-20 12:45:44 -07:00
Gregory Szorc
a808568b8a run-tests: teach Test instances whether they are in unittest mode
Tests executing in unittest mode behave a little differently. For
example, they report their results to a TestResult rather than just
printing. This patch paves the way for better integration of Test into
the unittest framework.
2014-04-20 12:19:48 -07:00
Gregory Szorc
860d201bb5 run-tests: teach unittest about warned results 2014-04-20 11:55:02 -07:00
Gregory Szorc
fb96114811 run-tests: document how success code is handled 2014-04-20 11:52:41 -07:00
Gregory Szorc
c9f14940a6 run-tests: teach unittest about ignored tests 2014-04-20 11:51:11 -07:00
Gregory Szorc
6de0802f27 run-tests: teach unittest about skipped tests 2014-04-20 11:48:19 -07:00
Gregory Szorc
103002df37 run-tests: define custom result and runner classes for unittest
We need to teach unittest about some custom result types. This will
require some custom classes. This patch creates a skeleton for them.
2014-04-20 11:47:40 -07:00
Gregory Szorc
a8a9760698 run-tests: start to report test results against TestResult
Previously, our unittest wrapper didn't report results properly. We now
properly report failures.

We had to rename the local variable to prevent "t" from being
overwritten in the local scope.
2014-04-20 11:29:39 -07:00
Gregory Szorc
95998c9339 run-tests: give unittest wrapper a short description
This will make the output contain something useful rather than the
default repr() for the class.
2014-04-20 11:24:37 -07:00
Gregory Szorc
4c1aec1cac run-tests: initial support for running tests with unittest
The unittest package in Python's standard library provides an almost
universal mechanism for defining and running tests. This patch starts
the process of making run-tests.py talk to it.

The main benefit of speaking unittest is that this will enable
Mercurial's tests to be more easily consumed by other testing tools,
like nose. This is useful for 3rd party extensions having their own
test infrastructure, for example.

Running tests in unittest mode will not result in completely sane
behavior until the unittest mode is made the default execution mode.
Expect things like double printing of output until support stabilizes.
2014-04-20 11:22:08 -07:00
Pierre-Yves David
c84e682681 test: split test-largefile.t in multiple file
The `test-largefiles.t` unified test is significantly longer (about 30%) than
any other tests in the mercurial test suite. As a result, its is alway the last
test my test runner is waiting for at the end of a run.

In practice, this means that `test-largefile.t` is wasting half a minute of my
life every times I'm running the mercurial test suites. This probably mean more
a few cumulated day by now.

I've finally decided to split it up in multiple smaller tests to bring it back in
reasonable length.

This changeset extracts independent test cases in two files. One dedicated to
wire protocole testing, and another one dedicated to all other tests that could
be independently extracted.

No test case were haltered in the making of this changeset.

Various timing available below. All timing have been done on a with 90 jobs on a
64 cores machine. Similar result are shown on firefly (20 jobs on 12 core).

General timing of the whole run
--------------------------------

We see a 25% real time improvement for no significant cpu time impact.

Before split:

    real   2m1.149s
    user  58m4.662s
    sys   11m28.563s

After split:

    real   1m31.977s
    user  57m45.993s
    sys   11m33.634s


Last test to finish (using run-test.py --time)
----------------------------------------------

test-largefile.t is now finishing at the same time than other slow tests.

Before split:

    Time      Test
    119.280   test-largefiles.t
     93.995   test-mq.t
     89.897   test-subrepo.t
     86.920   test-glog.t
     85.508   test-rename-merge2.t
     83.594   test-revset.t
     79.824   test-keyword.t
     78.077   test-mq-header-date.t

After split:

    Time      Test
    90.414   test-mq.t
    88.594   test-largefiles.t
    85.363   test-subrepo.t
    81.059   test-glog.t
    78.927   test-rename-merge2.t
    78.021   test-revset.t
    77.777   test-command-template.t



Timing of largefile test themself
-----------------------------------

Running only tests prefixed with "test-largefiles".
No significant change in cumulated time.

Before:

    Time     Test
    58.673   test-largefiles.t
     2.931   test-largefiles-cache.t
     0.583   test-largefiles-small-disk.t

After:

    Time     Test
    31.754   test-largefiles.t
    17.460   test-largefiles-misc.t
     8.888   test-largefiles-wireproto.t
     2.864   test-largefiles-cache.t
     0.580   test-largefiles-small-disk.t
2014-05-16 13:18:57 -07:00
FUJIWARA Katsunori
9af54bf260 mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qrefresh/qfold)
This patch also replaces "editor = False" by "editor =
cmdutil.getcommiteditor()", because:

  - it allows to hook commit message determination easily, even in the
    case without "--edit"

  - it avoids regression (or additional care) around saving
    "last-message.txt", even if MQ's "newcommit()" changes its
    implementation logic from "localrepository.commit" to
    "localrepository.commitctx" with "memctx" in the future

    to save commit message into "last-messge.txt" with "memctx",
    "editor" should be valid function.
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
55e621635c mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qnew)
This patch also replaces "editor = False" by "editor =
cmdutil.getcommiteditor()", because:

  - the latter allows to hook commit message determination easily,
    even in the case without "--edit"

  - the latter can avoid regression (or additional care) around saving
    "last-message.txt", even if MQ's "newcommit()" changes its
    implementation logic from "localrepository.commit" to
    "localrepository.commitctx" with "memctx" in the future

    to save commit message into "last-messge.txt" with "memctx",
    "editor" should be valid function.
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
4b34ba6872 tag: use the editor gotten by "getcommiteditor()" instead of "ui.edit()"
This patch also enhances "test-tag.t", because "hg tag" hasn't been
explicitly tested around editor invocation and "--edit" option.
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
308518c1e9 import: use "getcommiteditor()" instead of explicit editor choice
This patch also enhances "test-import-bypass.t" and "test-import.t",
because "hg import" hasn't been explicitly tested around editor
invocation and "--edit" option.

This patch explicitly tests below:

    - with "--bypass" (regardless of "--edit"):
        - not invoked, if the patch contains the commit message
        - not invoked, if the commit message is explicitly specified
        - invoked, otherwise (just adding comment)

    - without "--bypass":
        - with "--edit":
            - not invoked, if "--no-commit" is not specified
            - invoked, otherwise
        - without "--edit":
            - not invoked, if the patch contains the commit message
            - not invoked, if "--message" or "--logfile" is specified
              (just adding comment)
            - invoked, otherwise
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
67f9c7382a graft: use "getcommiteditor()" instead of explicit editor choice
This patch also enhances "test-graft.t", because "hg graft" hasn't
been explicitly tested around editor invocation and "--edit" option.
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
0aeb4a2423 backout: use "getcommiteditor()" instead of explicit editor choice
This patch also enhances "test-backout.t", because "hg backout" hasn't
been explicitly tested around editor invocation and '--edit' option.
2014-05-11 00:49:36 +09:00