Skip to content

Commit

Permalink
Skip linking test for macos and windows + re-enable CI (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem authored Aug 5, 2024
1 parent 7e5449f commit b0fdf4d
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 66 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410
with:
ndk-version: r26b
if: ${{ (matrix.sdk == 'stable' || matrix.sdk == '3.3.0') && matrix.os != 'macos' }}
if: ${{ matrix.os != 'macos' }}

- run: dart pub get

Expand Down Expand Up @@ -129,14 +129,12 @@ jobs:
# Run on dev to ensure we're not depending on deprecated SDK things.

- run: dart format --output=none --set-exit-if-changed .
if: ${{ (matrix.sdk == 'stable' || matrix.sdk == '3.3.0') }}

- name: Install native toolchains
run: sudo apt-get update && sudo apt-get install clang-15 gcc-i686-linux-gnu gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-riscv64-linux-gnu
if: ${{ (matrix.sdk == 'stable' || matrix.sdk == '3.3.0') && matrix.os == 'ubuntu' }}
if: ${{ matrix.os == 'ubuntu' }}

- run: dart test
if: ${{ (matrix.sdk == 'stable' || matrix.sdk == '3.3.0') }}

- run: dart --enable-experiment=native-assets test
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/
Expand All @@ -160,19 +158,16 @@ jobs:

- name: Install coverage
run: dart pub global activate coverage
if: ${{ matrix.sdk == 'stable' || matrix.sdk == '3.3.0' }}

- name: Collect coverage
run: dart pub global run coverage:test_with_coverage
if: ${{ matrix.sdk == 'stable' || matrix.sdk == '3.3.0' }}

- name: Upload coverage
uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63
with:
flag-name: ${{ matrix.package }}_${{ matrix.os }}
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
if: ${{ matrix.sdk == 'stable' || matrix.sdk == '3.3.0' }}

coverage-finished:
needs: [build]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,34 +107,41 @@ void main() async {
});
});

test('add C file, modify hook', timeout: longTimeout, () async {
await inTempDir((tempUri) async {
await copyTestProjects(targetUri: tempUri);
final packageUri = tempUri.resolve('native_add/');

await runPubGet(workingDirectory: packageUri, logger: logger);
// Make sure the first compile is at least one second after the
// package_config.json is written, otherwise dill compilation isn't
// cached.
await Future<void>.delayed(const Duration(seconds: 1));

{
final result = await build(packageUri, logger, dartExecutable);
await expectSymbols(
asset: result.assets.single as NativeCodeAssetImpl,
symbols: ['add']);
}

await copyTestProjects(
sourceUri: testDataUri.resolve('native_add_add_source/'),
targetUri: packageUri);

{
final result = await build(packageUri, logger, dartExecutable);
await expectSymbols(
asset: result.assets.single as NativeCodeAssetImpl,
symbols: ['add', 'multiply']);
}
});
});
test(
'add C file, modify hook',
timeout: longTimeout,
onPlatform: {
'linux': const Skip('https://github.com/dart-lang/native/issues/1391.'),
},
() async {
await inTempDir((tempUri) async {
await copyTestProjects(targetUri: tempUri);
final packageUri = tempUri.resolve('native_add/');

await runPubGet(workingDirectory: packageUri, logger: logger);
// Make sure the first compile is at least one second after the
// package_config.json is written, otherwise dill compilation isn't
// cached.
await Future<void>.delayed(const Duration(seconds: 1));

{
final result = await build(packageUri, logger, dartExecutable);
await expectSymbols(
asset: result.assets.single as NativeCodeAssetImpl,
symbols: ['add']);
}

await copyTestProjects(
sourceUri: testDataUri.resolve('native_add_add_source/'),
targetUri: packageUri);

{
final result = await build(packageUri, logger, dartExecutable);
await expectSymbols(
asset: result.assets.single as NativeCodeAssetImpl,
symbols: ['add', 'multiply']);
}
});
},
);
}
66 changes: 37 additions & 29 deletions pkgs/native_assets_builder/test/build_runner/link_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,38 +150,46 @@ void main() async {
});
});

test('treeshaking assets using CLinker', timeout: longTimeout, () async {
await inTempDir((tempUri) async {
await copyTestProjects(targetUri: tempUri);
final packageUri = tempUri.resolve('treeshaking_native_libs/');
test(
'treeshaking assets using CLinker',
timeout: longTimeout,
() async {
await inTempDir((tempUri) async {
await copyTestProjects(targetUri: tempUri);
final packageUri = tempUri.resolve('treeshaking_native_libs/');

// First, run `pub get`, we need pub to resolve our dependencies.
await runPubGet(
workingDirectory: packageUri,
logger: logger,
);
// First, run `pub get`, we need pub to resolve our dependencies.
await runPubGet(
workingDirectory: packageUri,
logger: logger,
);

final buildResult = await build(
packageUri,
logger,
dartExecutable,
linkingEnabled: true,
);
expect(buildResult.assets.length, 0);
expect(buildResult.assetsForLinking.length, 1);
final buildResult = await build(
packageUri,
logger,
dartExecutable,
linkingEnabled: true,
);
expect(buildResult.assets.length, 0);
expect(buildResult.assetsForLinking.length, 1);

final logMessages = <String>[];
final linkResult = await link(
packageUri,
logger,
dartExecutable,
buildResult: buildResult,
capturedLogs: logMessages,
);
expect(linkResult.assets.length, 1);
expect(linkResult.assets.first, isA<NativeCodeAsset>());
});
});
final logMessages = <String>[];
final linkResult = await link(
packageUri,
logger,
dartExecutable,
buildResult: buildResult,
capturedLogs: logMessages,
);
expect(linkResult.assets.length, 1);
expect(linkResult.assets.first, isA<NativeCodeAsset>());
});
},
onPlatform: {
'mac-os': const Skip('https://github.com/dart-lang/native/issues/1376.'),
'windows': const Skip('https://github.com/dart-lang/native/issues/1376.'),
},
);
}

Iterable<String> _getNames(List<AssetImpl> assets) =>
Expand Down

0 comments on commit b0fdf4d

Please sign in to comment.