Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failed test for inherits = ".." in user-defined benchmarks. #141

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pyperformance/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
import contextlib
import errno
import os
import subprocess
import sys
import tempfile

DATA_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), 'data'))


def run_cmd(cmd):
print("Execute: %s" % ' '.join(cmd))
proc = subprocess.Popen(cmd)
try:
proc.wait()
except: # noqa
proc.kill()
proc.wait()
raise

exitcode = proc.returncode
if exitcode:
sys.exit(exitcode)


@contextlib.contextmanager
def temporary_file(**kwargs):
Expand Down
4 changes: 4 additions & 0 deletions pyperformance/tests/data/user_defined_bm/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[benchmarks]

name metafile
1 <local>
3 changes: 3 additions & 0 deletions pyperformance/tests/data/user_defined_bm/base.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[project]
dynamic = ["name"]
version = "1.0.0"
11 changes: 11 additions & 0 deletions pyperformance/tests/data/user_defined_bm/bm_1/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
name = "test_bm_1"
requires-python = ">=3.8"
dependencies = ["pyperf"]
urls = { repository = "https://github.com/python/pyperformance" }
dynamic = ["version"]

[tool.pyperformance]
name = "1"
tags = "test"
inherits = ".."
19 changes: 1 addition & 18 deletions pyperformance/tests/test_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,7 @@
import unittest

from pyperformance import tests


DATA_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), 'data'))


def run_cmd(cmd):
print("Execute: %s" % ' '.join(cmd))
proc = subprocess.Popen(cmd)
try:
proc.wait()
except: # noqa
proc.kill()
proc.wait()
raise

exitcode = proc.returncode
if exitcode:
sys.exit(exitcode)
from pyperformance.tests import run_cmd, DATA_DIR


class CompareTests(unittest.TestCase):
Expand Down
18 changes: 18 additions & 0 deletions pyperformance/tests/test_user_defined_bm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os.path
import sys
import unittest

from pyperformance.tests import DATA_DIR, run_cmd

USER_DEFINED_MANIFEST = os.path.join(DATA_DIR, 'user_defined_bm', 'MANIFEST')


class TestBM(unittest.TestCase):
def test_user_defined_bm(self):
cmd = [sys.executable, '-m', 'pyperformance', 'run', f'--manifest={USER_DEFINED_MANIFEST}']

run_cmd(cmd)


if __name__ == "__main__":
unittest.main()
3 changes: 1 addition & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def run_bench(*cmd):

def main():
# Unit tests
cmd = [sys.executable, '-u',
os.path.join('pyperformance', 'tests', 'test_compare.py')]
cmd = [sys.executable, '-u', '-m', 'unittest']
run_cmd(cmd)

# Functional tests
Expand Down