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

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

Issue 2919003003: Reapply "Use backend targets to run Kernel transformations in Fasta" (Closed)
Patch Set: Follow dartanalyzer suggestions 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/class_hierarchy.dart'; 8 import 'package:kernel/class_hierarchy.dart';
9 import 'package:kernel/core_types.dart'; 9 import 'package:kernel/core_types.dart';
10 import 'package:kernel/kernel.dart'; 10 import 'package:kernel/kernel.dart';
11 import 'package:kernel/target/targets.dart'; 11 import 'package:kernel/target/targets.dart';
12 import 'package:kernel/text/ast_to_text.dart'; 12 import 'package:kernel/text/ast_to_text.dart';
13 import 'package:kernel/verifier.dart'; 13 import 'package:kernel/verifier.dart';
14 import 'package:path/path.dart' as pathlib; 14 import 'package:path/path.dart' as pathlib;
15 import 'package:test/test.dart'; 15 import 'package:test/test.dart';
16 16
17 final String testcaseDirectory = 'pkg/kernel/testcases'; 17 final String testcaseDirectory = 'pkg/kernel/testcases';
18 final String inputDirectory = 'pkg/kernel/testcases/input'; 18 final String inputDirectory = 'pkg/kernel/testcases/input';
19 final String sdkDirectory = 'sdk'; 19 final String sdkDirectory = 'sdk';
20 20
21 /// A target to be used for testing. 21 /// A target to be used for testing.
22 /// 22 ///
23 /// To simplify testing dependencies, we avoid transformations that rely on 23 /// To simplify testing dependencies, we avoid transformations that rely on
24 /// a patched SDK or any SDK changes that have not landed in the main SDK. 24 /// a patched SDK or any SDK changes that have not landed in the main SDK.
25 abstract class TestTarget extends Target { 25 abstract class TestTarget extends Target {
26 /// Annotations to apply on the textual output. 26 /// Annotations to apply on the textual output.
27 Annotator get annotator => null; 27 Annotator get annotator => null;
28 28
29 // Return a list of strings so that we can accumulate errors. 29 // Return a list of strings so that we can accumulate errors.
30 List<String> performModularTransformations( 30 List<String> performModularTransformationsOnProgram(
31 CoreTypes coreTypes, ClassHierarchy hierarchy, Program program); 31 CoreTypes coreTypes, ClassHierarchy hierarchy, Program program,
32 {void logger(String msg)});
32 List<String> performGlobalTransformations( 33 List<String> performGlobalTransformations(
33 CoreTypes coreTypes, Program program); 34 CoreTypes coreTypes, Program program,
35 {void logger(String msg)});
34 } 36 }
35 37
36 void runBaselineTests(String folderName, TestTarget target) { 38 void runBaselineTests(String folderName, TestTarget target) {
37 String outputDirectory = '$testcaseDirectory/$folderName'; 39 String outputDirectory = '$testcaseDirectory/$folderName';
38 var batch = new DartLoaderBatch(); 40 var batch = new DartLoaderBatch();
39 Directory directory = new Directory(inputDirectory); 41 Directory directory = new Directory(inputDirectory);
40 var applicationRoot = new ApplicationRoot(directory.absolute.path); 42 var applicationRoot = new ApplicationRoot(directory.absolute.path);
41 for (FileSystemEntity file in directory.listSync()) { 43 for (FileSystemEntity file in directory.listSync()) {
42 if (file is File && file.path.endsWith('.dart')) { 44 if (file is File && file.path.endsWith('.dart')) {
43 String name = pathlib.basename(file.path); 45 String name = pathlib.basename(file.path);
(...skipping 10 matching lines...) Expand all
54 var loader = await batch.getLoader( 56 var loader = await batch.getLoader(
55 program, 57 program,
56 new DartOptions( 58 new DartOptions(
57 strongMode: target.strongMode, 59 strongMode: target.strongMode,
58 sdk: sdkDirectory, 60 sdk: sdkDirectory,
59 declaredVariables: target.extraDeclaredVariables, 61 declaredVariables: target.extraDeclaredVariables,
60 applicationRoot: applicationRoot)); 62 applicationRoot: applicationRoot));
61 loader.loadProgram(dartPath, target: target); 63 loader.loadProgram(dartPath, target: target);
62 verifyProgram(program); 64 verifyProgram(program);
63 var errors = <String>[]; 65 var errors = <String>[];
64 errors.addAll(target.performModularTransformations( 66 errors.addAll(target.performModularTransformationsOnProgram(
65 coreTypes, hierarchy, program)); 67 coreTypes, hierarchy, program));
66 verifyProgram(program); 68 verifyProgram(program);
67 errors.addAll(target.performGlobalTransformations(coreTypes, program)); 69 errors.addAll(target.performGlobalTransformations(coreTypes, program));
68 verifyProgram(program); 70 verifyProgram(program);
69 71
70 var buffer = new StringBuffer(); 72 var buffer = new StringBuffer();
71 for (var error in errors) { 73 for (var error in errors) {
72 buffer.writeln('// $error'); 74 buffer.writeln('// $error');
73 } 75 }
74 new Printer(buffer, annotator: target.annotator) 76 new Printer(buffer, annotator: target.annotator)
(...skipping 12 matching lines...) Expand all
87 ' rm $filenameOfBaseline\n' 89 ' rm $filenameOfBaseline\n'
88 'Command to see the diff:\n' 90 'Command to see the diff:\n'
89 ' diff -cd $outputDirectory/$shortName.{baseline,current}.txt' 91 ' diff -cd $outputDirectory/$shortName.{baseline,current}.txt'
90 '\n'); 92 '\n');
91 } 93 }
92 } 94 }
93 }); 95 });
94 } 96 }
95 } 97 }
96 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698