Skip to content

Commit 60209c6

Browse files
v1: Testing framework (#5479)
* Early prototype * Tester service and basic functionality * Cleanup, being able to test app's main * guess platform * Fix passing FLET_TEST_APP_URL * Update Flet client Android template * The most of tester methods are implemented * Run pytest packages/flet/tests only * Screenshot control * Taking and comparing control screenshots * Golden images per platform * Try macOS integration tests on CI * Fix flutter install * Run tests with debug output * install cocoapods * Simulate mouse hover event * Add more logging * Try this trick * Try this * Fix windows build in yaml * Enable ignore_cleanup_errors for temp dirs * Fix artifacts * Run all CI jobs * Fix last job * Enable integration tests * Fix integration test * brew install cocoapods * Run all integration tests * Save actual image * Fix artifacts section * Update .appveyor.yml * Push images on failure * Fix find path * Try pixel_ratio=2.0 * More reliably close connection * Run all tests * Fix env var * Add duration to pump * More logging to close method * Allow tasks to be cancelled * Cancel wait timeout * Properly shutdown TCP server * More check on server close * Improve handle_connection() * More logging to handle_connection() * Some logging cleanup * Implement ScreenshotKey instead of Screenshot control * Use FVM to run Flutter, add more to readme * Remove fvm * TextField test and readme * Fix accuracy of image compare algo * Re-enable all CI jobs * Simplify integration tests * Text test baseline * `page.test` property * Copilot fix: The task cancellation loop with individual timeout Co-authored-by: Copilot <[email protected]> * Fix double key check * Configurable threshold value * Fix backend imports * Disable pgsl repo * Find apt for pgsql * Fix pgsql * Re-enable all CI jobs * Docs: Added services and testing classes * Rollback Screenshot control * Fix tests to use Screenshot control * Docs, examples for testing and Screenshot, cleanup * Fixed review notes --------- Co-authored-by: Copilot <[email protected]>
1 parent b2dda69 commit 60209c6

File tree

130 files changed

+1703
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1703
-390
lines changed

.appveyor.yml

Lines changed: 107 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -24,79 +24,86 @@ environment:
2424
matrix:
2525
- job_name: Build Flet package for Flutter
2626
job_group: build_flet_package
27-
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu
28-
29-
# - job_name: Build Flet for Windows
30-
# job_group: build_flet
31-
# job_depends_on: build_flet_package
32-
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
33-
34-
# - job_name: Build Flet for macOS
35-
# job_group: build_flet
36-
# job_depends_on: build_flet_package
37-
# APPVEYOR_BUILD_WORKER_IMAGE: macos-sonoma
38-
39-
# - job_name: Build Flet for Linux
40-
# job_group: build_flet_linux
41-
# job_depends_on: build_flet_package
42-
# ARCH: amd64
43-
# PACKAGE_NAME: flet-desktop
44-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
45-
46-
# - job_name: Build Flet Light for Linux
47-
# job_group: build_flet_linux
48-
# job_depends_on: build_flet_package
49-
# ARCH: amd64
50-
# PACKAGE_NAME: flet-desktop-light
51-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
52-
53-
# - job_name: Build Flet for Linux ARM64
54-
# job_group: build_flet_linux
55-
# job_depends_on: build_flet_package
56-
# ARCH: arm64
57-
# PACKAGE_NAME: flet-desktop
58-
# PYTHON_VERSION: 3.10
59-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004-arm
60-
61-
# - job_name: Build Flet Light for Linux ARM64
62-
# job_group: build_flet_linux
63-
# job_depends_on: build_flet_package
64-
# ARCH: arm64
65-
# PACKAGE_NAME: flet-desktop-light
66-
# PYTHON_VERSION: 3.10
67-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004-arm
68-
69-
# - job_name: Build Flet for web
70-
# job_group: build_flet
71-
# job_depends_on: build_flet_package
72-
# PYODIDE_URL: https://github.com/pyodide/pyodide/releases/download/0.27.7/pyodide-core-0.27.7.tar.bz2
73-
# PYODIDE_CDN_URL: https://cdn.jsdelivr.net/pyodide/v0.27.7/full
74-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
75-
76-
# - job_name: Test Python 3.10
77-
# job_group: python_tests
78-
# PYTHON_VERSION: 3.10
79-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
80-
81-
# - job_name: Test Python 3.11
82-
# job_group: python_tests
83-
# PYTHON_VERSION: 3.11
84-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
85-
86-
# - job_name: Test Python 3.12
87-
# job_group: python_tests
88-
# PYTHON_VERSION: 3.12
89-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
90-
91-
# - job_name: Test Python 3.13
92-
# job_group: python_tests
93-
# PYTHON_VERSION: 3.13
94-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
95-
96-
# - job_name: Build Python wheels
97-
# job_group: python_build
98-
# job_depends_on: python_tests, build_flet, build_flet_linux
99-
# APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
27+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2204
28+
29+
- job_name: Integration tests on macOS
30+
job_group: integration_tests
31+
python_stack: python 3.10
32+
APPVEYOR_BUILD_WORKER_IMAGE: macos-sonoma
33+
FLET_TEST_SCREENSHOTS_PIXEL_RATIO: 2.0
34+
FLET_TEST_SIMILARITY_THRESHOLD: 99.0
35+
36+
- job_name: Build Flet for Windows
37+
job_group: build_flet
38+
job_depends_on: build_flet_package
39+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
40+
41+
- job_name: Build Flet for macOS
42+
job_group: build_flet
43+
job_depends_on: build_flet_package
44+
APPVEYOR_BUILD_WORKER_IMAGE: macos-sonoma
45+
46+
- job_name: Build Flet for Linux
47+
job_group: build_flet_linux
48+
job_depends_on: build_flet_package
49+
ARCH: amd64
50+
PACKAGE_NAME: flet-desktop
51+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
52+
53+
- job_name: Build Flet Light for Linux
54+
job_group: build_flet_linux
55+
job_depends_on: build_flet_package
56+
ARCH: amd64
57+
PACKAGE_NAME: flet-desktop-light
58+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
59+
60+
- job_name: Build Flet for Linux ARM64
61+
job_group: build_flet_linux
62+
job_depends_on: build_flet_package
63+
ARCH: arm64
64+
PACKAGE_NAME: flet-desktop
65+
PYTHON_VERSION: 3.10
66+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004-arm
67+
68+
- job_name: Build Flet Light for Linux ARM64
69+
job_group: build_flet_linux
70+
job_depends_on: build_flet_package
71+
ARCH: arm64
72+
PACKAGE_NAME: flet-desktop-light
73+
PYTHON_VERSION: 3.10
74+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004-arm
75+
76+
- job_name: Build Flet for web
77+
job_group: build_flet
78+
job_depends_on: build_flet_package
79+
PYODIDE_URL: https://github.com/pyodide/pyodide/releases/download/0.27.7/pyodide-core-0.27.7.tar.bz2
80+
PYODIDE_CDN_URL: https://cdn.jsdelivr.net/pyodide/v0.27.7/full
81+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
82+
83+
- job_name: Test Python 3.10
84+
job_group: python_tests
85+
PYTHON_VERSION: 3.10
86+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
87+
88+
- job_name: Test Python 3.11
89+
job_group: python_tests
90+
PYTHON_VERSION: 3.11
91+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
92+
93+
- job_name: Test Python 3.12
94+
job_group: python_tests
95+
PYTHON_VERSION: 3.12
96+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
97+
98+
- job_name: Test Python 3.13
99+
job_group: python_tests
100+
PYTHON_VERSION: 3.13
101+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
102+
103+
- job_name: Build Python wheels
104+
job_group: python_build
105+
job_depends_on: python_tests, build_flet, build_flet_linux
106+
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
100107

101108
matrix:
102109
fast_finish: true
@@ -150,6 +157,27 @@ for:
150157
151158
fi
152159
160+
###########################
161+
# Integration Tests #
162+
###########################
163+
- matrix:
164+
only:
165+
- job_group: integration_tests
166+
167+
install:
168+
- HOMEBREW_NO_AUTO_UPDATE=1 brew install cocoapods
169+
- source ci/common.sh
170+
- source ci/install_flutter.sh
171+
172+
build: off
173+
174+
test_script:
175+
- cd sdk/python
176+
- uv run pytest -s -o log_cli=true -o log_cli_level=DEBUG packages/flet/integration_tests/
177+
178+
on_failure:
179+
- find packages/flet/integration_tests -type f -name '*_actual.png' -exec appveyor PushArtifact {} \;
180+
153181
# ======================================
154182
# Build Flet Client for Windows
155183
# ======================================
@@ -201,8 +229,8 @@ for:
201229
- uv build --wheel --package flet-desktop
202230
- ps: |
203231
Get-ChildItem -Path dist/*-py3-none-any.whl | ForEach-Object {
204-
Start-ProcessWithOutput "uv run --with wheel --no-project $env:APPVEYOR_BUILD_FOLDER\ci\repackage_wheel_with_tag.py $_.FullName 'py3-none-win_amd64'"
205-
Start-ProcessWithOutput "uv run --with wheel --no-project $env:APPVEYOR_BUILD_FOLDER\ci\repackage_wheel_with_tag.py $_.FullName 'py3-none-win32'"
232+
Start-ProcessWithOutput "uv run --with wheel --no-project $env:APPVEYOR_BUILD_FOLDER\ci\repackage_wheel_with_tag.py $($_.FullName) py3-none-win_amd64"
233+
Start-ProcessWithOutput "uv run --with wheel --no-project $env:APPVEYOR_BUILD_FOLDER\ci\repackage_wheel_with_tag.py $($_.FullName) py3-none-win32"
206234
Remove-Item $_.FullName
207235
}
208236
- dir dist
@@ -223,7 +251,7 @@ for:
223251

224252
artifacts:
225253
- path: client\build\windows\x64\runner\flet-windows.zip
226-
- path: sdk\python\packages\*.whl
254+
- path: sdk\python\dist\*.whl
227255

228256
deploy:
229257
provider: GitHub
@@ -291,6 +319,7 @@ for:
291319

292320
install:
293321
- source ci/common.sh
322+
- sudo sed -i.bak '/apt.postgresql.org/s/^/# /' /etc/apt/sources.list
294323
- sudo apt update --allow-releaseinfo-change
295324
- sudo apt install -y clang libgtk-3-dev libasound2-dev
296325
- sh: |
@@ -429,7 +458,7 @@ for:
429458
test_script:
430459
# run tests
431460
- cd sdk/python
432-
- uv run --group test pytest
461+
- uv run --group test pytest packages/flet/tests
433462

434463
# docs coverage report
435464
- uv run --directory packages/flet --group docs-coverage docstr-coverage > docstr_coverage.log 2>&1
@@ -458,7 +487,7 @@ for:
458487
- uv build --wheel --package flet
459488

460489
# update deps
461-
- python $root/ci/update-flet-wheel-deps.py dist
490+
- uv run --with wheel $root/ci/update-flet-wheel-deps.py dist
462491

463492
# publish packages
464493
- publish_to_pypi dist/*.whl

ci/repackage_wheel_with_tag.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99

1010
def repackage_wheel(wheel_path, new_tag):
11-
1211
wheel_path = os.path.realpath(wheel_path)
1312
print(f"Re-packaging wheel {wheel_path} with {new_tag}")
1413

1514
# Create temporary directory
16-
with tempfile.TemporaryDirectory() as tmp_dir:
15+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmp_dir:
1716
tmp_dir_path = Path(tmp_dir)
1817

1918
# Unpack the wheel file

ci/update-flet-wheel-deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def process_wheels(directory):
7373
print(f"Version: {version}")
7474

7575
# Create a temporary directory
76-
with tempfile.TemporaryDirectory() as tmp_dir:
76+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmp_dir:
7777
# Unpack the wheel file
7878
wheel.cli.unpack.unpack(wheel_file, tmp_dir)
7979

client/.metadata

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "5dcb86f68f239346676ceb1ed1ea385bd215fba1"
7+
revision: "6fba2447e95c451518584c35e25f5433f14d888c"
88
channel: "stable"
99

1010
project_type: app
@@ -13,11 +13,11 @@ project_type: app
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
17-
base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
18-
- platform: linux
19-
create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
20-
base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1
16+
create_revision: 6fba2447e95c451518584c35e25f5433f14d888c
17+
base_revision: 6fba2447e95c451518584c35e25f5433f14d888c
18+
- platform: android
19+
create_revision: 6fba2447e95c451518584c35e25f5433f14d888c
20+
base_revision: 6fba2447e95c451518584c35e25f5433f14d888c
2121

2222
# User provided section
2323

client/android/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ gradle-wrapper.jar
55
/gradlew.bat
66
/local.properties
77
GeneratedPluginRegistrant.java
8+
.cxx/
89

910
# Remember to never publicly share your keystore.
10-
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
# See https://flutter.dev/to/reference-keystore
1112
key.properties
1213
**/*.keystore
1314
**/*.jks

client/android/app/build.gradle

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)