Files
sdk/pkg/dartdev/test/native_assets/test_test.dart
T
Daco Harkes 8ac2279b07 [native assets] Graduate to preview
This PR enables native assets on the main and dev channel by default,
and make native assets available on the beta channel.

This PR removes the flag from invocations.

The helper packages (`package:hooks` and `package:code_assets`) will
stay 0.x for now, until the SDK constraint can be bumped to a beta
release and we're happy with the Dart API.

`dart build` is also made available as preview (without a flag on
the main, dev, and beta channels). We're still finalizing the spec for
this command. (https://github.com/dart-lang/sdk/issues/60730)

`dart test` will need https://github.com/dart-lang/test/pull/2501.
This means users will need to update their `package:test` dependency.

This PR refactors the way that invalid `package_config.json`s are
handled: they are now loaded in the dartdev commands and handled there.

Bug: https://github.com/dart-lang/sdk/issues/50565
Project: https://github.com/orgs/dart-lang/projects/99/

Change-Id: I7db9ff6d7196750cab9379a4605c6bbf89a974d7
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-win-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429920
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-05-21 06:10:19 -07:00

135 lines
3.2 KiB
Dart

// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart=2.18
import 'package:test/test.dart';
import '../utils.dart';
import 'helpers.dart';
void main([List<String> args = const []]) async {
if (!nativeAssetsExperimentAvailableOnCurrentChannel) {
return;
}
// No --source option, `dart run` from source does not output target program
// stdout.
for (final package in [
'native_add',
'native_add_version_skew',
'native_dynamic_linking',
'system_library',
]) {
test('package:$package dart test', timeout: longTimeout, () async {
await nativeAssetsTest(package, usePubWorkspace: true,
(packageUri) async {
final result = await runDart(
arguments: [
'test',
],
workingDirectory: packageUri,
logger: logger,
);
expect(
result.stdout,
stringContainsInOrder(
[
'All tests passed!',
],
),
);
});
});
}
test('dart run test:test', timeout: longTimeout, () async {
await nativeAssetsTest('native_add', (packageUri) async {
final result = await runDart(
arguments: [
'run',
'test:test',
],
workingDirectory: packageUri,
logger: logger,
);
expect(
result.stdout,
stringContainsInOrder(
[
'native add test',
'All tests passed!',
],
),
);
});
});
test('run pub get if needed', timeout: longTimeout, () async {
await nativeAssetsTest(
'native_add',
skipPubGet: true,
(dartAppUri) async {
final result = await runDart(
arguments: [
'test',
],
workingDirectory: dartAppUri,
logger: logger,
);
expect(result.exitCode, equals(0));
},
);
});
test('with native dynamic linking', timeout: longTimeout, () async {
await nativeAssetsTest('native_dynamic_linking', (packageUri) async {
final result = await runDart(
arguments: [
'test',
],
workingDirectory: packageUri,
logger: logger,
);
expect(
result.stdout,
stringContainsInOrder(
[
'invoke native function',
'All tests passed!',
],
),
);
});
});
for (final usePubWorkspace in [true, false]) {
test(
'dart test with user defines',
timeout: longTimeout,
() async {
await nativeAssetsTest('user_defines', usePubWorkspace: usePubWorkspace,
(packageUri) async {
final result = await runDart(
arguments: [
'test',
],
workingDirectory: packageUri,
logger: logger,
);
expect(
result.stdout,
stringContainsInOrder(
[
'All tests passed!',
],
),
);
});
},
);
}
}