You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Change ondevice positional to --ondevice
This commit is contained in:
@@ -178,13 +178,16 @@ Tests are in the `tests/` directory. There are two types: unit tests and manual
|
||||
./tests/unittest.sh tests/test_start_app.py
|
||||
|
||||
# Run a specific test on connected device (via mpremote)
|
||||
./tests/unittest.sh tests/test_shared_preferences.py ondevice
|
||||
./tests/unittest.sh tests/test_shared_preferences.py --ondevice
|
||||
|
||||
# Run all tests on connected device
|
||||
./tests/unittest.sh --ondevice
|
||||
```
|
||||
|
||||
The `unittest.sh` script:
|
||||
- Automatically detects the platform (Linux/macOS) and uses the correct binary
|
||||
- Sets up the proper paths and heapsize
|
||||
- Can run tests on device using `mpremote` with the `ondevice` argument
|
||||
- Can run tests on device using `mpremote` with the `--ondevice` flag
|
||||
- Runs all `test_*.py` files when no argument is provided
|
||||
- On device, assumes the OS is already running (boot.py and main.py already executed), so tests run against the live system
|
||||
- Test infrastructure (graphical_test_helper.py) is automatically installed by `scripts/install.sh`
|
||||
@@ -202,7 +205,7 @@ The `unittest.sh` script:
|
||||
./tests/unittest.sh tests/test_graphical_about_app.py
|
||||
|
||||
# Run graphical tests on device
|
||||
./tests/unittest.sh tests/test_graphical_about_app.py ondevice
|
||||
./tests/unittest.sh tests/test_graphical_about_app.py --ondevice
|
||||
|
||||
# Convert screenshots from raw RGB565 to PNG
|
||||
cd tests/screenshots
|
||||
|
||||
@@ -12,7 +12,7 @@ This is a proof of concept for graphical testing that:
|
||||
|
||||
Usage:
|
||||
Desktop: ./tests/unittest.sh tests/test_graphical_about_app.py
|
||||
Device: ./tests/unittest.sh tests/test_graphical_about_app.py ondevice
|
||||
Device: ./tests/unittest.sh tests/test_graphical_about_app.py --ondevice
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
@@ -12,7 +12,7 @@ trying to access it.
|
||||
|
||||
Usage:
|
||||
Desktop: ./tests/unittest.sh tests/test_graphical_animation_deleted_widget.py
|
||||
Device: ./tests/unittest.sh tests/test_graphical_animation_deleted_widget.py ondevice
|
||||
Device: ./tests/unittest.sh tests/test_graphical_animation_deleted_widget.py --ondevice
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
@@ -6,7 +6,7 @@ and mode switching. Captures screenshots for regression testing.
|
||||
|
||||
Usage:
|
||||
Desktop: ./tests/unittest.sh tests/test_graphical_custom_keyboard.py
|
||||
Device: ./tests/unittest.sh tests/test_graphical_custom_keyboard.py ondevice
|
||||
Device: ./tests/unittest.sh tests/test_graphical_custom_keyboard.py --ondevice
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
@@ -5,7 +5,7 @@ Tests keyboard creation, mode switching, text input, and API compatibility.
|
||||
|
||||
Usage:
|
||||
Desktop: ./tests/unittest.sh tests/test_custom_keyboard.py
|
||||
Device: ./tests/unittest.sh tests/test_custom_keyboard.py ondevice
|
||||
Device: ./tests/unittest.sh tests/test_custom_keyboard.py --ondevice
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
@@ -6,7 +6,7 @@ required by mpos.ui.anim.smooth_show() and smooth_hide().
|
||||
|
||||
Usage:
|
||||
Desktop: ./tests/unittest.sh tests/test_graphical_keyboard_animation.py
|
||||
Device: ./tests/unittest.sh tests/test_graphical_keyboard_animation.py ondevice
|
||||
Device: ./tests/unittest.sh tests/test_graphical_keyboard_animation.py --ondevice
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
@@ -13,7 +13,7 @@ This test should INITIALLY FAIL, demonstrating the bug before the fix is applied
|
||||
|
||||
Usage:
|
||||
Desktop: ./tests/unittest.sh tests/test_graphical_keyboard_styling.py
|
||||
Device: ./tests/unittest.sh tests/test_graphical_keyboard_styling.py ondevice
|
||||
Device: ./tests/unittest.sh tests/test_graphical_keyboard_styling.py --ondevice
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
+17
-5
@@ -5,8 +5,18 @@ mydir=$(dirname "$mydir")
|
||||
testdir="$mydir"
|
||||
scriptdir=$(readlink -f "$mydir"/../scripts/)
|
||||
fs="$mydir"/../internal_filesystem/
|
||||
onetest="$1"
|
||||
ondevice="$2"
|
||||
|
||||
# Parse arguments
|
||||
ondevice=""
|
||||
onetest=""
|
||||
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "--ondevice" ]; then
|
||||
ondevice="yes"
|
||||
else
|
||||
onetest="$arg"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# print os and set binary
|
||||
@@ -95,19 +105,21 @@ else:
|
||||
failed=0
|
||||
|
||||
if [ -z "$onetest" ]; then
|
||||
echo "Usage: $0 [one_test_to_run.py] [ondevice]"
|
||||
echo "Usage: $0 [one_test_to_run.py] [--ondevice]"
|
||||
echo "Example: $0 tests/simple.py"
|
||||
echo "Example: $0 tests/simple.py ondevice"
|
||||
echo "Example: $0 tests/simple.py --ondevice"
|
||||
echo "Example: $0 --ondevice"
|
||||
echo
|
||||
echo "If no test is specified: run all tests from $testdir on local machine."
|
||||
echo
|
||||
echo "The 'ondevice' argument will try to run the test on a connected device using mpremote.py (should be on the PATH) over a serial connection."
|
||||
echo "The '--ondevice' flag will run the test(s) on a connected device using mpremote.py (should be on the PATH) over a serial connection."
|
||||
while read file; do
|
||||
one_test "$file"
|
||||
result=$?
|
||||
if [ $result -ne 0 ]; then
|
||||
echo "\n\n\nWARNING: test $file got error $result !!!\n\n\n"
|
||||
failed=$(expr $failed \+ 1)
|
||||
exit 1
|
||||
fi
|
||||
done < <( find "$testdir" -iname "test_*.py" )
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user