You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
TaskManager: add disable() functionality and fix unit tests
This commit is contained in:
@@ -85,7 +85,9 @@ started_launcher = mpos.apps.start_app(launcher_app.fullname)
|
||||
# Then start auto_start_app if configured
|
||||
auto_start_app = prefs.get_string("auto_start_app", None)
|
||||
if auto_start_app and launcher_app.fullname != auto_start_app:
|
||||
mpos.apps.start_app(auto_start_app)
|
||||
result = mpos.apps.start_app(auto_start_app)
|
||||
if result is not True:
|
||||
print(f"WARNING: could not run {auto_start_app} app")
|
||||
|
||||
# Create limited aiorepl because it's better than nothing:
|
||||
import aiorepl
|
||||
|
||||
@@ -6,6 +6,7 @@ class TaskManager:
|
||||
|
||||
task_list = [] # might be good to periodically remove tasks that are done, to prevent this list from growing huge
|
||||
keep_running = None
|
||||
disabled = False
|
||||
|
||||
@classmethod
|
||||
async def _asyncio_thread(cls, ms_to_sleep):
|
||||
@@ -17,6 +18,9 @@ class TaskManager:
|
||||
|
||||
@classmethod
|
||||
def start(cls):
|
||||
if cls.disabled is True:
|
||||
print("Not starting TaskManager because it's been disabled.")
|
||||
return
|
||||
cls.keep_running = True
|
||||
# New thread works but LVGL isn't threadsafe so it's preferred to do this in the same thread:
|
||||
#_thread.stack_size(mpos.apps.good_stack_size())
|
||||
@@ -28,6 +32,10 @@ class TaskManager:
|
||||
def stop(cls):
|
||||
cls.keep_running = False
|
||||
|
||||
@classmethod
|
||||
def disable(cls):
|
||||
cls.disabled = True
|
||||
|
||||
@classmethod
|
||||
def create_task(cls, coroutine):
|
||||
cls.task_list.append(asyncio.create_task(coroutine))
|
||||
|
||||
@@ -73,7 +73,7 @@ class TestIMUCalibrationUI(unittest.TestCase):
|
||||
# Step 4: Click "Check IMU Calibration" (it's a clickable label/container, not a button)
|
||||
print("Step 4: Clicking 'Check IMU Calibration' menu item...")
|
||||
self.assertTrue(click_label("Check IMU Calibration"), "Could not find Check IMU Calibration menu item")
|
||||
wait_for_render(iterations=20)
|
||||
wait_for_render(iterations=40)
|
||||
|
||||
print("Step 5: Checking BEFORE calibration...")
|
||||
print("Current screen content:")
|
||||
|
||||
+5
-5
@@ -59,14 +59,14 @@ one_test() {
|
||||
if [ -z "$ondevice" ]; then
|
||||
# Desktop execution
|
||||
if [ $is_graphical -eq 1 ]; then
|
||||
# Graphical test: include boot_unix.py and main.py
|
||||
"$binary" -X heapsize=8M -c "$(cat main.py) ; import mpos.main ; import mpos.apps; sys.path.append(\"$tests_abs_path\")
|
||||
echo "Graphical test: include main.py"
|
||||
"$binary" -X heapsize=8M -c "import sys ; sys.path.insert(0, 'lib') ; import mpos ; mpos.TaskManager.disable() ; $(cat main.py) ; import mpos.apps; sys.path.append(\"$tests_abs_path\")
|
||||
$(cat $file)
|
||||
result = unittest.main() ; sys.exit(0 if result.wasSuccessful() else 1) "
|
||||
result=$?
|
||||
else
|
||||
# Regular test: no boot files
|
||||
"$binary" -X heapsize=8M -c "$(cat main.py)
|
||||
"$binary" -X heapsize=8M -c "import sys ; sys.path.insert(0, 'lib') ; import mpos ; mpos.TaskManager.disable() ; $(cat main.py)
|
||||
$(cat $file)
|
||||
result = unittest.main() ; sys.exit(0 if result.wasSuccessful() else 1) "
|
||||
result=$?
|
||||
@@ -86,7 +86,7 @@ result = unittest.main() ; sys.exit(0 if result.wasSuccessful() else 1) "
|
||||
echo "$test logging to $testlog"
|
||||
if [ $is_graphical -eq 1 ]; then
|
||||
# Graphical test: system already initialized, just add test paths
|
||||
"$mpremote" exec "$(cat main.py) ; sys.path.append('tests')
|
||||
"$mpremote" exec "import sys ; sys.path.insert(0, 'lib') ; import mpos ; mpos.TaskManager.disable() ; $(cat main.py) ; sys.path.append('tests')
|
||||
$(cat $file)
|
||||
result = unittest.main()
|
||||
if result.wasSuccessful():
|
||||
@@ -96,7 +96,7 @@ else:
|
||||
" | tee "$testlog"
|
||||
else
|
||||
# Regular test: no boot files
|
||||
"$mpremote" exec "$(cat main.py)
|
||||
"$mpremote" exec "import sys ; sys.path.insert(0, 'lib') ; import mpos ; mpos.TaskManager.disable() ; $(cat main.py)
|
||||
$(cat $file)
|
||||
result = unittest.main()
|
||||
if result.wasSuccessful():
|
||||
|
||||
Reference in New Issue
Block a user