Skip to content

Commit

Permalink
Delete coverage.sh (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe authored May 7, 2024
1 parent 877114b commit a152cfa
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 51 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/ffigen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,15 @@ jobs:
run: flutter pub get
- name: Build test dylib and bindings
run: dart test/setup.dart
- name: Run VM tests
run: dart test
- name: Collect coverage
run: ./tool/coverage.sh
- name: Run VM tests and collect coverage
run: dart run coverage:test_with_coverage --scope-output=ffigen --scope-output=objective_c
- name: Upload coverage
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
with:
flag-name: ffigen_macos
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
path-to-lcov: pkgs/ffigen/lcov.info
path-to-lcov: pkgs/ffigen/coverage/lcov.info
- name: Upload coverage
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
with:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/objective_c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,15 @@ jobs:
- name: Build test dylib
# TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
run: dart test/setup.dart
- name: Run VM tests
run: dart test
- name: Collect coverage
run: ./tool/coverage.sh
- name: Run VM tests and collect coverage
run: dart run coverage:test_with_coverage --scope-output=ffigen --scope-output=objective_c
- name: Upload coverage
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
with:
flag-name: objective_c_tests
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
path-to-lcov: pkgs/objective_c/lcov.info
path-to-lcov: pkgs/objective_c/coverage/lcov.info
- name: Upload coverage
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
with:
Expand Down
3 changes: 1 addition & 2 deletions pkgs/ffigen/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ experiments/
# Files generated by tests for debugging purposes.
test/debug_generated/*
!test/debug_generated/readme.md
lcov.info
coverage.json
coverage/

# Files generated by various OSs.
.DS_Store
1 change: 1 addition & 0 deletions pkgs/ffigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies:
yaml_edit: ^2.0.3

dev_dependencies:
coverage: ^1.8.0
json_schema: ^5.1.1
lints: ^2.0.1
meta: ^1.11.0
Expand Down
41 changes: 32 additions & 9 deletions pkgs/ffigen/test/native_objc_test/automated_ref_count_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
// Objective C support is only available on mac.
@TestOn('mac-os')

// This test is slightly flaky. Some of the ref counts are occasionally lower
// than expected, presumably due to the Dart wrapper objects being GC'd before
// the expect call.
@Retry(3)

import 'dart:ffi';
import 'dart:io';

Expand Down Expand Up @@ -37,15 +42,6 @@ void main() {
test('objectRetainCount edge cases', () {
expect(objectRetainCount(nullptr), 0);
expect(objectRetainCount(Pointer.fromAddress(0x1234)), 0);

final obj = NSObject.new1();
final objRefs = <NSObject>[];
for (int i = 1; i < 1000; ++i) {
final expectedCount = i < 128 ? i : 128;
expect(objectRetainCount(obj.pointer), expectedCount);
objRefs.add(
NSObject.castFromPointer(obj.pointer, retain: true, release: true));
}
});

(Pointer<ObjCObject>, Pointer<ObjCObject>) newMethodsInner(
Expand Down Expand Up @@ -492,5 +488,32 @@ void main() {
expect(objectRetainCount(obj1bRaw), 0);
calloc.free(counter);
});

void largeRefCountInner(Pointer<Int32> counter) {
final obj = ArcTestObject.newWithCounter_(counter);
expect(counter.value, 1);
final objRefs = <ArcTestObject>[];
for (int i = 1; i < 1000; ++i) {
final expectedCount = i < 128 ? i : 128;
expect(objectRetainCount(obj.pointer), expectedCount);
objRefs.add(ArcTestObject.castFromPointer(obj.pointer,
retain: true, release: true));
}
expect(counter.value, 1);
}

test("objectRetainCount large ref count", () {
// Most ObjC API methods return us a reference without incrementing the
// ref count (ie, returns us a reference we don't own). So the wrapper
// object has to take ownership by calling retain. This test verifies that
// is working correctly by holding a reference to an object returned by a
// method, after the original wrapper object is gone.
final counter = calloc<Int32>();
counter.value = 0;
largeRefCountInner(counter);
doGC();
expect(counter.value, 0);
calloc.free(counter);
});
});
}
15 changes: 0 additions & 15 deletions pkgs/ffigen/tool/coverage.sh

This file was deleted.

1 change: 1 addition & 0 deletions pkgs/objective_c/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
.history
.svn/
migrate_working_dir/
coverage/

# IntelliJ related
*.iml
Expand Down
1 change: 1 addition & 0 deletions pkgs/objective_c/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
yaml: ^3.1.0

dev_dependencies:
coverage: ^1.8.0
ffigen: ^11.0.0
flutter_test:
sdk: flutter
Expand Down
15 changes: 0 additions & 15 deletions pkgs/objective_c/tool/coverage.sh

This file was deleted.

0 comments on commit a152cfa

Please sign in to comment.