Commit Graph

141 Commits

Author SHA1 Message Date
Victor Stinner 48b5c422ff bpo-30776: reduce regrtest -R false positives (#2422)
* Change the regrtest --huntrleaks checker to decide if a test file
  leaks or not. Require that each run leaks at least 1 reference.
* Warmup runs are now completely ignored: ignored in the checker test
  and not used anymore to compute the sum.
* Add an unit test for a reference leak.

Example of reference differences previously considered a failure
(leak) and now considered as success (success, no leak):

    [3, 0, 0]
    [0, 1, 0]
    [8, -8, 1]
2017-06-27 02:02:04 +02:00
Victor Stinner 63f54c6893 bpo-30764: regrtest: add --fail-env-changed option (#2402)
* bpo-30764: regrtest: change exit code on failure

* Exit code 2 if failed tests ("bad")
* Exit code 3 if interrupted

* bpo-30764: regrtest: add --fail-env-changed option

If the option is set, mark a test as failed if it alters the
environment, for example if it creates a file without removing it.
2017-06-26 18:33:19 +02:00
Victor Stinner ace56d5836 bpo-30523: regrtest --list-cases --match (#2401)
* regrtest --list-cases now supports --match and --match-file options.
  Example: ./python -m test --list-cases -m FileTests test_os
* --list-cases now also sets support.verbose to False to prevent
  messages to stdout when loading test modules.
* Add support._match_test() private function.
2017-06-26 14:18:51 +02:00
mlouielu a49c935cfd bpo-30523: regrtest: Add --list-cases option (#2238)
* bpo-30523: regrtest: Add --list-cases option

* bpo-30523: Enhance --list-cases

* Add get_abs_module() function, use it in list_cases()
* list_cases() now logs skipped tests into stderr

* Remove unused doctest
2017-06-16 11:36:19 +02:00
Victor Stinner f7e07840d7 bpo-30284: Fix regrtest for out of tree build (#1481)
Use a build/ directory in the build directory, not in the source
directory, since the source directory may be read-only and must not
be modified.

Fallback on the source directory if the build directory is not
available (missing "abs_builddir" sysconfig variable).
2017-06-15 00:44:05 +02:00
Victor Stinner ef8320cf6f bpo-30540: regrtest: add --matchfile option (#1909)
* Add a new option taking a filename to get a list of test names to
  filter tests.
* support.match_tests becomes a list.
* Modify run_unittest() to accept to match the whole test identifier,
  not just a part of a test identifier.

For example, the following command only runs test_default_timeout()
of the BarrierTests class of test_threading:

$ ./python -m test -v test_threading -m test.test_threading.BarrierTests.test_default_timeout

Remove also some empty lines from test_regrtest.py to make flake8
tool happy.
2017-06-09 10:18:48 +02:00
Victor Stinner fcdd9b6b7e bpo-27103: regrtest disables -W if -R is used (#1651)
Workaround for a regrtest bug.
2017-05-18 13:03:24 -07:00
Victor Stinner 74683fc624 bpo-30258: regrtest: Fix run_tests_multiprocess() (#1479)
If the child process exited with a non-zero code, don't strip the
last line of stdout anymore.

Add also a sanity check in accumulate_result().
2017-05-09 11:34:01 +02:00
Victor Stinner 3d0056842c bpo-30263: regrtest: log system load (#1452)
* bpo-30263: regrtest: log system load

* regrtest: log the number of CPUs

Log the number of CPUs in the header. --verbose now imply --header.
2017-05-04 15:21:12 +02:00
Victor Stinner ec4b17239d regrtest: always show before/after of modified env (#1192)
Buildbots don't run tests with -vv and so only log "xxx was modified
by test_xxx" which is not enough to debug such random issue. In many
cases, I'm unable to reproduce the warning and so unable to fix it.

Always logging the value before and value after should help to debug
such warning on buildbots.
2017-04-20 00:57:30 +02:00
Ivan Levkivskyi 7acffa23c9 bpo-29638: Fix spurious refleaks after typing is imported (#469) 2017-03-05 20:15:20 +02:00
Victor Stinner 17a63e2169 Fix regrtest -j0 -R output
Write also dots into stderr, instead of stdout.
2017-02-08 13:06:08 +01:00
Victor Stinner 5bad70def6 regrtest: don't fail immediately if a child does crash
Issue #29362: Catch a crash of a worker process as a normal failure and
continue to run next tests. It allows to get the usual test summary: single
line result (OK/FAIL), total duration, etc.
2017-02-06 12:42:00 +01:00
Victor Stinner e8cfec5abc Issue #29035: Simplify a regex in libregrtest
regrtest: simplify the regex used to match test names for the --fromfile
command line option.
2017-01-03 01:38:58 +01:00
Xiang Zhang f76df27806 Issue #28950: Merge 3.6. 2016-12-19 22:05:46 +08:00
Xiang Zhang 772bf2ed83 Issue #28950: Disallow -j0 combined with -T/-l in regrtest. 2016-12-19 22:00:22 +08:00
Victor Stinner c24217e144 regrtest --fromfile now accepts a list of filenames 2016-12-09 16:05:51 +01:00
Serhiy Storchaka 684cadaef9 Issue #23839: Various caches now are cleared before running every test file. 2016-11-11 11:48:22 +02:00
Serhiy Storchaka 839102603c Issue #23839: Various caches now are cleared before running every test file. 2016-11-11 11:46:44 +02:00
Serhiy Storchaka 1f9449589e Issue #28649: Clear the typing module caches when search for reference leaks. 2016-11-09 23:52:40 +02:00
Serhiy Storchaka 04c954d275 Issue #28649: Clear the typing module caches when search for reference leaks. 2016-11-09 23:51:54 +02:00
Victor Stinner 8f5dd35d8e Merge 3.7: Issue #28409: regrtest: fix the parser of command line arguments. 2016-10-17 18:15:07 +02:00
Victor Stinner a506a93b0b Merge 3.6: Issue #28409: regrtest: fix the parser of command line arguments. 2016-10-17 18:13:46 +02:00
Victor Stinner e7d3b0cf14 Merge 3.6 (issue #27829) 2016-09-23 11:16:32 +02:00
Victor Stinner 21c8c92422 Merge 3.5 (issue #27829) 2016-09-23 11:15:50 +02:00
Victor Stinner 3e56c23e7d regrtest: add -u for unbuffered stdout/stderr 2016-09-21 17:12:50 +02:00
Victor Stinner eddc4b7272 Merge 3.5 (regrtest) 2016-09-10 04:27:56 -04:00
Eric V. Smith 451d0e38fc Issue 27948: Allow backslashes in the literal string portion of f-strings, but not in the expressions. Also, require expressions to begin and end with literal curly braces. 2016-09-09 21:56:20 -04:00
Victor Stinner b96ef55d49 regrtest: log FS and locale encodings 2016-09-08 21:46:56 -07:00
Steve Dower 22d0698d3b Adds test.support.PGO and skips tests that are not useful for PGO. 2016-09-06 19:38:15 -07:00
Eric V. Smith 6a4efce7a5 Closes issue 27921: Disallow backslashes anywhere in f-strings. This is a temporary restriction. In 3.6 beta 2, the plan is to again allow backslashes in the string parts of f-strings, but disallow them in the expression parts. 2016-09-03 09:18:34 -04:00
Victor Stinner ad7b6c3720 Issue #27829: libregrtest.save_env: flush stderr
Use flush=True to try to get a warning which is missing in buildbots.

Use also f-string to make the code shorter.
2016-08-22 14:29:54 +02:00
Victor Stinner ab98367747 Cleanup libregrtest
* main.py: remove unused import
* runtest: simplify runtest_inner() parameters, reuse ns parameter
2016-08-22 14:28:52 +02:00
Martin Panter 051b2201a7 Issue #27787: Merge regrtest fixup from 3.5 2016-08-20 07:38:21 +00:00
Victor Stinner f2abf5c11a regrtest: replace "Result:" with "Tests result:" 2016-08-19 17:54:25 +02:00
Victor Stinner 636860354e regrtest: add a summary of the summary, "Result: xxx"
It's sometimes hard to check quickly if tests succeeded, failed or something
bad happened. I added a final "Result: xxx" line which summarizes all outputs
into a single line, written at the end (it should always be the last line of
the output).
2016-08-17 16:12:16 +02:00
Victor Stinner c5a01f8551 regrtest: set interrupted to True if re-run is interrupted 2016-08-17 16:00:12 +02:00
Victor Stinner 8f00319294 regrtest: add newlines in output for readability 2016-08-17 15:42:21 +02:00
Victor Stinner 435eaf4422 regrtest: nicer output for durations
Use milliseconds and minutes units, not only seconds.
2016-08-17 12:22:52 +02:00
Victor Stinner 6c44619ece regrtest: rename --slow option to --slowest
Thanks to optparse, --slow syntax still works ;-)
2016-08-17 11:25:43 +02:00
Alexander Belopolsky 5d0c598382 Closes issue #24773: Implement PEP 495 (Local Time Disambiguation). 2016-07-22 18:47:04 -04:00
Victor Stinner 1b8b42344e regrtest: display test result (passed, failed, ...)
* in multiprocessing mode: always display the result
* sequential mode: only display the result if the test did not pass
2016-05-20 13:37:40 +02:00
Victor Stinner 6d81a2136d regrtest doesn't ignore -j1 anymore
* regrtest now uses subprocesses when the -j1 command line option
  is used: each test file runs in a fresh child process. Before, the -j1 option
  was ignored.
* Tools/buildbot/test.bat script now uses -j1 by default to run
  each test file in fresh child process.
2016-05-20 13:15:55 +02:00
Victor Stinner 9759dd3343 Issue #26295: When using "python3 -m test --testdir=TESTDIR", regrtest doesn't
add "test." prefix to test module names.

regrtest also prepends testdir to sys.path.
2016-03-30 02:32:52 +02:00
Victor Stinner 8a96389d47 Merge 3.5 (regrtest) 2016-03-29 13:34:06 +02:00
Victor Stinner 80ec58c497 fix typo in comment
Thanks Arfrever for the report :)
2016-03-29 09:50:18 +02:00
Victor Stinner 622583e9bf regrtest: round final timing towards +inf 2016-03-27 18:28:15 +02:00
Victor Stinner d7ac00e620 Backed out changeset 245a16f33c4b
Serhiy asked me to review it.
2016-03-25 19:13:06 +01:00
Victor Stinner ba8cf10873 Rework libregrtest.save_env
* Replace get/restore methods with a Resource class and Resource subclasses
* Create ModuleAttr, ModuleAttrList and ModuleAttrDict helper classes
* Use __subclasses__() to get resource classes instead of using an hardcoded
  list (2 shutil resources were missinged in the list!)
* Don't define MultiprocessingProcessDangling resource if the multiprocessing
  module is missing
* Nicer diff for dictionaries. Useful for the big os.environ dict
* Reorder code to group resources
2016-03-25 17:36:33 +01:00
Victor Stinner 3aac0adfe0 Cleanup regrtest "main()" function
* Rename libregrtest.main_in_temp_cwd() to libregrtest.main()
* Add regrtest.main_in_temp_cwd() alias to libregrtest.main()
* Move old main_in_temp_cwd() code into libregrtest.Regrtest.main()
* Update multiple scripts to call libregrtest.main()
2016-03-24 17:53:20 +01:00
Victor Stinner 56db16cd44 regrtest: when parallel tests are interrupted, display progress 2016-03-24 12:04:15 +01:00
Victor Stinner 2b60b7237e regrtest: mention in tests run sequentially or in parallel 2016-03-24 11:55:29 +01:00
Victor Stinner 5de16e80c1 regrtest: fix --fromfile feature
* Update code for the name regrtest output format.
* Enhance also test_regrtest test on --fromfile
2016-03-24 09:43:00 +01:00
Victor Stinner 69649f21f0 regrtest: display test duration in sequential mode
Only display duration if a test takes more than 30 seconds.
2016-03-23 12:14:10 +01:00
Victor Stinner 6d7f4f6675 regrtest: add timeout to main process when using -jN
libregrtest: add a watchdog to run_tests_multiprocess() using
faulthandler.dump_traceback_later().
2016-03-23 02:04:32 +01:00
Victor Stinner 24f949e10c regrtest: add time to output
Timestamps should help to debug slow buildbots, and timeout and hang on
buildbots.
2016-03-22 15:14:09 +01:00
Victor Stinner 82f04e2dfd regrtest: Fix module.__path__
Issue #26538: libregrtest: Fix setup_tests() to keep module.__path__ type
(_NamespacePath), don't convert to a list.

Add _NamespacePath.__setitem__() method to importlib._bootstrap_external.
2016-03-15 23:08:44 +01:00
Victor Stinner 45550178ef regrtest: display progress every 30 seconds (instead of 60 seconds) when
running tests in multiprocessing mode (-jN).
2015-11-04 09:03:53 +01:00
Serhiy Storchaka 4a7c03aab4 Issue #25523: Merge a-to-an corrections from 3.5. 2015-11-02 14:44:29 +02:00
Victor Stinner 3909e58994 Close #25373: Fix regrtest --slow with interrupted test
* Fix accumulate_result(): don't use time on interrupted and failed test
* Add unit test for interrupted test
* Add unit test on --slow with interrupted test, with and without
  multiprocessing
2015-10-11 10:37:25 +02:00
Steve Dower 08ec6d9611 Fix missing import in libregrtest. 2015-10-08 11:34:07 -07:00
Steve Dower 12c2945ccf Issue #23919: Prevents assert dialogs appearing in the test suite. 2015-10-08 09:05:36 -07:00
Brett Cannon 11faa21843 Merge from 3.5 for issue #25188. 2015-10-02 16:20:49 -07:00
Victor Stinner 5f9d3acc5e Issue #22806: Add ``python -m test --list-tests`` command to list tests. 2015-10-03 00:21:12 +02:00
Victor Stinner 076fc872bc Issue #18174: "python -m test --huntrleaks ..." now also checks for leak of
file descriptors. Patch written by Richard Oudkerk.
2015-10-03 00:20:56 +02:00
Victor Stinner a53a818c3c Fix regrtest --coverage on Windows
Issue #25260: Fix ``python -m test --coverage`` on Windows. Remove the list of
ignored directories.
2015-10-01 00:53:09 +02:00
Victor Stinner 9a14214aee Issue #25220: Fix "-m test --forever"
* Fix "-m test --forever": replace _test_forever() with self._test_forever()
* Add unit test for --forever
* Add unit test for a failing test
* Fix also some pyflakes warnings in libregrtest
2015-09-30 13:51:17 +02:00
Victor Stinner 17f9716676 Issue #25220, libregrtest: more verbose output for -jN
When the -jN command line option is used, display tests running since at least
30 seconds every minute.
2015-09-30 03:05:43 +02:00
Victor Stinner b40843546b Issue #25220, libregrtest: Cleanup
No need to support.verbose in Regrtest.run_tests(), it's always set in
runtest().
2015-09-30 02:39:22 +02:00
Victor Stinner 6f20a2e01f Issue #25220, libregrtest: Pass directly ns to runtest()
* Remove runtest_ns(): pass directly ns to runtest().
* Create also Regrtest.rerun_failed_tests() method.
* Inline again Regrtest.run_test(): it's no more justified to have a method
2015-09-30 02:32:11 +02:00
Victor Stinner a204502dbf Issue #25220, libregrtest: Set support.use_resources in setup_tests()
* Rename setup_python() to setup_tests()
* Remove use_resources parameter of runtest()
2015-09-30 02:17:28 +02:00
Victor Stinner ecef622fec Issue #25220, libregrtest: Call setup_python(ns) in the slaves
Slaves (child processes running tests for regrtest -jN) now inherit
--memlimit/-M, --threshold/-t and --nowindows/-n options.

* -M, -t and -n are now supported with -jN
* Factorize code to run tests.
* run_test_in_subprocess() now pass the whole "ns" namespace to the child
  process.
2015-09-30 01:39:28 +02:00
Victor Stinner 8bb19f094b Issue #25220, libregrtest: Add runtest_ns() function
* Factorize code to run tests.
* run_test_in_subprocess() now pass the whole "ns" namespace to the child
  process.
2015-09-30 01:32:39 +02:00
Victor Stinner 234cbef39f Issue #25220, libregrtest: Move setup_python() to a new submodule 2015-09-30 01:13:53 +02:00
Victor Stinner c7eab0528c Issue #25220, libregrtest: Cleanup setup code 2015-09-30 00:59:35 +02:00
Victor Stinner f33536c430 Issue #25220: Use print(flush=True) in libregrtest 2015-09-30 00:48:27 +02:00
Victor Stinner 76f756d934 Issue #25220: Enhance regrtest -jN
Running the Python test suite with -jN now:

- Display the duration of tests which took longer than 30 seconds
- Display the tests currently running since at least 30 seconds
- Display the tests we are waiting for when the test suite is interrupted

Clenaup also run_test_in_subprocess() code.
2015-09-30 00:33:29 +02:00
Victor Stinner 02319804ea Don't strip refcount in libregrtest/runtest_mp.py
Python doesn't display the refcount anymore by default. It only displays it
when -X showrefcount command line option is used, which is not the case here.
regrtest can be run with -X showrefcount, the option is not inherited by child
processes.
2015-09-29 23:52:33 +02:00
Victor Stinner 86e8c31b8d Issue #25220, libregrtest: Remove unused import 2015-09-29 23:50:19 +02:00
Victor Stinner 6448b8041a Issue #25220: truncate some long lines in libregrtest/*.py 2015-09-29 23:43:33 +02:00
Victor Stinner 37554525aa Issue #25220: regrtest setups Python after parsing command line options 2015-09-29 23:37:14 +02:00
Victor Stinner bd1a72c455 Issue #25220: Enhance regrtest --coverage
Add a new Regrtest.run_test() method to ensure that --coverage pass the same
options to the runtest() function.
2015-09-29 23:36:27 +02:00
Victor Stinner 56e05dd0b0 Issue #25220: Create libregrtest/runtest_mp.py
Move the code to run tests in multiple processes using threading and subprocess
to a new submodule.

Move also slave_runner() (renamed to run_tests_slave()) and
run_test_in_subprocess() (renamed to run_tests_in_subprocess()) there.
2015-09-29 23:15:38 +02:00
Victor Stinner dad20e4876 Issue #25220: Split the huge main() function of libregrtest.main into a class
with attributes and methods.

The --threshold command line option is now ignored if the gc module is missing.

* Convert main() variables to Regrtest attributes, document some attributes
* Convert accumulate_result() function to a method
* Create setup_python() function and setup_regrtest() method.
* Import gc at top level
* Move resource.setrlimit() and the code to make the module paths absolute into
  the new setup_python() function. So this code is no more executed when the
  module is imported, only when main() is executed. We have a better control on
  when the setup is done.
* Move textwrap import from printlist() to the top level.
* Some other minor cleanup.
2015-09-29 22:48:52 +02:00
Victor Stinner feabaed054 Oops, revert unwanted change, sorry 2015-09-29 14:02:35 +02:00
Victor Stinner 3f7468507a test 2015-09-29 13:47:15 +02:00
Victor Stinner 36b3fbb0ee Issue #25220: Fix Lib/test/autotest.py 2015-09-27 11:19:08 +02:00
Victor Stinner 3844fe5ed8 Issue #25220: Move most regrtest.py code to libregrtest 2015-09-26 10:38:01 +02:00
Victor Stinner 98de5340d4 Issue #25220: Create Lib/test/libregrtest/
Start to split regrtest.py into smaller parts with the creation of
Lib/test/libregrtest/cmdline.py: code to handle the command line, especially
parsing command line arguments. This part of the code is tested by
test_regrtest.
2015-09-26 09:43:45 +02:00
Victor Stinner 0cca00b67e Issue #25220: Backed out changeset eaf9a99b6bb8 2015-09-23 23:16:47 +02:00
Victor Stinner 7b92abf0e9 Issue #25220: Create Lib/test/libregrtest/
Start to split regrtest.py into smaller parts with the creation of
Lib/test/libregrtest/cmdline.py.
2015-09-23 23:04:18 +02:00