|
17 | 17 |
|
18 | 18 | class _TestType(enum.Enum):
|
19 | 19 | functional = 1
|
20 |
| - benchmark = 2 |
21 | 20 |
|
22 | 21 |
|
23 | 22 | logger = logging.getLogger('tests')
|
24 | 23 | ROOT_DIR = '..'
|
25 | 24 | TEST_ROOT = os.path.abspath(os.path.join(ROOT_DIR, 'tests'))
|
26 | 25 | TEST_DIRS = {
|
27 | 26 | _TestType.functional: os.path.join(TEST_ROOT, 'snippets'),
|
28 |
| - _TestType.benchmark: os.path.join(TEST_ROOT, 'benchmarks'), |
29 | 27 | }
|
30 | 28 | CPYTHON_RUNNER_DIR = os.path.abspath(os.path.join(ROOT_DIR, 'py_code_object'))
|
31 | 29 | RUSTPYTHON_RUNNER_DIR = os.path.abspath(os.path.join(ROOT_DIR))
|
@@ -65,24 +63,23 @@ def run_via_cpython_bytecode(filename, test_type):
|
65 | 63 |
|
66 | 64 | # Step2: run cpython bytecode:
|
67 | 65 | env = os.environ.copy()
|
68 |
| - log_level = 'info' if test_type == _TestType.benchmark else 'debug' |
69 |
| - env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level) |
| 66 | + env['RUST_LOG'] = 'info,cargo=error,jobserver=error' |
70 | 67 | env['RUST_BACKTRACE'] = '1'
|
71 | 68 | with pushd(CPYTHON_RUNNER_DIR):
|
72 | 69 | subprocess.check_call(['cargo', 'run', bytecode_filename], env=env)
|
73 | 70 |
|
74 | 71 |
|
75 | 72 | def run_via_rustpython(filename, test_type):
|
76 | 73 | env = os.environ.copy()
|
77 |
| - log_level = 'info' if test_type == _TestType.benchmark else 'trace' |
78 |
| - env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level) |
| 74 | + env['RUST_LOG'] = 'info,cargo=error,jobserver=error' |
79 | 75 | env['RUST_BACKTRACE'] = '1'
|
| 76 | + |
| 77 | + target = 'release' |
80 | 78 | if env.get('CODE_COVERAGE', 'false') == 'true':
|
81 |
| - subprocess.check_call( |
82 |
| - ['cargo', 'run', filename], env=env) |
83 |
| - else: |
84 |
| - subprocess.check_call( |
85 |
| - ['cargo', 'run', '--release', filename], env=env) |
| 79 | + target = 'debug' |
| 80 | + binary = os.path.abspath(os.path.join(ROOT_DIR, 'target', target, 'rustpython')) |
| 81 | + |
| 82 | + subprocess.check_call([binary, filename], env=env) |
86 | 83 |
|
87 | 84 |
|
88 | 85 | def create_test_function(cls, filename, method, test_type):
|
@@ -124,4 +121,7 @@ def get_test_files():
|
124 | 121 | # @populate('cpython_bytecode')
|
125 | 122 | @populate('rustpython')
|
126 | 123 | class SampleTestCase(unittest.TestCase):
|
127 |
| - pass |
| 124 | + @classmethod |
| 125 | + def setUpClass(cls): |
| 126 | + subprocess.check_call(['cargo', 'build']) |
| 127 | + subprocess.check_call(['cargo', 'build', '--release']) |
0 commit comments