44c6312df8
Also, convert package:vm to use onDiagnostic. We're consolidating all dependencies on package:front_end in one file per tool. The idea is, if you want to depend on something in the package:front_end, you modify pkg/front_end/lib/src/api_unstable/vm.dart and consult with the front-end team. These consolidated files will help us when designing a public API in the future. Change-Id: I66bafdd0ae29605fd12f8d6c589dbc761e5c7a97 Reviewed-on: https://dart-review.googlesource.com/c/77581 Auto-Submit: Peter von der Ahé <ahe@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Peter von der Ahé <ahe@google.com>
54 lines
1.9 KiB
Dart
54 lines
1.9 KiB
Dart
// Copyright (c) 2018, 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.
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:front_end/src/api_unstable/vm.dart'
|
|
show CompilerOptions, DiagnosticMessage;
|
|
import 'package:kernel/ast.dart';
|
|
import 'package:kernel/kernel.dart';
|
|
import 'package:test/test.dart';
|
|
import 'package:vm/bytecode/gen_bytecode.dart' show generateBytecode;
|
|
import 'package:vm/kernel_front_end.dart' show runWithFrontEndCompilerContext;
|
|
|
|
import '../common_test_utils.dart';
|
|
|
|
final String pkgVmDir = Platform.script.resolve('../..').toFilePath();
|
|
|
|
runTestCase(Uri source) async {
|
|
// Certain tests require super-mixin semantics which is used in Flutter.
|
|
bool enableSuperMixins = source.pathSegments.last == 'super_calls.dart';
|
|
|
|
Component component = await compileTestCaseToKernelProgram(source,
|
|
enableSuperMixins: enableSuperMixins);
|
|
|
|
final options = new CompilerOptions()
|
|
..strongMode = true
|
|
..onDiagnostic = (DiagnosticMessage message) {
|
|
fail("Compilation error: ${message.plainTextFormatted.join('\n')}");
|
|
};
|
|
|
|
await runWithFrontEndCompilerContext(source, options, component, () {
|
|
// Need to omit source positions from bytecode as they are different on
|
|
// Linux and Windows (due to differences in newline characters).
|
|
generateBytecode(component, strongMode: true, omitSourcePositions: true);
|
|
});
|
|
|
|
final actual = kernelLibraryToString(component.mainMethod.enclosingLibrary);
|
|
compareResultWithExpectationsFile(source, actual);
|
|
}
|
|
|
|
main() {
|
|
group('gen-bytecode', () {
|
|
final testCasesDir = new Directory(pkgVmDir + '/testcases/bytecode');
|
|
|
|
for (var entry
|
|
in testCasesDir.listSync(recursive: true, followLinks: false)) {
|
|
if (entry.path.endsWith(".dart")) {
|
|
test(entry.path, () => runTestCase(entry.uri));
|
|
}
|
|
}
|
|
});
|
|
}
|