From 8f77550a057ba380f9357db1ea3f129070dc7ffc Mon Sep 17 00:00:00 2001 From: freetlab Date: Thu, 28 May 2026 23:54:18 +0200 Subject: [PATCH] fix(ci): bound critical alarm tests --- .gitea/workflows/build.yml | 32 ++++++++++++++++++++++++---- test/estado/estado_alarmas_test.dart | 16 ++++++++++++-- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 985fae9..e344284 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -30,11 +30,35 @@ jobs: - name: Analizar código run: flutter analyze --no-fatal-infos --no-fatal-warnings - - name: Ejecutar tests criticos + - name: Ejecutar tests críticos run: | - flutter test \ - test/estado/estado_alarmas_test.dart \ - test/servicios/servicio_programacion_alarmas_test.dart + python3 - <<'PY' + import subprocess + import sys + + tests = [ + 'test/servicios/servicio_programacion_alarmas_test.dart', + 'test/estado/estado_alarmas_test.dart', + ] + + for test_path in tests: + cmd = [ + 'flutter', + 'test', + '--concurrency=1', + '--timeout=60s', + '--reporter=expanded', + test_path, + ] + print('$ ' + ' '.join(cmd), flush=True) + try: + result = subprocess.run(cmd, timeout=180) + except subprocess.TimeoutExpired: + print(f'ERROR: timeout ejecutando {test_path}', file=sys.stderr, flush=True) + sys.exit(124) + if result.returncode != 0: + sys.exit(result.returncode) + PY build: name: Build APK + AAB release diff --git a/test/estado/estado_alarmas_test.dart b/test/estado/estado_alarmas_test.dart index 7c9c82b..39234ec 100644 --- a/test/estado/estado_alarmas_test.dart +++ b/test/estado/estado_alarmas_test.dart @@ -22,6 +22,8 @@ void main() { android: android, iniciarAutomaticamente: false, ); + addTearDown(estado.dispose); + addTearDown(android.dispose); await estado.guardarAlarma( const AlarmaMusical( id: 'a1', @@ -55,6 +57,8 @@ void main() { android: android, iniciarAutomaticamente: false, ); + addTearDown(estado.dispose); + addTearDown(android.dispose); await estado.guardarAlarma( AlarmaMusical( id: 'pre1', @@ -80,13 +84,16 @@ void main() { }); test('finalizar diaria calcula siguiente dia y limpia snooze', () async { + final android = FakePuertoAlarmasAndroid(); final estado = EstadoAlarmas( servicio: ServicioAlarmas( reloj: () => DateTime(2026, 5, 25, 7, 31), ), - android: FakePuertoAlarmasAndroid(), + android: android, iniciarAutomaticamente: false, ); + addTearDown(estado.dispose); + addTearDown(android.dispose); await estado.guardarAlarma( AlarmaMusical( id: 'a2', @@ -108,13 +115,16 @@ void main() { }); test('finalizar unica la desactiva y queda sin proxima ejecucion', () async { + final android = FakePuertoAlarmasAndroid(); final estado = EstadoAlarmas( servicio: ServicioAlarmas( reloj: () => DateTime(2026, 5, 25, 7, 31), ), - android: FakePuertoAlarmasAndroid(), + android: android, iniciarAutomaticamente: false, ); + addTearDown(estado.dispose); + addTearDown(android.dispose); await estado.guardarAlarma( AlarmaMusical( id: 'a3', @@ -193,4 +203,6 @@ class FakePuertoAlarmasAndroid implements PuertoAlarmasAndroid { @override Future solicitarPermisoPantallaCompleta() async => true; + + Future dispose() => _eventos.close(); }