Skip to content

Tests cleanups #749

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

Merged
merged 4 commits into from
Mar 25, 2019
Merged
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
2 changes: 0 additions & 2 deletions tests/snippets/append.py

This file was deleted.

8 changes: 8 additions & 0 deletions tests/snippets/strings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from testutils import assert_raises

assert "a" == 'a'
assert """a""" == "a"
assert len(""" " "" " "" """) == 11
Expand Down Expand Up @@ -124,3 +126,9 @@
assert 'z' > 'b'
assert 'z' >= 'b'
assert 'a' >= 'a'

def try_mutate_str():
word = "word"
word[0] = 'x'

assert_raises(TypeError, try_mutate_str)
7 changes: 0 additions & 7 deletions tests/snippets/xfail_3.1.2.17.py

This file was deleted.

24 changes: 12 additions & 12 deletions tests/test_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@

class _TestType(enum.Enum):
functional = 1
benchmark = 2


logger = logging.getLogger('tests')
ROOT_DIR = '..'
TEST_ROOT = os.path.abspath(os.path.join(ROOT_DIR, 'tests'))
TEST_DIRS = {
_TestType.functional: os.path.join(TEST_ROOT, 'snippets'),
_TestType.benchmark: os.path.join(TEST_ROOT, 'benchmarks'),
}
CPYTHON_RUNNER_DIR = os.path.abspath(os.path.join(ROOT_DIR, 'py_code_object'))
RUSTPYTHON_RUNNER_DIR = os.path.abspath(os.path.join(ROOT_DIR))
Expand Down Expand Up @@ -65,24 +63,23 @@ def run_via_cpython_bytecode(filename, test_type):

# Step2: run cpython bytecode:
env = os.environ.copy()
log_level = 'info' if test_type == _TestType.benchmark else 'debug'
env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level)
env['RUST_LOG'] = 'info,cargo=error,jobserver=error'
env['RUST_BACKTRACE'] = '1'
with pushd(CPYTHON_RUNNER_DIR):
subprocess.check_call(['cargo', 'run', bytecode_filename], env=env)


def run_via_rustpython(filename, test_type):
env = os.environ.copy()
log_level = 'info' if test_type == _TestType.benchmark else 'trace'
env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level)
env['RUST_LOG'] = 'info,cargo=error,jobserver=error'
env['RUST_BACKTRACE'] = '1'

target = 'release'
if env.get('CODE_COVERAGE', 'false') == 'true':
subprocess.check_call(
['cargo', 'run', filename], env=env)
else:
subprocess.check_call(
['cargo', 'run', '--release', filename], env=env)
target = 'debug'
binary = os.path.abspath(os.path.join(ROOT_DIR, 'target', target, 'rustpython'))

subprocess.check_call([binary, filename], env=env)


def create_test_function(cls, filename, method, test_type):
Expand Down Expand Up @@ -124,4 +121,7 @@ def get_test_files():
# @populate('cpython_bytecode')
@populate('rustpython')
class SampleTestCase(unittest.TestCase):
pass
@classmethod
def setUpClass(cls):
subprocess.check_call(['cargo', 'build'])
subprocess.check_call(['cargo', 'build', '--release'])