mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
shared/runtime/pyexec: Provide support for compile-only mode.
When `MICROPY_PYEXEC_COMPILE_ONLY` is enabled and the global `mp_compile_only` is True, code is compiled but not executed. Also add comprehensive tests for compile-only functionality covering both successful compilation and syntax error detection. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This commit is contained in:
committed by
Damien George
parent
3b2b8dd538
commit
7b3a0fc6b7
13
tests/cmdline/cmd_compile_only.py
Normal file
13
tests/cmdline/cmd_compile_only.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# cmdline: -X compile-only
|
||||
# test compile-only functionality
|
||||
print("This should not be printed")
|
||||
x = 1 + 2
|
||||
|
||||
|
||||
def hello():
|
||||
return "world"
|
||||
|
||||
|
||||
class TestClass:
|
||||
def __init__(self):
|
||||
self.value = 42
|
||||
1
tests/cmdline/cmd_compile_only.py.exp
Normal file
1
tests/cmdline/cmd_compile_only.py.exp
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
6
tests/cmdline/cmd_compile_only_error.py
Normal file
6
tests/cmdline/cmd_compile_only_error.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# cmdline: -X compile-only
|
||||
# test compile-only with syntax error
|
||||
print("This should not be printed")
|
||||
def broken_syntax(
|
||||
# Missing closing parenthesis
|
||||
return "error"
|
||||
1
tests/cmdline/cmd_compile_only_error.py.exp
Normal file
1
tests/cmdline/cmd_compile_only_error.py.exp
Normal file
@@ -0,0 +1 @@
|
||||
CRASH
|
||||
Reference in New Issue
Block a user