From e44b02b88f726408478377fc62f094661d59c8ce Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Mon, 25 Mar 2019 17:52:37 +0100 Subject: [PATCH 1/4] Avoid trace log in tests --- tests/test_snippets.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test_snippets.py b/tests/test_snippets.py index 4be73b7bde..bc4c43a775 100644 --- a/tests/test_snippets.py +++ b/tests/test_snippets.py @@ -65,8 +65,7 @@ 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) @@ -74,8 +73,7 @@ def run_via_cpython_bytecode(filename, test_type): 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' if env.get('CODE_COVERAGE', 'false') == 'true': subprocess.check_call( From 4ab59a8e4c369104ab8518f651038877ada301f1 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Mon, 25 Mar 2019 17:53:13 +0100 Subject: [PATCH 2/4] Do not run benchmarks in the main test suite --- tests/test_snippets.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_snippets.py b/tests/test_snippets.py index bc4c43a775..7aa9c2456b 100644 --- a/tests/test_snippets.py +++ b/tests/test_snippets.py @@ -17,7 +17,6 @@ class _TestType(enum.Enum): functional = 1 - benchmark = 2 logger = logging.getLogger('tests') @@ -25,7 +24,6 @@ class _TestType(enum.Enum): 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)) From 16e04cf298a67f1c2686fe846177789425a26df4 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Mon, 25 Mar 2019 17:54:04 +0100 Subject: [PATCH 3/4] Run rustpython tests without cargo middleman --- tests/test_snippets.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/test_snippets.py b/tests/test_snippets.py index 7aa9c2456b..7edbd7b7e5 100644 --- a/tests/test_snippets.py +++ b/tests/test_snippets.py @@ -73,12 +73,13 @@ def run_via_rustpython(filename, test_type): env = os.environ.copy() 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): @@ -120,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']) From 2131a8130cfcf344a81437d7c7413211976dc25e Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Mon, 25 Mar 2019 17:55:17 +0100 Subject: [PATCH 4/4] Clean up some tests --- tests/snippets/append.py | 2 -- tests/snippets/strings.py | 8 ++++++++ tests/snippets/xfail_3.1.2.17.py | 7 ------- 3 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 tests/snippets/append.py delete mode 100644 tests/snippets/xfail_3.1.2.17.py diff --git a/tests/snippets/append.py b/tests/snippets/append.py deleted file mode 100644 index a0490cb6d3..0000000000 --- a/tests/snippets/append.py +++ /dev/null @@ -1,2 +0,0 @@ -x = [] -x.append(1) diff --git a/tests/snippets/strings.py b/tests/snippets/strings.py index 4483b37f62..31511db11e 100644 --- a/tests/snippets/strings.py +++ b/tests/snippets/strings.py @@ -1,3 +1,5 @@ +from testutils import assert_raises + assert "a" == 'a' assert """a""" == "a" assert len(""" " "" " "" """) == 11 @@ -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) diff --git a/tests/snippets/xfail_3.1.2.17.py b/tests/snippets/xfail_3.1.2.17.py deleted file mode 100644 index fc956bef43..0000000000 --- a/tests/snippets/xfail_3.1.2.17.py +++ /dev/null @@ -1,7 +0,0 @@ -word = "Python" - -word[0] = "J" # Should raise a error, immutable -word[2:] = "Jy" # Should raise a error, immutable - - -