-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm/aot] Check in test to ensure in PRODUCT mode we don't retain any …
…code in dart:vmservice_io/dart:_vmservice The CL also updates a number of pragma annotations to be conditional on non-product mode. Change-Id: Ia00b5089d54bbb8f6f6006ef67d65859ab56c132 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127004 Reviewed-by: Vyacheslav Egorov <vegorov@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
- Loading branch information
1 parent
eec49f3
commit 1bbbc9f
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) 2019, 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. | ||
|
||
// This test ensures that certain core libraries are "empty" in product mode (thereby | ||
// ensuring the right conditional pragma annotations were used). | ||
|
||
import "dart:async"; | ||
import "dart:io"; | ||
|
||
import 'package:path/path.dart' as path; | ||
import 'package:kernel/kernel.dart'; | ||
import 'package:expect/expect.dart'; | ||
|
||
import 'use_bare_instructions_flag_test.dart' show run, withTempDir; | ||
|
||
const platformFilename = 'vm_platform_strong.dill'; | ||
|
||
Future main(List<String> args) async { | ||
final buildDir = path.dirname(Platform.resolvedExecutable); | ||
|
||
if (!buildDir.contains('Product')) { | ||
print('Skipping test due to running in non-PRODUCT configuration.'); | ||
return; | ||
} | ||
|
||
if (Platform.isAndroid) { | ||
print('Skipping test due missing "$platformFilename".'); | ||
return; | ||
} | ||
|
||
final platformDill = path.join(buildDir, platformFilename); | ||
await withTempDir((String tempDir) async { | ||
final helloFile = path.join(tempDir, 'hello.dart'); | ||
final helloDillFile = path.join(tempDir, 'hello.dart.dill'); | ||
|
||
// Compile script to Kernel IR. | ||
await File(helloFile).writeAsString('main() => print("Hello");'); | ||
await run('pkg/vm/tool/gen_kernel', <String>[ | ||
'--aot', | ||
'--platform=$platformDill', | ||
'-o', | ||
helloDillFile, | ||
helloFile, | ||
]); | ||
|
||
// Ensure the AOT dill file will have effectively empty service related | ||
// libraries. | ||
final Component component = loadComponentFromBinary(helloDillFile); | ||
|
||
final libVmService = component.libraries | ||
.singleWhere((lib) => lib.importUri.toString() == 'dart:_vmservice'); | ||
Expect.isTrue(libVmService.procedures.isEmpty); | ||
Expect.isTrue(libVmService.classes.isEmpty); | ||
Expect.isTrue(libVmService.fields.isEmpty); | ||
|
||
final libVmServiceIo = component.libraries | ||
.singleWhere((lib) => lib.importUri.toString() == 'dart:vmservice_io'); | ||
Expect.isTrue(libVmServiceIo.procedures.isEmpty); | ||
Expect.isTrue(libVmServiceIo.classes.isEmpty); | ||
|
||
// Those fields are currently accessed by by the embedder, even in product | ||
// mode. | ||
Expect.isTrue(libVmServiceIo.fields.length <= 11); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters