Skip to content

Commit 96d8c27

Browse files
committed
Split runtests.rst into Jython-specific and CPython versions
Just too much divergence to remain common.
1 parent 3d56927 commit 96d8c27

7 files changed

+122
-24
lines changed

buildbots_jy.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ as soon as possible.
5858
Flags-dependent failures
5959
------------------------
6060

61-
Sometimes, while you have run the :doc:`whole test suite <runtests>` before
61+
Sometimes, while you have run the :doc:`whole test suite <runtests_jy>` before
6262
committing, you may witness unexpected failures on the buildbots. One source
6363
of such discrepancies is if different flags have been passed to the test runner
6464
or to Python itself. To reproduce, make sure you use the same flags as the

committing.rst

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Accepting Pull Requests
88

99
.. warning:: At present, this is not much modified from the CPython base.
1010

11+
1112
This page is aimed to core developers, and covers the steps required to
1213
accept, merge, and possibly backport a pull request on the main repository.
1314

committing_hg_jy.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ensure your changes fulfill several mandatory criteria.
2525
Does the test suite still pass?
2626
'''''''''''''''''''''''''''''''
2727

28-
You must :ref:`run the whole test suite <runtests>` to ensure that it
28+
You must :ref:`run the whole test suite <runtests-jy>` to ensure that it
2929
passes before pushing any code changes.
3030

3131
.. note::
@@ -95,7 +95,7 @@ triagers are good to go except maybe lacking ``Misc/ACKS`` and ``Misc/NEWS``
9595
entries.
9696

9797
Second, make sure the patch does not break backwards-compatibility without a
98-
good reason. This means :ref:`running the entire test suite <runtests>` to
98+
good reason. This means :ref:`running the entire test suite <runtests-jy>` to
9999
make sure everything still passes. It also means that if semantics do change
100100
there must be a good reason for the breakage of code the change will cause
101101
(and it **will** break someone's code). If you are unsure if the breakage

index.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Mercurial
3838

3939
ant
4040

41-
3. :doc:`Run the tests <runtests>`::
41+
3. :doc:`Run the tests <runtests_jy>`::
4242

4343
ant regrtest
4444

@@ -70,7 +70,7 @@ instructions please see the :ref:`setup guide <setup-jy>`.
7070
See also :ref:`more detailed instructions <compiling-jy>`,
7171
and :ref:`how to build dependencies <build-dependencies-jy>`.
7272

73-
4. :doc:`Run the tests <runtests>`::
73+
4. :doc:`Run the tests <runtests_jy>`::
7474

7575
dist/bin/jython -m test -e
7676

@@ -194,7 +194,7 @@ Guide for contributing to Jython:
194194
* :doc:`help`
195195
* :doc:`patch_hg_jy` (existing process)
196196
* :doc:`pullrequest` (partly usable future process)
197-
* :doc:`runtests`
197+
* :doc:`runtests_jy`
198198
* Beginner tasks to become familiar with the development process
199199
* :doc:`docquality`
200200
* :doc:`coverage`
@@ -318,7 +318,7 @@ Full Table of Contents
318318
help
319319
patch_hg_jy
320320
pullrequest
321-
runtests
321+
runtests_jy
322322
coverage_jy
323323
docquality
324324
documenting
@@ -356,6 +356,7 @@ you understand the Jython one.
356356
:maxdepth: 1
357357

358358
setup
359+
runtests
359360
coverage
360361
triaging
361362
porting

pullrequest.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ developers.
7575
Third, make sure you have proper tests to verify your pull request works as
7676
expected. Pull requests will not be accepted without the proper tests!
7777

78-
Fourth, make sure the entire test suite :ref:`runs <runtests>` **without
78+
Fourth, make sure the entire test suite :ref:`runs <runtests-jy>` **without
7979
failure** because of your changes. It is not sufficient to only run whichever
8080
test seems impacted by your changes, because there might be interferences
8181
unknown to you between your changes and some other part of the interpreter.
@@ -122,12 +122,12 @@ Here is a quick overview of how you can contribute to CPython on GitHub:
122122

123123
#. :ref:`Build Jython <compiling-jy>` on your system
124124

125-
#. :ref:`Run tests <runtests>` after you have built Python
125+
#. :ref:`Run tests <runtests-jy>` after you have built Python
126126

127127
#. :ref:`Create a Branch in Git <pullrequest-steps>` where you can work on
128128
changes
129129

130-
#. :ref:`Run tests <runtests>` again
130+
#. :ref:`Run tests <runtests-jy>` again
131131

132132
#. :ref:`Commit <commit-changes>` and :ref:`push <push-changes>`
133133
changes to your GitHub fork

runtests.rst

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
.. This file is derived from a file of the same name in the CPython devguide
2-
and will receive updates from the CPython guide by merging.
3-
41
.. _runtests:
52

63
Running & Writing Tests
74
=======================
85

9-
10-
.. warning:: At present, this is not much modified from the CPython base.
11-
126
.. note::
137

148
This document assumes you are working from an
15-
:ref:`in-development <indevbranch>` checkout of Jython. If you
9+
:ref:`in-development <indevbranch>` checkout of Python. If you
1610
are not then some things presented here may not work as they may depend
17-
on new features not available in earlier versions of Jython.
11+
on new features not available in earlier versions of Python.
1812

1913
Running
2014
-------
2115

2216
The shortest, simplest way of running the test suite is the following command
23-
from the root directory of your checkout::
24-
25-
ant regrtest
17+
from the root directory of your checkout (after you have
18+
:ref:`built Python <compiling>`)::
2619

27-
.. Jython should enable this:
20+
./python -m test
2821

29-
.. warning:: From here on needs modification from CPython base.
22+
You may need to change this command as follows throughout this section.
23+
On :ref:`most <mac-python.exe>` Mac OS X systems, replace :file:`./python`
24+
with :file:`./python.exe`. On Windows, use :file:`python.bat`. If using
25+
Python 2.7, replace ``test`` with ``test.regrtest``.
3026

3127
If you don't have easy access to a command line, you can run the test suite from
3228
a Python or IDLE shell::
@@ -102,7 +98,7 @@ be executed on that platform.
10298
Often, the cause is that an optional module hasn't been built due to missing
10399
build dependencies. In these cases, the missing module reported when the test
104100
is skipped should match one of the modules reported as failing to build when
105-
:ref:`compiling-jy`.
101+
:ref:`compiling`.
106102

107103
In other cases, the skip message should provide enough detail to help figure
108104
out and resolve the cause of the problem (for example, the default security

runtests_jy.rst

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
.. Jython companion to runtests.rst
2+
3+
.. _runtests-jy:
4+
5+
Running & Writing Tests (Jython)
6+
================================
7+
8+
.. highlight:: console
9+
10+
.. note::
11+
12+
This document assumes you are working from an
13+
:ref:`in-development <indevbranch>` checkout of Jython. If you
14+
are not then some things presented here may not work as they may depend
15+
on new features not available in earlier versions of Jython.
16+
17+
The commands are given for Jython 2.7, and may be different in Jython 3.
18+
19+
Running
20+
-------
21+
22+
The shortest, simplest way of running the test suite is the following command
23+
from the root directory of your checkout::
24+
25+
$ ant regrtest
26+
27+
This will run the majority of tests, but exclude a small portion of them;
28+
these excluded tests are known failures on the current platform or
29+
use special kinds of resources: for example, accessing the
30+
Internet, or trying to play a sound or to display a graphical interface on
31+
your desktop. They are disabled by default so that running the test suite
32+
is not too intrusive. To enable some of these additional tests (and for
33+
other flags which can help debug various issues such as reference leaks), read
34+
the help text::
35+
36+
$ dist/bin/jython -m test.regrtest -h
37+
38+
If you want to run a single test file, simply specify the test file name
39+
(without the extension) as an argument. You also probably want to enable
40+
verbose mode (using ``-v``), so that individual failures are detailed::
41+
42+
$ dist/bin/jython -m test.regrtest -v test_abc
43+
44+
This form may be used to run multiple tests by name,
45+
and in a the order specified, or even repeat to tests::
46+
47+
$ dist/bin/jython -m test.regrtest test_abc test_int test_abc
48+
49+
To run a single test case, use the ``unittest`` module, providing the import
50+
path to the test case::
51+
52+
$ dist/bin/jython -m unittest -v test.test_abc.TestABC
53+
54+
55+
Unexpected Skips
56+
^^^^^^^^^^^^^^^^
57+
58+
Sometimes when running the test suite, you will see "unexpected skips"
59+
reported. These represent cases where an entire test module has been
60+
skipped, but the test suite normally expects the tests in that module to
61+
be executed on that platform.
62+
63+
Often, the cause is that an optional module hasn't been built due to missing
64+
build dependencies. In these cases, the missing module reported when the test
65+
is skipped should match one of the modules reported as failing to build when
66+
:ref:`compiling-jy`.
67+
68+
In other cases, the skip message should provide enough detail to help figure
69+
out and resolve the cause of the problem (for example, the default security
70+
settings on some platforms will disallow some tests)
71+
72+
73+
Writing
74+
-------
75+
76+
Writing tests for Python is much like writing tests for your own code. Tests
77+
need to be thorough, fast, isolated, consistently repeatable, and as simple as
78+
possible. We try to have tests both for normal behaviour and for error
79+
conditions. Tests live in the ``Lib/test`` directory, where every file that
80+
includes tests has a ``test_`` prefix.
81+
82+
One difference with ordinary testing is that you are encouraged to rely on the
83+
:py:mod:`test.support` module. It contains various helpers that are tailored to
84+
Python's test suite and help smooth out common problems such as platform
85+
differences, resource consumption and cleanup, or warnings management.
86+
That module is not suitable for use outside of the standard library.
87+
88+
When you are adding tests to an existing test file, it is also recommended
89+
that you study the other tests in that file; it will teach you which precautions
90+
you have to take to make your tests robust and portable.
91+
92+
93+
Benchmarks
94+
----------
95+
Benchmarking is useful to test that a change does not degrade performance.
96+
97+
`The Python Benchmark Suite <https://github.com/python/performance>`_
98+
has a collection of benchmarks for all Python implementations. Documentation
99+
about running the benchmarks is in the `README.txt
100+
<https://github.com/python/performance/blob/master/README.rst>`_ of the repo.

0 commit comments

Comments
 (0)