Commit Graph

619 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
7162b6792b run-tests.py: inherit --pure option from outer run-tests.py execution
Before this patch, "test-run-tests.t" doesn't test "run-tests.py" with
"--pure", even if outer "run-tests.py" is executed with it.

This patch uses not "HG_RUN_TESTS_PURE" but "HGTEST_RUN_TESTS_PURE",
because "HG_" prefixed environments are forcibly dropped in "_getenv()".

This is also useful to run "run-tests.py" successfully by
"run-tests.py --pure" on Windows without any compilation tools (like
VisualStudio).
2015-01-22 00:07:06 +09:00
FUJIWARA Katsunori
30be0460c5 run-tests.py: execute hghave with same env vars as ones for actual tests
Before this patch, "run-tests.py" executes "hghave" process without
any modifications for environment variables, even though actual tests
are executed with LC_ALL, LANG and LANGUAGE explicitly assigned "C".

When "run-tests.py" is executed:

  - with non-"C" locale environment variables on any platforms, or

  - without any explicit locale environment setting on Windows
    (only for "outer-repo" feature using "hg root")

external commands indirectly executed by "hghave" may show translated
messages.

This causes incorrect "hghave" result and skipping tests, because some
regexp matching of "hghave" expect external commands to show
un-translated messages.

To prevent external commands from showing translated messages, this
patch makes "run-tests.py" execute "hghave" with same environment
variables as ones for actual tests.

This patch doesn't make "hghave" execute external commands forcibly
with LC_ALL, LANG and LANGUAGE explicitly assigned "C", because
changing "run-tests.py" is cheaper than changing "hghave":

  - "os.popen" should be replaced by "subprocess.Popen" or so, and
  - setting up environment variables should be newly added
2015-01-22 00:03:58 +09:00
Mads Kiilerich
9f07fbbb15 run-tests: include testdir in $PATH so tests easily can use helper tools
The testdir is already added to $PYTHONPATH - I think it makes sense and is
convenient to add it to $PATH too.

The following binaries are invoked from tests using full path with $TESTDIR/ -
they can now be used without specifying path:
  dumbhttp.py
  dummyssh
  filterpyflakes.py
  generate-working-copy-states.py
  get-with-headers.py
  hghave
  histedit-helpers.sh
  killdaemons.py
  md5sum.py
  notcapable
  printenv.py
  readlink.py
  revlog-formatv0.py
  run-tests.py
  svn-safe-append.py
  svnxml.py
  tinyproxy.py
2015-01-14 01:15:26 +01:00
Mads Kiilerich
7ebc1609d6 run-tests: automatically add (glob) to "saved backup bundle to" lines
Avoid spending too much time adding (glob) after running run-tests -i. This
doesn't handle all cases but it helps.

The run-tests tests add a bit of escaping of trailing (glob) in the output to
avoid interference from the outer test runner.

The regexp for matching the output lines contains a group for making multiline
substitute in a way that works with Python before 2.7.
2014-11-27 02:04:30 +01:00
Matt Harbison
889536b207 run-tests: set a default largefiles usercache in the default hgrc file
This fixes a test failure introduced in 131ac757f996 on Windows and OS X, where
the cached largefile wasn't being deleted because the named .cache directory
didn't exist.  It only existed on Linux because the test suite sets $HOME to the
directory of the test being run, and Linux uses $HOME/.cache by default.

Most of the other largefiles tests explicitly set this value at the top of their
scripts, but test-largefiles-update.t didn't pick that up when it was created.
Those scripts that do set a value will override this.

We could just set the parameter in the test-largefiles-update.t script, but
there are a few other non obvious tests that exercise largefiles too.  These
largefiles end up being cached in the user's real cache, so proper hygiene
dictates that this not be left to each individual test script.
2014-11-19 23:41:40 -05:00
Matt Harbison
a1af7899a6 run-tests: don't warn on unnecessary globs mandated by check-code.py
When test output is processed, if os.altsep is defined (i.e. on Windows),
TTest.globmatch() will cause a warning later on if a line has a glob that isn't
necessary.  Unfortunately, the regex checking in check-code.py doesn't have this
context.  Therefore we ended up with cases where the test would get flagged with
a warning only on Windows because a glob was present, because check-code.py
would warn if it wasn't.  For example, from test-subrepo.t:

    $ hg -R issue1852a push `pwd`/issue1852c
    pushing to $TESTTMP/issue1852c (glob)

The glob isn't necessary here because the slash is shown as it was provided.
However, check-code mandates one to handle the case where the default path has
backslashes in it.

Break the cycle by checking against a subset of the check-code rules before
flagging the test with a warning, and ignore the superfluous glob if it matches
a rule.  This change fixes warnings in test-largefiles-update.t, test-subrepo.t,
test-tag.t, and test-rename-dir-merge.t on Windows.

I really hate that the rules are copy/pasted here (minus the leading two spaces)
because it would be nice to only update the rules once, in a single place.  But
I'm not sure how else to do it.  I'm open to suggestions.  Splitting some of the
rules out of check-code.py seems wrong, but so does moving check-code.py out of
contrib, given that other checking scripts live there.

There are other glob patterns that could be copied over, but this is enough to
make the current tests run on Windows.
2014-11-18 22:02:00 -05:00
Matt Harbison
46cd7c6aa4 run-tests: include quotes in the HGEDITOR value when storing sys.executable
This fixes test-install.t on Windows that broke in 97300cee8fc0 when
shlex.split() was added to the debuginstall command:

    @@ -7,8 +7,11 @@
       checking installed modules (*mercurial)... (glob)
       checking templates (*mercurial?templates)... (glob)
       checking commit editor...
    +   Can't find editor 'c:\Python27\python.exe -c "(omitted)"' in PATH
    +   (specify a commit editor in your configuration file)
       checking username...
    -  no problems detected
    +  1 problems detected, please check your install!
    +  [1]

What happens is that shlex.split() on Windows turns this:

    c:\Python27\python.exe -c "import sys; sys.exit(0)"

into this:

    ['c:Python27python.exe', '-c', 'import sys; sys.exit(0)']

While technically a regression, most programs on Windows live in some flavor of
'Program Files', and therefore the environment variable needs to contain quotes
anyway to handle the space.  This wasn't handled prior to the shlex() change,
because it tested the whole environment variable to see if it was an executable,
or split on the first space and tested again.
2014-11-04 12:46:00 -05:00
Augie Fackler
7a3a996d0f run-tests: use a try/except ladder instead of looking for a specific version
This ensures we get json instead of simplejson in as many places as possible.
2014-11-10 13:20:56 -05:00
Mads Kiilerich
523c87c1fe spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
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