Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: pkg/kernel/test/baseline_tester.dart

Issue 2918623004: Use backend targets to run Kernel transformations in Fasta (Closed)
Patch Set: Remove some overrides of performModularTransformationsOnProgram Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 import 'dart:io'; 4 import 'dart:io';
5 5
6 import 'package:analyzer/src/kernel/loader.dart'; 6 import 'package:analyzer/src/kernel/loader.dart';
7 import 'package:kernel/application_root.dart'; 7 import 'package:kernel/application_root.dart';
8 import 'package:kernel/core_types.dart'; 8 import 'package:kernel/core_types.dart';
9 import 'package:kernel/kernel.dart'; 9 import 'package:kernel/kernel.dart';
10 import 'package:kernel/target/targets.dart'; 10 import 'package:kernel/target/targets.dart';
11 import 'package:kernel/text/ast_to_text.dart'; 11 import 'package:kernel/text/ast_to_text.dart';
12 import 'package:kernel/verifier.dart'; 12 import 'package:kernel/verifier.dart';
13 import 'package:path/path.dart' as pathlib; 13 import 'package:path/path.dart' as pathlib;
14 import 'package:test/test.dart'; 14 import 'package:test/test.dart';
15 15
16 final String testcaseDirectory = 'pkg/kernel/testcases'; 16 final String testcaseDirectory = 'pkg/kernel/testcases';
17 final String inputDirectory = 'pkg/kernel/testcases/input'; 17 final String inputDirectory = 'pkg/kernel/testcases/input';
18 final String sdkDirectory = 'sdk'; 18 final String sdkDirectory = 'sdk';
19 19
20 /// A target to be used for testing. 20 /// A target to be used for testing.
21 /// 21 ///
22 /// To simplify testing dependencies, we avoid transformations that rely on 22 /// To simplify testing dependencies, we avoid transformations that rely on
23 /// a patched SDK or any SDK changes that have not landed in the main SDK. 23 /// a patched SDK or any SDK changes that have not landed in the main SDK.
24 abstract class TestTarget extends Target { 24 abstract class TestTarget extends Target {
25 /// Annotations to apply on the textual output. 25 /// Annotations to apply on the textual output.
26 Annotator get annotator => null; 26 Annotator get annotator => null;
27 27
28 // Return a list of strings so that we can accumulate errors. 28 // Return a list of strings so that we can accumulate errors.
29 List<String> performModularTransformations( 29 List<String> performModularTransformationsOnProgram(
30 CoreTypes coreTypes, Program program); 30 CoreTypes coreTypes, Program program);
31 List<String> performGlobalTransformations( 31 List<String> performGlobalTransformations(
32 CoreTypes coreTypes, Program program); 32 CoreTypes coreTypes, Program program);
33 } 33 }
34 34
35 void runBaselineTests(String folderName, TestTarget target) { 35 void runBaselineTests(String folderName, TestTarget target) {
36 String outputDirectory = '$testcaseDirectory/$folderName'; 36 String outputDirectory = '$testcaseDirectory/$folderName';
37 var batch = new DartLoaderBatch(); 37 var batch = new DartLoaderBatch();
38 Directory directory = new Directory(inputDirectory); 38 Directory directory = new Directory(inputDirectory);
39 var applicationRoot = new ApplicationRoot(directory.absolute.path); 39 var applicationRoot = new ApplicationRoot(directory.absolute.path);
(...skipping 12 matching lines...) Expand all
52 var loader = await batch.getLoader( 52 var loader = await batch.getLoader(
53 program, 53 program,
54 new DartOptions( 54 new DartOptions(
55 strongMode: target.strongMode, 55 strongMode: target.strongMode,
56 sdk: sdkDirectory, 56 sdk: sdkDirectory,
57 declaredVariables: target.extraDeclaredVariables, 57 declaredVariables: target.extraDeclaredVariables,
58 applicationRoot: applicationRoot)); 58 applicationRoot: applicationRoot));
59 loader.loadProgram(dartPath, target: target); 59 loader.loadProgram(dartPath, target: target);
60 verifyProgram(program); 60 verifyProgram(program);
61 var errors = <String>[]; 61 var errors = <String>[];
62 errors.addAll(target.performModularTransformations(coreTypes, program)); 62 errors.addAll(
63 target.performModularTransformationsOnProgram(coreTypes, program));
63 verifyProgram(program); 64 verifyProgram(program);
64 errors.addAll(target.performGlobalTransformations(coreTypes, program)); 65 errors.addAll(target.performGlobalTransformations(coreTypes, program));
65 verifyProgram(program); 66 verifyProgram(program);
66 67
67 var buffer = new StringBuffer(); 68 var buffer = new StringBuffer();
68 for (var error in errors) { 69 for (var error in errors) {
69 buffer.writeln('// $error'); 70 buffer.writeln('// $error');
70 } 71 }
71 new Printer(buffer, annotator: target.annotator) 72 new Printer(buffer, annotator: target.annotator)
72 .writeLibraryFile(program.mainMethod.enclosingLibrary); 73 .writeLibraryFile(program.mainMethod.enclosingLibrary);
(...skipping 11 matching lines...) Expand all
84 ' rm $filenameOfBaseline\n' 85 ' rm $filenameOfBaseline\n'
85 'Command to see the diff:\n' 86 'Command to see the diff:\n'
86 ' diff -cd $outputDirectory/$shortName.{baseline,current}.txt' 87 ' diff -cd $outputDirectory/$shortName.{baseline,current}.txt'
87 '\n'); 88 '\n');
88 } 89 }
89 } 90 }
90 }); 91 });
91 } 92 }
92 } 93 }
93 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698