Commit Graph

7217 Commits

Author SHA1 Message Date
Gregory Szorc
b1c9f22ffa run-tests: pass a full test path into Test.__init__
Previously, a Test's path came from the base directory of all tests and
a filename leaf. There is not a strong reason why an absolute test path
can not be specified.

This change isn't strictly necessary. But it does enable scenarios such
as more easily running tests from multiple, non-sibling directories.
2014-04-22 10:01:22 -07:00
Gregory Szorc
50b1663f63 run-tests: factor refpath into Test classes
refpath is a side-effect of the test type. We therefore move it to the
Test class implementations.
2014-04-21 16:43:36 -07:00
Gregory Szorc
42d448ded4 run-tests: don't trap exceptions in Test.runTest()
Exceptions are all handled in Test.run(). This code was redundant since
the unittest test wrapper class was merged into Test.
2014-04-20 18:23:48 -07:00
Gregory Szorc
803865798c run-tests: factor options out of run()
We were only utilizing 2 parts of options. These have been converted to
named arguments.
2014-04-20 18:20:24 -07:00
Mads Kiilerich
3af50396f2 convert: mercurial source: convert global tags only - not local tags
Mercurial tags can be local (tag -l, stored in .hg/localtags) or global (normal
tags, tracked in .hgtags) ... or extensions can add other kind of tags.

Convert would take all tags (except "tip"), not just the ones from .hgtags, and
put them into .hgtags.

Instead, convert only the global tags that come from .hgtags.
2014-05-16 02:30:27 +02:00
Gregory Szorc
8e80b0bd22 run-tests: refactor temporary directories in Test
We no longer need cleanup() because setUp() and tearDown() cover it. We
move tempdir creation into setUp() and always delete in tearDown()
2014-04-20 18:15:38 -07:00
Gregory Szorc
0024c28a10 run-tests: move _executetests into TestSuite 2014-04-20 17:42:31 -07:00
Gregory Szorc
fd2322f58b run-tests: capture execution times in TestResult
TestResult has facilities for recording when tests start and stop. It
makes sense to move execution time recording into TestResult.

In addition, output generation is being moved into TestResult, a class
that has a concept of an output buffer (and a lock).
2014-04-20 17:39:26 -07:00
Gregory Szorc
b583c9eacb run-tests: move outputtimes() into unittest runner class
The unittest runner now does all the printing. Move outputtimes() there.
2014-04-20 17:28:24 -07:00
Gregory Szorc
d9c2ef0a49 run-tests: refactor how times are recorded
We now record times in Test.run(), which is a more appropriate place for
it.
2014-04-20 17:21:24 -07:00
Gregory Szorc
3c3efa484d run-tests: eliminate Test._result
The result of test execution is now reported on a TestResult. We no
longer need to store a tuple of the result.
2014-04-20 17:13:10 -07:00
Gregory Szorc
0f26e878dd run-tests: replace Test.ignore() with raise IgnoreTest 2014-04-20 17:10:49 -07:00
Gregory Szorc
352b2437a3 run-tests: replace Test.skip() with raise SkipTest
All the result functions now raise an Exception. We no longer need these
functions and we can inline the raise.
2014-04-20 17:09:52 -07:00
Gregory Szorc
2d619ddf2b run-tests: remove some legacy code around result handling
unittest handles all results now. We no longer need to manually keep
track of results.
2014-04-20 17:06:57 -07:00
Gregory Szorc
e9f9523063 run-tests: merge MercurialTest into Test
Now that we execute all tests via unittest, the MercurialTest wrapper is
not necessary. This patches moves the logic from MercurialTest into Test
and makes Test a child of unittest.TestCase.
2014-04-20 17:04:42 -07:00
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