diff --git a/.gitignore b/.gitignore index bbf3282a..f2242e16 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ native/ test/.test_coverage.dart coverage/ coverage_badge.svg +coverage.xml +TEST-report.* # IntelliJ related *.iml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6e742c4..37b57923 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ workflow: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH variables: - FLUTTER_IMAGE_TAG: '3.0.3' + FLUTTER_IMAGE_TAG: '3.0.5' coverage: tags: @@ -23,9 +23,18 @@ coverage: - rm -r example - ./scripts/prepare.sh - ./scripts/test.sh + coverage: /^\s*lines\.*:\s*\d+.\d+\%/ artifacts: + when: always paths: - coverage/ + - coverage.xml + - TEST-report.xml + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml + junit: TEST-report.xml coverage_without_olm: tags: @@ -33,9 +42,26 @@ coverage_without_olm: stage: test image: dart dependencies: [] + variables: + NO_OLM: 1 + before_script: + - apt-get update && apt-get install --no-install-recommends --no-install-suggests -y curl lcov python3 python3-distutils + - curl -o /bin/lcov_cobertura.py https://raw.githubusercontent.com/eriwen/lcov-to-cobertura-xml/master/lcov_cobertura/lcov_cobertura.py && sed 's/env python/env python3/' -i /bin/lcov_cobertura.py && chmod +x /bin/lcov_cobertura.py script: - dart pub get - - dart pub run test + - ./scripts/test.sh + coverage: /^\s*lines\.*:\s*\d+.\d+\%/ + artifacts: + when: always + paths: + - coverage/ + - coverage.xml + - TEST-report.xml + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml + junit: TEST-report.xml e2ee_test: tags: diff --git a/scripts/test.sh b/scripts/test.sh index 0c3f63a0..1a5c17ae 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,6 +1,42 @@ -#!/bin/sh -e -# pub run test -p vm -flutter test --coverage -flutter pub global activate remove_from_coverage -flutter pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$' +#!/bin/bash +if which flutter >/dev/null; then + flutter pub global activate junitreport + flutter test --coverage --machine | tee TEST-report.json + TEST_CODE=${PIPESTATUS[0]} + + # junit report + flutter pub global run junitreport:tojunit --input TEST-report.json --output TEST-report.xml + # remove shell escapes since those are invalid xml + sed 's///g' -i TEST-report.xml + + # coverage + flutter pub global activate remove_from_coverage + flutter pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$' +else + dart pub global activate junitreport + dart test --coverage=coverage --file-reporter='json:TEST-report.json' + TEST_CODE=$? + + # junit report + dart pub global run junitreport:tojunit --input TEST-report.json --output TEST-report.xml + # remove shell escapes since those are invalid xml + sed 's///g' -i TEST-report.xml + + # coverage + dart pub global activate coverage + + reporton="--report-on=lib/" + if [ -n "$NO_OLM" ]; then reporton="--report-on=lib/src --report-on=lib/msc_extensions"; fi + + dart pub global run coverage:format_coverage -i coverage/ --lcov -o coverage/lcov.info $reporton + dart pub global activate remove_from_coverage + dart pub global run remove_from_coverage:remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$' +fi + +# coverage html report genhtml -o coverage coverage/lcov.info || true + +# https://github.com/eriwen/lcov-to-cobertura-xml +lcov_cobertura.py coverage/lcov.info || true + +exit $TEST_CODE diff --git a/test/encryption/bootstrap_test.dart b/test/encryption/bootstrap_test.dart index 428c795d..935c61d9 100644 --- a/test/encryption/bootstrap_test.dart +++ b/test/encryption/bootstrap_test.dart @@ -270,5 +270,10 @@ void main() { if (!olmEnabled) return; await client.dispose(closeDatabase: true); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/cross_signing_test.dart b/test/encryption/cross_signing_test.dart index 15bb22ca..ffe6751e 100644 --- a/test/encryption/cross_signing_test.dart +++ b/test/encryption/cross_signing_test.dart @@ -117,5 +117,10 @@ void main() { if (!olmEnabled) return; await client.dispose(closeDatabase: true); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/encrypt_decrypt_room_message_test.dart b/test/encryption/encrypt_decrypt_room_message_test.dart index d150e3fc..015741fb 100644 --- a/test/encryption/encrypt_decrypt_room_message_test.dart +++ b/test/encryption/encrypt_decrypt_room_message_test.dart @@ -102,5 +102,10 @@ void main() { if (!olmEnabled) return; await client.dispose(closeDatabase: true); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/encrypt_decrypt_to_device_test.dart b/test/encryption/encrypt_decrypt_to_device_test.dart index 10904eae..05d71f98 100644 --- a/test/encryption/encrypt_decrypt_to_device_test.dart +++ b/test/encryption/encrypt_decrypt_to_device_test.dart @@ -120,5 +120,10 @@ void main() { await client.dispose(closeDatabase: true); await otherClient.dispose(closeDatabase: true); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/key_manager_test.dart b/test/encryption/key_manager_test.dart index d9f0e77f..e7499d04 100644 --- a/test/encryption/key_manager_test.dart +++ b/test/encryption/key_manager_test.dart @@ -572,5 +572,10 @@ void main() { if (!olmEnabled) return; await client.dispose(closeDatabase: false); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/key_request_test.dart b/test/encryption/key_request_test.dart index 4470e1b0..6c9df72d 100644 --- a/test/encryption/key_request_test.dart +++ b/test/encryption/key_request_test.dart @@ -400,5 +400,10 @@ void main() { await matrix.dispose(closeDatabase: true); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/key_verification_test.dart b/test/encryption/key_verification_test.dart index d6dc9aa0..a6622715 100644 --- a/test/encryption/key_verification_test.dart +++ b/test/encryption/key_verification_test.dart @@ -241,7 +241,7 @@ void main() async { true); await client1.encryption!.keyVerificationManager.cleanup(); await client2.encryption!.keyVerificationManager.cleanup(); - }); + }, skip: skip); test('ask SSSS start', () async { client1.userDeviceKeys[client1.userID]!.masterKey! @@ -257,7 +257,7 @@ void main() async { await req1.cancel(); await client1.encryption!.keyVerificationManager.cleanup(); - }); + }, skip: skip); test('ask SSSS end', () async { FakeMatrixApi.calledEndpoints.clear(); @@ -379,7 +379,7 @@ void main() async { await client1.encryption!.keyVerificationManager.cleanup(); await client2.encryption!.keyVerificationManager.cleanup(); - }); + }, skip: skip); test('reject verification', () async { FakeMatrixApi.calledEndpoints.clear(); @@ -412,7 +412,7 @@ void main() async { await client1.encryption!.keyVerificationManager.cleanup(); await client2.encryption!.keyVerificationManager.cleanup(); - }); + }, skip: skip); test('reject sas', () async { FakeMatrixApi.calledEndpoints.clear(); @@ -488,7 +488,7 @@ void main() async { await client1.encryption!.keyVerificationManager.cleanup(); await client2.encryption!.keyVerificationManager.cleanup(); - }); + }, skip: skip); test('other device accepted', () async { FakeMatrixApi.calledEndpoints.clear(); @@ -536,6 +536,11 @@ void main() async { '/client/v3/rooms/!1234%3AfakeServer.notExisting/send/m.key.verification.cancel')); await client1.encryption!.keyVerificationManager.cleanup(); await client2.encryption!.keyVerificationManager.cleanup(); - }); - }, skip: skip); + }, skip: skip); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }, skip: skip != 'false' ? 'false' : 'No need for dummy'); + }); } diff --git a/test/encryption/olm_manager_test.dart b/test/encryption/olm_manager_test.dart index 5792b761..1e28e8af 100644 --- a/test/encryption/olm_manager_test.dart +++ b/test/encryption/olm_manager_test.dart @@ -264,5 +264,10 @@ void main() { if (!olmEnabled) return; await client.dispose(closeDatabase: true); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/online_key_backup_test.dart b/test/encryption/online_key_backup_test.dart index aa46ecfd..ff1737aa 100644 --- a/test/encryption/online_key_backup_test.dart +++ b/test/encryption/online_key_backup_test.dart @@ -120,5 +120,10 @@ void main() { if (!olmEnabled) return; await client.dispose(closeDatabase: false); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/ssss_test.dart b/test/encryption/ssss_test.dart index d7a9e7f4..8f845e48 100644 --- a/test/encryption/ssss_test.dart +++ b/test/encryption/ssss_test.dart @@ -496,5 +496,10 @@ void main() { if (!olmEnabled) return; await client.dispose(closeDatabase: true); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/encryption/utils_test.dart b/test/encryption/utils_test.dart index 59e79a58..efecaf72 100644 --- a/test/encryption/utils_test.dart +++ b/test/encryption/utils_test.dart @@ -73,5 +73,10 @@ void main() { expect(shrinkedImage.blurhash, 'L75NyU5kvvbx^7AF#kSgZxOZ%5NE', reason: 'Unexpected scaled image blur'); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(seconds: 1)); + }); }); } diff --git a/test/event_test.dart b/test/event_test.dart index 8cc4edd2..8bca14ba 100644 --- a/test/event_test.dart +++ b/test/event_test.dart @@ -1662,5 +1662,10 @@ void main() { expect(event.onlyEmotes, false); expect(event.numberEmotes, 2); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(milliseconds: 400)); + }); }); } diff --git a/test/matrix_api/try_get_map_extension_test.dart b/test/matrix_api/try_get_map_extension_test.dart index 886700e3..128ce975 100644 --- a/test/matrix_api/try_get_map_extension_test.dart +++ b/test/matrix_api/try_get_map_extension_test.dart @@ -41,5 +41,10 @@ void main() { expect(data.tryGet>('pam')?.tryGet('beep'), null); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(milliseconds: 400)); + }); }); } diff --git a/test/matrix_exception_test.dart b/test/matrix_exception_test.dart index f9769edd..9a5726de 100644 --- a/test/matrix_exception_test.dart +++ b/test/matrix_exception_test.dart @@ -65,5 +65,10 @@ void main() { ); expect(matrixException.error, MatrixError.M_UNKNOWN); }); + + // see https://github.com/dart-lang/test/issues/1698 + test('KeyVerification dummy test', () async { + await Future.delayed(Duration(milliseconds: 400)); + }); }); }