Skip to content

Commit d470ebc

Browse files
committed
a bunch of fixes
1 parent 799a0a1 commit d470ebc

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

posts/2022/03/how-is-pypy-tested.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ How is PyPy Tested?
1414

1515
In this post I want to give an overview of how the PyPy project does and thinks
1616
about testing. PyPy takes testing quite seriously and has done some from the
17-
start of the project. In the post I want to present the different styles of
17+
start of the project. Here I want to present the different styles of
1818
tests that PyPy has, when we use them and how I think about them.
1919

2020

@@ -116,7 +116,7 @@ just completely regular Python 2 classes that behave in the regular way when
116116
run on top of a Python interpreter.
117117

118118
In CPython, these tests don't really have an equivalent. They would correspond
119-
to tests that are written in C and that can access test the logic of all the C
119+
to tests that are written in C and that can test the logic of all the C
120120
functions of CPython that execute certain functionality, accessing the internals
121121
of C structs in the process. `¹`_
122122

@@ -181,27 +181,30 @@ The CPython Test Suite
181181
We also use the CPython Test suite as a final check to see whether our
182182
interpreter correctly implements all the features of the Python language. In
183183
that sense it acts as some kind of compliance test suite that checks whether we
184-
implement the language correctly. The test suite is not perfect for this
185-
purpose. Since it is written for CPython's purposes during its development, a
184+
implement the language correctly. The test suite is not perfect for this.
185+
Since it is written for CPython's purposes during its development, a
186186
lot of the tests check really specific CPython implementation details. Examples
187187
for these are tests that check that ``__del__`` is called immediately after
188188
objects go out of scope (which only happens if you use reference counting as a
189-
garbage collection strategy, which PyPy doesn't do). Other examples are checking
189+
garbage collection strategy, PyPy uses a `different approach to garbage
190+
collection`_). Other examples are checking
190191
for exception error messages very explicitly. However, the CPython test suite
191192
has gotten a lot better in these regards over time, by adding
192193
``support.gc_collect()`` calls to fix the former problem, and by marking some
193194
very specific tests with the ``@impl_detail`` decorator. Thanks to all the
194195
CPython developers who have worked on this!
195196

197+
.. _`different approach to garbage collection`: https://www.pypy.org/posts/2013/10/incremental-garbage-collector-in-pypy-8956893523842234676.html
198+
196199
In the process of re-implementing CPython's functionality and running CPython's
197200
tests suite, PyPy can often also be a good way to find bugs in CPython. While we
198201
think about the corner cases of some Python feature we occasionally find
199202
situations where CPython didn't get everything completely correct either, which
200203
we then report back.
201204

202205

203-
Testing Performance
204-
=====================
206+
Testing for Performance Regressions
207+
====================================
205208

206209
All the tests we described so far are checking *behaviour*. But one of PyPy's
207210
important goals is to be a *fast* implementation not "just" a correct one. Some
@@ -221,7 +224,7 @@ representation`_ that the JIT uses to produce machine code from.
221224
.. _`intermediate representation`: https://www.pypy.org/posts/2018/09/the-first-15-years-of-pypy-3412615975376972020.html
222225

223226
As an example, here is a small test that loading the attribute of a constant
224-
global instance can be completely constant folded away
227+
global instance can be completely constant folded away:
225228

226229
.. code:: python
227230
@@ -290,7 +293,7 @@ Footnotes
290293

291294
.. _`¹`:
292295

293-
CPython has the `_testcapimodule.c` and related modules, that are used to
296+
¹ CPython has the `_testcapimodule.c` and related modules, that are used to
294297
unit-test the C-API. However, these are still driven from Python tests using
295298
the ``unittest`` framework and wouldn't run without the Python interpreter
296299
already working.
@@ -304,8 +307,8 @@ then having a test class with the pattern ``class AppTest*``. We haven't
304307
converted all of them to the new style yet, even though the old style is
305308
quite weird: since the ``test_*.py`` files are themselves parsed by
306309
Python 2, the tests methods in ``AppTest*`` classes need to be written in the
307-
subset of Python 3 that is also valid Python 2 syntax, leading to a lot of
308-
confusion.
310+
subset of Python 3 syntax that is also valid Python 2 syntax, leading to a lot
311+
of confusion.
309312

310313
.. _`³`:
311314

0 commit comments

Comments
 (0)