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

CU-86drpncrq - Refactor assertCompilerLogs to handle path the same way as assertCompile #1234

Merged
merged 1 commit into from
Apr 11, 2024
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
8 changes: 4 additions & 4 deletions boa3_test/tests/boatestcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,13 @@ def assertCompile(self,

def assertCompilerLogs(self,
expected_logged_exception,
path
*path: str
) -> CompilerOutput | str:
py_abs_path = self.get_contract_path(*path)
output, error_msg = self._assert_compiler_logs_error(expected_logged_exception, py_abs_path)

output, error_msg = self._assert_compiler_logs_error(expected_logged_exception, path)
manifest = {}
if not issubclass(expected_logged_exception, CompilerError):
return output, manifest
return self.compile_and_save(py_abs_path)
else:
# filter to get only the error message, without location information
import re
Expand Down
9 changes: 3 additions & 6 deletions boa3_test/tests/compiler_tests/test_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def test_any_variable_assignments(self):
self.assertEqual(expected_output, output)

def test_variable_assignment_with_any(self):
path = self.get_contract_path('VariableAssignmentWithAny.py')
self.assertCompilerLogs(CompilerError.MismatchedTypes, path)
self.assertCompilerLogs(CompilerError.MismatchedTypes, 'VariableAssignmentWithAny.py')

def test_any_list(self):
ok = String('ok').to_bytes()
Expand Down Expand Up @@ -76,8 +75,7 @@ def test_any_tuple(self):
self.assertEqual(expected_output, output)

def test_any_operation(self):
path = self.get_contract_path('OperationWithAny.py')
self.assertCompilerLogs(CompilerError.MismatchedTypes, path)
self.assertCompilerLogs(CompilerError.MismatchedTypes, 'OperationWithAny.py')

def test_function_any_param(self):
ok = String('ok').to_bytes()
Expand Down Expand Up @@ -346,6 +344,5 @@ def test_sequence_of_int_sequence_fail(self):
+ Opcode.RET
)

path = self.get_contract_path('SequenceOfAnyIntSequence.py')
output, _ = self.assertCompilerLogs(CompilerWarning.TypeCasting, path)
output, _ = self.assertCompilerLogs(CompilerWarning.TypeCasting, 'SequenceOfAnyIntSequence.py')
self.assertEqual(expected_output, output)
12 changes: 4 additions & 8 deletions boa3_test/tests/compiler_tests/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,10 @@ async def test_concat_string_variables_and_constants(self):
# region Division

def test_division_operation(self):
path = self.get_contract_path('Division.py')
self.assertCompilerLogs(CompilerError.NotSupportedOperation, path)
self.assertCompilerLogs(CompilerError.NotSupportedOperation, 'Division.py')

def test_division_augmented_assignment(self):
path = self.get_contract_path('DivisionAugmentedAssignment.py')
self.assertCompilerLogs(CompilerError.NotSupportedOperation, path)
self.assertCompilerLogs(CompilerError.NotSupportedOperation, 'DivisionAugmentedAssignment.py')

async def test_division_builtin_type(self):
await self.set_up_contract('DivisionBuiltinType.py')
Expand Down Expand Up @@ -404,12 +402,10 @@ async def test_list_addition(self):
# region Mismatched

def test_mismatched_type_binary_operation(self):
path = self.get_contract_path('MismatchedOperandBinary.py')
self.assertCompilerLogs(CompilerError.MismatchedTypes, path)
self.assertCompilerLogs(CompilerError.MismatchedTypes, 'MismatchedOperandBinary.py')

def test_mismatched_type_unary_operation(self):
path = self.get_contract_path('MismatchedOperandUnary.py')
self.assertCompilerLogs(CompilerError.MismatchedTypes, path)
self.assertCompilerLogs(CompilerError.MismatchedTypes, 'MismatchedOperandUnary.py')

# endregion

Expand Down
9 changes: 3 additions & 6 deletions boa3_test/tests/compiler_tests/test_assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,13 @@ async def test_assert_with_bytes_message_run(self):
self.assertRegex(String(str(context.exception)).to_bytes(), assert_msg)

def test_assert_with_int_message(self):
path = self.get_contract_path('AssertWithIntMessage.py')
self.assertCompilerLogs(CompilerError.MismatchedTypes, path)
self.assertCompilerLogs(CompilerError.MismatchedTypes, 'AssertWithIntMessage.py')

def test_assert_with_bool_message(self):
path = self.get_contract_path('AssertWithBoolMessage.py')
self.assertCompilerLogs(CompilerError.MismatchedTypes, path)
self.assertCompilerLogs(CompilerError.MismatchedTypes, 'AssertWithBoolMessage.py')

def test_assert_with_list_message(self):
path = self.get_contract_path('AssertWithListMessage.py')
self.assertCompilerLogs(CompilerError.MismatchedTypes, path)
self.assertCompilerLogs(CompilerError.MismatchedTypes, 'AssertWithListMessage.py')

def test_assert_with_str_var_message_compile(self):
assert_msg = String('a must be greater than zero').to_bytes()
Expand Down
6 changes: 2 additions & 4 deletions boa3_test/tests/compiler_tests/test_boa_builtin_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,10 @@ async def test_deploy_def(self):
self.assertEqual(10, result)

def test_deploy_def_incorrect_signature(self):
path = self.get_contract_path('DeployDefWrongSignature.py')
self.assertCompilerLogs(CompilerError.InternalIncorrectSignature, path)
self.assertCompilerLogs(CompilerError.InternalIncorrectSignature, 'DeployDefWrongSignature.py')

def test_will_not_compile(self):
path = self.get_contract_path('WillNotCompile.py')
self.assertCompilerLogs(CompilerError.UnresolvedReference, path)
self.assertCompilerLogs(CompilerError.UnresolvedReference, 'WillNotCompile.py')

# region math builtins

Expand Down
Loading
Loading