Skip to content

Commit

Permalink
Preserve the Exit Code of Running the Tests (#166)
Browse files Browse the repository at this point in the history
We had been ignoring the exit code of the subprocess in runtests.py.
  • Loading branch information
ericsnowcurrently authored Mar 28, 2022
1 parent 4501ad8 commit 934182f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions pyperformance/tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import os.path
import shutil
import subprocess
import sys
import textwrap
import unittest
Expand All @@ -10,6 +9,12 @@
from pyperformance import tests


CPYTHON_ONLY = unittest.skipIf(
sys.implementation.name != 'cpython',
'CPython-only',
)


class FullStackTests(tests.Functional, unittest.TestCase):

maxDiff = 80 * 100
Expand All @@ -24,12 +29,13 @@ def setUpClass(cls):

@classmethod
def ensure_pyperformance(cls):
_, stdout, _ = cls.run_python(
ec, stdout, _ = cls.run_python(
os.path.join(tests.DATA_DIR, 'find-pyperformance.py'),
capture='stdout',
onfail='raise',
verbose=False,
)
assert ec == 0, ec
stdout = stdout.strip()
if stdout.strip():
# It is already installed.
Expand All @@ -43,7 +49,8 @@ def ensure_pyperformance(cls):
# Install it.
reporoot = os.path.dirname(pyperformance.PKG_ROOT)
# XXX Ignore the output (and optionally log it).
cls.run_pip('install', '--editable', reporoot)
ec, _, _ = cls.run_pip('install', '--editable', reporoot)
assert ec == 0, ec

# Clean up extraneous files.
egg_info = "pyperformance.egg-info"
Expand Down Expand Up @@ -252,6 +259,7 @@ def create_compile_config(self, *revisions,
outfile.write(text)
return cfgfile

@CPYTHON_ONLY
@unittest.skip('way too slow')
def test_compile(self):
cfgfile = self.create_compile_config()
Expand All @@ -263,6 +271,7 @@ def test_compile(self):
capture=None,
)

@CPYTHON_ONLY
@unittest.skip('way too slow')
def test_compile_all(self):
rev1 = '2cd268a3a934' # tag: v3.10.1
Expand All @@ -275,6 +284,7 @@ def test_compile_all(self):
capture=None,
)

@CPYTHON_ONLY
@unittest.expectedFailure
def test_upload(self):
url = '<bogus>'
Expand Down
3 changes: 2 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ def main():
# <unreachable>

# Now run the tests.
subprocess.run(
proc = subprocess.run(
[sys.executable, '-u', '-m', 'pyperformance.tests'],
cwd=os.path.dirname(__file__) or None,
env=dict(
os.environ,
PYPERFORMANCE_TESTS_VENV=venvroot,
)
)
sys.exit(proc.returncode)


if __name__ == "__main__":
Expand Down

0 comments on commit 934182f

Please sign in to comment.