mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-27 21:16:48 +00:00
Add script to find and test all un-touched .dart files
This commit is contained in:
parent
b18dd92079
commit
6b0fd2a708
1
.github/workflows/ci.yaml
vendored
1
.github/workflows/ci.yaml
vendored
@ -38,6 +38,7 @@ jobs:
|
||||
- name: Run Unit Tests
|
||||
run: |
|
||||
cp lib/dummy_dsn.dart lib/dsn.dart
|
||||
python3 find_dart_files.py
|
||||
flutter pub get
|
||||
flutter analyze
|
||||
flutter test --coverage
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,6 +11,9 @@
|
||||
|
||||
coverage/*
|
||||
|
||||
# This file is auto-generated as part of the CI process
|
||||
test/test_touch_files.dart
|
||||
|
||||
# Sentry API key
|
||||
lib/dsn.dart
|
||||
|
||||
|
35
find_dart_files.py
Normal file
35
find_dart_files.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""
|
||||
This script recursively finds any '.dart' files in the ./lib directory,
|
||||
and generates a 'test' file which includes all these files.
|
||||
|
||||
This is to ensure that *all* .dart files are included in test coverage.
|
||||
By default, source files which are not touched by the unit tests are not included!
|
||||
|
||||
Ref: https://github.com/flutter/flutter/issues/27997#issue-410722816
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
dart_files = Path('lib').rglob('*.dart')
|
||||
|
||||
with open("test/test_touch_files.dart", "w") as f:
|
||||
|
||||
f.write("// ignore_for_file: unused_import\n\n")
|
||||
|
||||
for path in dart_files:
|
||||
path = str(path)
|
||||
# Remove leading 'lib\' text
|
||||
path = path[4:]
|
||||
path = path.replace('\\', '/')
|
||||
f.write(f'import "package:inventree/{path}";\n')
|
||||
|
||||
f.write("\n\n")
|
||||
|
||||
f.write("// DO NOT EDIT THIS FILE - it has been auto-generated by 'find_dart_files.py'\n")
|
||||
f.write("// It has been created to ensure that *all* source file are included in coverage data\n")
|
||||
f.write("// Reference: https://github.com/flutter/flutter/issues/27997#issue-410722816\n\n")
|
||||
|
||||
f.write("// Do not actually test anything!")
|
||||
f.write("void main() {}\n")
|
Loading…
x
Reference in New Issue
Block a user