Commit Graph

760 Commits

Author SHA1 Message Date
Matt Mackall
78b956ae0c run-tests: output diffs with only forward slashes
This removes some gratuitous variance when testing on Windows with
test-run-tests.t.
2014-10-23 13:44:34 -05:00
Yuya Nishihara
df336dc3c8 ui: separate option to show prompt echo, enabled only in tests (issue4417)
The problem in commandserver was addressed by 766cfbe766dc, but it is tricky
to reuse ui.nontty option to disable echo back.  Instead, this patch introduces
new option to enable echoing of prompt response.

Prompt echoing is changed to be off by default, which should avoid possible
breakage of output parsing in user scripts.

For now, this option is undocumented because it exists for internal use.
2014-10-21 23:16:46 +09:00
Yuya Nishihara
f15ba4e058 run-tests: clean up unused globals that were removed by tests-refactor series
They were demoted to instance variables by bd9cce5752d6, c59bb1e35f8c,
12bbe81716c1, b9b6ea3c673c, ac4e4d32cde4 and 7212772d393e.
2014-10-18 21:52:11 +09:00
Kyle Lippincott
95982a95be run-tests: more accurate/helpful message than "diff generation failed"
Diff generation didn't really fail, it recognized that an hg serve server has
failed to start, and thus skipped the diff generation intentionally.

The most common reason for a server to fail to start is that the port was
already in use, so output HGPORT as well, to help finding it (since pgrep -f
'hg serve' is not sufficient, if the command line is something like 'hg -R main
serve')
2014-10-09 17:00:29 -07:00
Augie Fackler
dcb03fe445 run-tests: handle --jobs and --first gracefully
Without this change, --first causes currently-running tests to explode
in violent and surprising ways when their temporary directory gets
cleaned up. Now we just suppress failure messages from non-first
failures when running in --first mode.
2014-10-09 15:10:40 -04:00
anuraggoel
7937672970 run-tests: added 'cuser', 'csys' time info in report.json file
This patch adds up a 'cuser' and 'csys'(cputime) info in report.json file
which generated when --json is enabled while testing.

Now the new format of report.json file is as below.

testreport ={
    "test-success.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "success",
        "time": "2.041"
    }
    "test-failure.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "failure",
        "time": "4.430"
    }
    "test-skip.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "skip",
        "time": "3.754"
    }
}
2014-09-19 07:23:10 +05:30
anuraggoel
98bc0018a9 run-tests: added '--json' functionality to store test result in json file
This patch added a new functionality '--json'. While testing, if '--json'
is enabled then test result data gets stored in newly created "report.json"
file in the following format.

testreport ={
    "test-success.t": {
        "result": "success",
        "time": "2.041"
    }
    "test-failure.t": {
        "result": "failure",
        "time": "4.430"
    }
    "test-skip.t": {
        "result": "skip"
            "time": "3.754"
    }
}

Otherwise, if '--json' is enabled but json module was not installed then it
will raise an error "json module not installed".

This "report.json" file will further accessed by html/javascript file for
graph usage.
2014-09-08 16:41:00 +02:00
Gregory Szorc
6f5ee93aca run-tests: make --interactive work with --view 2014-08-31 12:22:44 +02:00
Mads Kiilerich
33397f4828 run-tests: report skipped tests as "skipped" - they might still be "relevant" 2014-08-26 22:03:30 +02:00
Matt Mackall
25d1182c5d merge with stable 2014-08-14 15:21:48 -05:00
Matt Mackall
1fc52a716b run-tests: fix some io ordering
backported from default
2014-08-13 18:50:35 -05:00
Matt Mackall
158e001efc run-tests: don't double lines on build failure output 2014-08-12 11:17:29 -05:00
Matt Mackall
4437029857 run-tests: self-test on Windows needs binary streams 2014-08-12 11:02:30 -05:00
Matt Mackall
ee564a47d4 merge with stable 2014-08-12 17:22:57 -05:00
Matt Mackall
a9cc11268b run-tests: don't show 'i' for tests that don't match a keyword 2014-08-12 00:33:48 -05:00
Matt Mackall
02873686da run-tests: attempt to fix iolock handling
Ideally, when using -j and -i together, when a prompt comes up, we'd
like all other output to wait (but testing to continue!). This gets
other output to wait by adding back a bunch of the locking that
formerly existed. We switch to a recursive lock to deal with the
restructuring due to unittest compatibility.

Running tests continue to run, but now the scheduler doesn't schedule
any new tasks while waiting at a prompt because no task slots become
available due to result output happening in the thread and
blocking on the iolock.
2014-08-11 17:45:50 -05:00
Matt Mackall
99b86fb9bf run-tests: add #require to abort full test
This allows nuking a bunch of ugly hghave || exit 80 lines.
2014-08-06 10:34:54 -05:00
Augie Fackler
00009ae554 run-tests: add support for xunit test reports
The Jenkins CI system understands xunit reports natively, so this will
be helpful for anyone that wants to use Jenkins for testing hg or
extensions that use run-tests.py for their testing.
2014-08-05 21:17:11 -04:00
Augie Fackler
292ddbefc0 run-tests: fix test result counts with --keyword specified or skips occurring
This preserves the current behavior that excludes ignored or skipped
tests from the number of tests run, except when tests are ignored due
to the --retest flag.
2014-07-28 19:48:59 -04:00
Matt Mackall
e26bfca88b run-tests: add iolock to failure output 2014-08-04 14:42:24 -05:00
anuraggoel
0a9b451708 run-tests: '--time' option provide more details to Linux users
As our tests execute in child processes, this patch uses os.times()
module in replace of time.time() module to provide additional info like
user time and system time spent by child's processes along with real elapsed
time taken by a process.

There is one limitation of this patch. It can work only for Linux users and
not for Windows.

"os.times" module returns a 5-tuple of a floaing point numbers.
1) User time
2) System time
3) Child's user time
4) Child's system time
5) Ellapsed real time

On Windows, only the first two items are filled, the others are zero.
Therefore, below test cases does not break on Windows but instead gives the
zero value.
2014-06-26 01:22:50 +05:30
Matt Mackall
0eb76768ec run-tests: make --view work again 2014-07-18 17:52:18 -05:00
FUJIWARA Katsunori
ba5b3b9f46 filemerge: use 'basic' as the default of '[ui] mergemarkers' for safety
Before this patch, 'detailed' is used as the default of '[ui]
mergemarkers'. This embeds non-ASCII characters in tags, branches,
bookmarks, author and/or commit descriptions into merged files in the
encoding specified by '--encoding' global option, 'HGENCODING' or
other locale setting environment variables.

But, if files to be merged use another encoding, this behavior breaks
consistency of encoding in merged files.

For example, ISO-2022-JP or EUC-JP are sometimes used as the file
encoding for Japanese characters, because of historical and/or
environmental reasons, even though UTF-8 or Shift-JIS are ordinarily
used as the terminal encoding.

This can't be resolved automatically, because Mercurial doesn't aware
encoding of managed files.

This patch uses 'basic' as the default of '[ui] mergemarkers' to avoid
embedding encoding sensitive characters for safety.

This patch puts '[ui] mergemarkers = detailed' into default hgrc file
for tests, to reduce changes for tests in this patch.
2014-07-06 02:56:41 +09:00
Augie Fackler
3da9ad54da run-tests: write out scripts in binary mode
Caught because Python 3 refuses to write bytes to a non-binary fd.
2013-11-05 14:47:35 -05:00
Matt Mackall
e5948a69d1 run-tests: hold iolock across diff/prompt when interactive
Otherwise diff may get separated from the corresponding prompt by
other threads. This required moving the interactive prompting from one
helper method to another.
2014-06-18 20:51:49 -05:00
anuraggoel
56f12d427d run-tests: fixes the '--interactive' option error
This patch fixes a regression recently introduced by a refactoring.

Previously when failure occurs while testing with '--interactive' was enable,
it didn't prompt user by asking whether he wants to accept this failure
changes or not.

This was happening beacuse of the 'if' condition
if ret or not self._options.interactive or \
not os.path.exists(test.errpath):

Everytime failure occurs, this condition gets true and returns back even
when '--interactive' is enabled. This condition don't led the function to
execute further, which consist the '--interactive' functionality.

Now, on failure with '--interactive' enabled, it prompts user whether he wants
to accepts failure changes or not.
If yes then test gets passed  and returns true, else test gets failed.

On every failure, results gets stored in "self.failures.append((test, reason))"
But if failure changes accepted by user then test must get "pop out" from
failed test list.
2014-06-13 14:45:23 +05:30
anuraggoel
3226c7323f run-tests: checks behaviour of test on failure while testing
On failure while testing, if this function "result.addFailure(self, str(e))"
returns true then test get 'passed' else count as 'failed'.
2014-06-13 14:33:02 +05:30
anuraggoel
04c584a5dc run-tests: fixes the number of tests ran when '--retest' is enabled
This patch fixes a regression recently introduced by a refactoring. (see
a2d588d82fa2 and about 200 previous changesets from Gregory Szorc)

While retesting, that is when '--retest' is enabled, only failure tests run
and others either skipped or ignored.

During retesting, "result.testsRun" holds the count of failure test that has
run. But as while printing output, we have subtracted the skipped and ignored
count from "result.testsRun". Therefore, to make the count remain
the same, we need to add skipped and ignored count before printing.
2014-06-12 03:20:28 +05:30
anuraggoel
ad20794545 run-tests: skipped test should not produce 'i' mark while retesting
When '--retest' option is enabled then skipped test should not produce 'i' mark.
This fixes a regression introduced by a2d588d82fa2 and about 200 previous
changesets from Gregory Szorc.
2014-06-12 02:36:52 +05:30
Matt Mackall
e27ac051fd run-tests: filter whitespace at end of error diffs
Python 2.6 and 2.7 produce slightly different diff headers.
2014-06-13 16:36:53 -05:00
anuraggoel
8761fa590f run-tests: produce '!' mark after running a failing test
This patch  fixes a regression recently introduced by a refactoring (see
a2d588d82fa2 and about 200 previous changesets from Gregory Szorc).  '!' mark
denotes that the test gets failed while testing.
2014-06-12 01:28:22 +05:30
anuraggoel
6abace8ac1 run-tests: produce error on running a failing test
This patch fixes a regression recently introduced by a refactoring (see
a2d588d82fa2 and about 200 previous changesets from Gregory Szorc).  It produce
an error message everytime with a test filename which gets fail while testing
except at one condition when '--nodiff' option is enabled.
2014-06-12 01:36:57 +05:30
Pierre-Yves David
31b8a93ca3 run-tests: don't check for the mercurial library used when using --with-hg
In the ``--with-hg`` case, we cannot properly infer the location of the mercurial
library, so we skip the warning completely.
2014-06-10 14:32:52 -07:00
Gregory Szorc
c498780367 run-tests: write .err files earlier
Earlier refactoring of run-tests.py accidentally broke --interactive
and external diff generation by not having .err files written before
they are consulted. This patch fixes that.
2014-05-27 19:21:12 -07:00
Gregory Szorc
a52d8f80c9 run-tests: exit with non-0 exit code when tests fail or warn
As part of the run-tests.py refactor, run-tests.py accidentally started
exiting with 0 for most test runs. This patch restores the expected
behavior.
2014-05-27 19:10:22 -07:00
Mads Kiilerich
c9533b7029 run-tests: assign value to ESCAPEMAP - dict.update do not return self
5819a76729ab did more than what the description said and introduced a bug.
2014-05-25 13:47:42 +02:00
Mads Kiilerich
b478aa67c2 run-tests: fix invalid reference to stringescape after 5819a76729ab 2014-05-25 13:47:19 +02:00
Gregory Szorc
9040584c9d run-tests: add docstrings 2014-05-09 16:13:14 -07:00
Gregory Szorc
84bd2471e4 run-tests: avoid duplicate code in vlog() 2014-05-09 15:55:58 -07:00
Gregory Szorc
419c755930 run-tests: make attributes of TestRunner internal
There is little reason for the data members of TestRunner to be public,
as they are implementation details. Enforce it through naming.
2014-04-25 15:34:28 -07:00
Gregory Szorc
dd51f9b9a4 run-tests: make testdir an argument of TestSuite.__init__
With this change, TestSuite no longer accesses anything on TestRunner
and the TestRunner is no longer passed to TestSuite.
2014-04-25 15:11:38 -07:00
Gregory Szorc
3893068a8d run-tests: move loop to a named argument of TestSuite.__init__ 2014-04-25 15:08:03 -07:00
Gregory Szorc
d4cf43f426 run-tests: make keywords a named argument to TestSuite.__init__
This was the last usage of option in ``TextTestRunner.run``.
2014-04-25 15:06:23 -07:00
Gregory Szorc
a9774725ac run-tests: make retest a named argument of TestSuite.__init__ 2014-04-25 15:03:06 -07:00
Gregory Szorc
829f7e62aa run-tests: move whitelist and blacklist to named arguments of TestSuite 2014-04-25 15:00:54 -07:00
Gregory Szorc
6884debc3f run-tests: pass jobs into TestSuite constructor
This starts a series of patches that will lessen the importance of
TestRunner. It will remove the TestRunner instance stored inside the
TestSuite.
2014-04-25 14:51:53 -07:00
Gregory Szorc
375be90a07 run-tests: move interactive test acceptance into TestResult
We shouldn't be performing interactive prompting during test execution.
The first step of this is to move the functionality into TestResult.
2014-04-22 13:32:05 -07:00
Gregory Szorc
70868f71e0 run-tests: raise WarnTest outside of Test.fail() 2014-04-22 13:25:17 -07:00
Gregory Szorc
382f52cba6 run-tests: move diff generation into TestResult
TestResult is the thing that captures all our test results. It's logical
for diff viewing to be handled there and not inside Test.

While writing this patch, it was discovered that Test.fail() was
printing redundant test result output. This has been removed.

Arguments controlling diffs have been removed from Test.__init__.
2014-04-22 13:16:34 -07:00
Gregory Szorc
cb478bcd7b run-tests: remove global abort flag
The global abort flag has been moved into each Test instance. A
Test.abort() accomplishing the same thing has been added.
2014-04-22 12:35:18 -07:00
Gregory Szorc
c2d6530853 run-tests: remove options from Test.__init__
All options are now passed as arguments and we no longer need options.

This enables us to instantiate Test from "plain old data" types. Since
options must be given as arguments, it also makes people think harder
about adding things that may not belong in Test. This will help ensure a
proper separation of responsibility going forward.
2014-04-22 12:20:10 -07:00
Gregory Szorc
5656f4586d run-tests: move shell to Test.__init__ 2014-04-22 12:17:23 -07:00
Gregory Szorc
285b810dae run-tests: move py3kwarnings to Test.__init__ 2014-04-22 12:15:55 -07:00
Gregory Szorc
7a6aa4b289 run-tests: move extra config options to Test.__init__ 2014-04-22 12:13:40 -07:00
Gregory Szorc
2bd392374e run-tests: refactor port number declaration
Instead of making port numbers derived from count and a global initial
port, we now pass a start port to Test.__init__ and do the calculation
at a higher level.
2014-04-22 12:10:25 -07:00
Gregory Szorc
e29eaf20cf run-tests: move timeout into Test.__init__ 2014-04-22 12:04:15 -07:00
Gregory Szorc
08548ac839 run-tests: move interactive to Test.__init__ 2014-04-22 12:01:31 -07:00
Gregory Szorc
7427586dc4 run-tests: move diff options into arguments of Test.__init__ 2014-04-22 11:58:32 -07:00
Gregory Szorc
d83a06e76b run-tests: move debug into an argument to Test.__init__ 2014-04-22 11:44:34 -07:00
Gregory Szorc
48b8b52024 run-tests: factor options.keep_tmpdir into an argument to Test.__init__ 2014-04-22 11:41:10 -07:00
Gregory Szorc
9edaec1d62 run-tests: remove redundant test name filter
TestSuite.run() doesn't need to filter tests by name because that
already happens elsewhere. Garbage in garbage out applies.
2014-04-22 12:29:33 -07:00
Gregory Szorc
d516d7b5e7 run-tests: move test filtering into TestSuite.run()
Upcoming patches will move the execution of tests to separate processes.
To facilitate this, it makes sense to move logic out of Test.
Furthermore, test filtering is logically the domain of the test runner,
not the test itself.

This patch interrupts our mini series of factoring options into named
arguments because filtering consults many options and it is easier to
move this logic out of Test sooner so we don't have to introduce
arguments at all.
2014-04-22 11:38:14 -07:00
Gregory Szorc
18e8487bdf run-tests: no longer pass a TestRunner into Test.__init__
We no longer access any attributes on TestRunner besides options, so we
stop passing a TestRunner to Test.__init__ and now pass the options
data structure instead.

Subsequent patches will move accessed options attributes into named
arguments.
2014-04-22 10:13:41 -07:00
Gregory Szorc
706551657a run-tests: pass abort into Test.__init__ 2014-04-22 10:12:19 -07:00
Gregory Szorc
71ca8805db run-tests: pass temp dir into Test.__init__
This patch starts a mini series of moving arguments to Test.__init__
from semi-complex data structures (such as the command options) to named
arguments. This will allow Test instances to be more easily instantiated
from other contexts. This improves the ability to run Mercurial tests in
new and different environments.
2014-04-22 10:05:32 -07:00
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
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
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
b262d9a640 run-tests: fix --interactive option
``TTest._testpath`` never existed. This must be the remain of some contributors
side refactoring.
2014-05-17 00:47:42 -07:00
Pierre-Yves David
d2c3815194 run-test: fix AttributeError in the --interactive prompt
One must choose between ``"y yes".split()`` and ``('y', 'yes')``. I choose the
later.

The feature still crash when you answer "yes" to use it. But at least, the
prompt itself works.
2014-05-17 00:38:48 -07:00
Pierre-Yves David
8b89a74c6f run-test: restore the -i prompt by write .err before checking if it exists
The `--interactive` flag workis by overwriting the original test file by its
`.err` version. So we need to write it before calling `self.fail`. Otherwise the
`.err` file does not exists and `--interactive` is ignored.

We can move that block code around because it is dedicated to write changed
output and we moves it in the try-except dedicated to handling changed output.

Note that the flog is still badly broken after this change. But at least it crash
instead of being ignored.
2014-05-17 00:37:06 -07:00
Gregory Szorc
1a9a4f69c5 run-tests: move _gethgpath() into TestRunner 2014-04-20 11:04:25 -07:00
Gregory Szorc
5d72ba5d0e run-tests: move string escaping to TTest
With this patch, TTest is almost fully self-contained and extractable.
Only logging functions remain outside of its class.
2014-04-20 10:34:52 -07:00
Gregory Szorc
29c42e357d run-tests: add some docstrings 2014-04-20 10:28:35 -07:00
Gregory Szorc
5be656d402 run-tests: move createhgrc into Test 2014-04-20 10:24:00 -07:00
Gregory Szorc
f91c5a5105 run-tests: move SKIPPED_PREFIX and FAILED_PREFIX into TTest 2014-04-20 10:19:58 -07:00
Gregory Szorc
a67c76a563 run-tests: move SKIPPED_STATUS into Test class 2014-04-20 10:16:36 -07:00
Gregory Szorc
3cae671831 run-tests: move parsehghaveoutput() into TTest
This patch starts a sequence of patches that will try to isolate
everything related to t tests into the TTest class.
2014-04-20 10:14:25 -07:00
Gregory Szorc
8d7902d08f run-tests: make some methods of TestRunner internal 2014-04-20 10:11:46 -07:00
Gregory Szorc
77377eb9f9 run-tests: eliminate main() 2014-04-20 10:09:23 -07:00
Gregory Szorc
f77a2632fd run-tests: move option parser logic to TestRunner.run() 2014-04-20 10:08:33 -07:00
Gregory Szorc
e8679e7082 run-tests: move umask into TestRunner.run()
We now properly restore the umask as well, since run() tries to clean up
after itself.
2014-04-20 10:06:19 -07:00
Gregory Szorc
1a7b678d41 run-tests: move checktools into TestRunner.run() 2014-04-20 10:05:00 -07:00
Gregory Szorc
9b509906ec run-tests: move test discovery into TestRunner.run() 2014-04-20 10:04:15 -07:00
Gregory Szorc
015f85c261 run-tests: move test shuffling and sorting into TestRunner 2014-04-20 10:03:08 -07:00
Gregory Szorc
6b2b768e30 run-tests: assign testdir in TestRunner 2014-04-20 10:00:59 -07:00
Gregory Szorc
f10ceaaa22 run-tests: move hash seed logic to TestRunner 2014-04-20 09:59:01 -07:00
Gregory Szorc
c5b81eb209 run-tests: move tmpdir calculations into TestRunner 2014-04-20 09:58:26 -07:00
Gregory Szorc
3a9dcd2480 run-tests: move more path calculations into TestRunner 2014-04-20 09:57:02 -07:00
Gregory Szorc
c63c3fe0f7 run-tests: move pypath manipulation into TestRunner 2014-04-20 09:54:28 -07:00
Gregory Szorc
d8efe9acf0 run-tests: establish TestRunner.run()
(amended by mpm to remove environ cleanup - unrelated change that
breaks on Solaris)
2014-04-20 09:49:33 -07:00
Gregory Szorc
e9f87a494b run-tests: move program searching into TestRunner 2014-04-20 09:44:39 -07:00
Gregory Szorc
85852466ca run-tests: allow TestRunner to be passed into main()
This allows 3rd parties to specify a custom TestRunner. This is useful
for providing your own test discovery mechanism, for example.
2014-04-20 09:40:27 -07:00
Gregory Szorc
8b959d83f2 run-tests: move test discovery logic into a function
The new function is easily monkeypatchable. This facilitates more
advanced test discovery by 3rd parties such as extensions.
2014-04-20 00:23:06 -07:00
Gregory Szorc
27d037f441 run-tests: move scheduletests() into TestRunner 2014-04-20 00:12:26 -07:00
Gregory Szorc
eec6cde13e run-tests: move abort global to TestRunner 2014-04-20 00:10:06 -07:00
Gregory Szorc
25b7330a18 run-tests: move runtests() into TestRunner 2014-04-20 00:06:30 -07:00
Gregory Szorc
e57adc8c20 run-tests: move results global into TestRunner 2014-04-20 00:03:32 -07:00
Gregory Szorc
ff5048b39c run-tests: move times global into TestRunner 2014-04-19 23:59:06 -07:00
Gregory Szorc
1b4a48f3dc run-tests: move gettest() into TestRunner 2014-04-19 23:53:23 -07:00
Gregory Szorc
2703caf446 run-tests: move outputcoverage() into TestRunner 2014-04-19 23:49:23 -07:00
Gregory Szorc
49cdc11656 run-tests: move outputtimes() into TestRunner 2014-04-19 23:47:59 -07:00
Gregory Szorc
f60ca60f88 run-tests: move checkhglib into TestRunner 2014-04-19 23:44:56 -07:00
Gregory Szorc
105c9c2fc1 run-tests: move installhg() into TestRunner 2014-04-19 23:43:00 -07:00
Gregory Szorc
023fa479ff run-tests: move createdfiles out of a global and into TestRunner 2014-04-19 23:39:38 -07:00
Gregory Szorc
a24163eef4 run-tests: move usecorrectpython() into TestRunner 2014-04-19 23:38:10 -07:00
Gregory Szorc
88e6be733b run-tests: move cleanup() into TestRunner 2014-04-19 23:35:27 -07:00
Gregory Szorc
e74d6a9170 run-tests: add options to runner 2014-04-19 23:33:44 -07:00
Gregory Szorc
691c3d4a63 run-tests: add options to runner 2014-04-19 23:28:59 -07:00
Gregory Szorc
fbb4e07860 run-tests: move COVERAGE_FILE out of a global 2014-04-19 23:27:11 -07:00
Gregory Szorc
cb55575cbf run-tests: move PYTHONDIR out of a global 2014-04-19 23:26:15 -07:00
Gregory Szorc
cd540cf8ab run-tests: move TMPBINDIR out of a global 2014-04-19 23:24:39 -07:00
Gregory Szorc
0b30c04fca run-tests: move BINDIR out of a global 2014-04-19 23:22:47 -07:00
Gregory Szorc
e4684a44f0 run-tests: move INST out of a global 2014-04-19 23:20:42 -07:00
Gregory Szorc
985af7905a run-tests: move HGTMP out of a global 2014-04-19 23:19:23 -07:00
Gregory Szorc
43a68f701f run-tests: move TESTDIR out of a global
This patch starts the process of removing global variables from
run-tests.py. The goal of this is to make it easier to run tests
differently without having to concern yourself with global state.
2014-04-19 23:15:24 -07:00
Gregory Szorc
6ac2fa2ac5 run-tests: establish a class to hold testing state 2014-04-19 23:07:17 -07:00
Gregory Szorc
a557fd6847 run-tests: refactor runone() into gettest() and scheduletests()
runone() has been removed. Replacing it are gettest() (which returns a
Test instance) and a small amount of boilerplate in scheduletests().
2014-04-19 22:02:55 -07:00
Gregory Szorc
cf638dcc58 run-tests: move computation of test paths into Test.__init__ 2014-04-19 21:53:15 -07:00
Gregory Szorc
2c78c23435 run-tests: move logging of test start into Test.run() 2014-04-19 21:50:23 -07:00
Gregory Szorc
0e7ab8a4df run-tests: remove remaining uses of TestResult 2014-04-19 21:21:57 -07:00
Gregory Szorc
a9a228cd32 run-tests: move output writing to Test.run() 2014-04-19 21:17:39 -07:00
Gregory Szorc
23754a084d run-tests: move err file saving to Test.run() 2014-04-19 21:14:31 -07:00
Gregory Szorc
d8e59715bf run-tests: emit exception failure result from Test.run() 2014-04-19 21:10:22 -07:00
Gregory Szorc
ac40d2296a run-tests: move test name filter to Test.run() 2014-04-19 21:08:03 -07:00
Gregory Szorc
266111b2d1 run-tests: move keyword processing into Test.run() 2014-04-19 21:05:50 -07:00
Gregory Szorc
d1cef4a6a1 run-tests: move retesting result to Test.run() 2014-04-19 21:04:08 -07:00
Gregory Szorc
e8004cbf37 run-tests: move blacklist skipping to Test.run() 2014-04-19 21:02:51 -07:00
Gregory Szorc
29ec1e08f4 run-tests: check for test file existence in Test.run()
We delay this a little bit. But it shouldn't really matter when the
check is performed.
2014-04-19 21:00:24 -07:00
Gregory Szorc
54e9611a41 run-tests: move remaining result processing to Test.run() 2014-04-19 20:53:45 -07:00
Gregory Szorc
49fbb46418 run-tests: move output difference processing to Test.run() 2014-04-19 20:52:58 -07:00
Gregory Szorc
fe13f7598d run-tests: generate timeout result in Test.run() 2014-04-19 20:48:16 -07:00
Gregory Szorc
3573cbd388 run-tests: add skip processing to Test 2014-04-19 20:47:14 -07:00
Gregory Szorc
d792278ce6 run-tests: move fail() into Test
The code was changed slightly as part of the migration to make use of
appropriate variables and modern Python conventions.
2014-04-19 20:41:08 -07:00
Gregory Szorc
42a72930a7 run-tests: move success() into Test 2014-04-19 20:35:54 -07:00
Gregory Szorc
8fab6ea01c run-tests: move err path handling to Test 2014-04-19 20:32:38 -07:00
Gregory Szorc
0dcb1a6ed2 run-tests: handle interrupted in Test.run() 2014-04-19 20:27:18 -07:00
Gregory Szorc
ddc2d7190f run-tests: kill daemons during Test.cleanup()
As a safety precaution, we kill daemons in Test.cleanup(). This is
necessary for a subsequent patch that will reraise KeyboardInterrupt
before killdaemons() runs as part of run().
2014-04-19 20:22:32 -07:00
Gregory Szorc
aa0568676a run-tests: capture reference output in Test.__init__
Reference output should be constant and doesn't need to be computed at
test execution time. We calculate it earlier.

This patch is the first in a mini series that will change how the
TestResult object works.
2014-04-19 18:50:40 -07:00
Gregory Szorc
c3bcf32fc2 run-tests: make globmatch a static method of TTest 2014-04-19 16:14:30 -07:00
Gregory Szorc
1b34005cfc run-tests: make rematch a static method of TTest 2014-04-19 16:13:02 -07:00
Gregory Szorc
19099dc4f1 run-tests: make linematch a static method of TTest
linematch only applies to t tests. It makes sense to move everything t
test related to the TTest class.
2014-04-19 16:11:49 -07:00
Gregory Szorc
df67209088 run-tests: finish moving tsttest() into TTest 2014-04-19 15:37:50 -07:00
Gregory Szorc
044e5b3e56 run-tests: move t test execution from tsttest() to TTest.run()
After this patch, tsttest() only contains output/result processing.
2014-04-19 15:28:31 -07:00
Gregory Szorc
21e213cf15 run-tests: move t test parsing into its own function
Test parsing is somewhat complicated. This patch extracts it into its
own function.

The impetus of this patch is folding tsttest() into the TTest class.
Subsequent patches will continue this work until tsttest() no longer
exists.
2014-04-19 15:19:28 -07:00
Gregory Szorc
4018f371bc run-tests: roll pytest() into PythonTest._run()
Python was the old runner function. It no longer needs to exist since
the PythonTest class took its job.
2014-04-19 14:54:04 -07:00
Gregory Szorc
bd0b5555d2 run-tests: remove threadtmp in Test.cleanup()
threadtmp is an implementation detail. We move the cleanup of this
directory to Test.cleanup() and make the variable internal. The
cleanup function will eventually disappear into unittest machinery.
2014-04-19 14:51:43 -07:00
Gregory Szorc
5b6c781b5d run-tests: allow Test.run() to run multiple times
Test.run() can now be executed multiple times on the same Test instance.
This feature is currently unused and there are no plans to implement it.
The main reason for this work was to refactor testtmp, replacements, and
env to be run-time specific as opposed to Test instance specific.
2014-04-19 14:47:34 -07:00
Gregory Szorc
d9fcd5b2f9 run-tests: capture reference output in TestResult class 2014-04-19 14:09:46 -07:00
Gregory Szorc
c1c96a878a run-tests: give TestResult a skipped attribute 2014-04-19 14:01:18 -07:00