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

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

Issue 2532053005: Store library paths relative to a given application root folder. (Closed)
Patch Set: Revert changes to testcase baseline Created 4 years 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
« no previous file with comments | « pkg/kernel/lib/repository.dart ('k') | pkg/kernel/test/frontend_bench.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:kernel/analyzer/loader.dart'; 6 import 'package:kernel/analyzer/loader.dart';
7 import 'package:kernel/application_root.dart';
7 import 'package:kernel/kernel.dart'; 8 import 'package:kernel/kernel.dart';
8 import 'package:kernel/target/targets.dart'; 9 import 'package:kernel/target/targets.dart';
9 import 'package:kernel/text/ast_to_text.dart'; 10 import 'package:kernel/text/ast_to_text.dart';
10 import 'package:kernel/verifier.dart'; 11 import 'package:kernel/verifier.dart';
11 import 'package:path/path.dart' as pathlib; 12 import 'package:path/path.dart' as pathlib;
12 import 'package:test/test.dart'; 13 import 'package:test/test.dart';
13 14
14 final String testcaseDirectory = 'pkg/kernel/testcases'; 15 final String testcaseDirectory = 'pkg/kernel/testcases';
15 final String inputDirectory = 'pkg/kernel/testcases/input'; 16 final String inputDirectory = 'pkg/kernel/testcases/input';
16 final String sdkDirectory = 'sdk'; 17 final String sdkDirectory = 'sdk';
17 18
18 /// A target to be used for testing. 19 /// A target to be used for testing.
19 /// 20 ///
20 /// To simplify testing dependencies, we avoid transformations that rely on 21 /// To simplify testing dependencies, we avoid transformations that rely on
21 /// a patched SDK or any SDK changes that have not landed in the main SDK. 22 /// a patched SDK or any SDK changes that have not landed in the main SDK.
22 abstract class TestTarget extends Target { 23 abstract class TestTarget extends Target {
23 /// Annotations to apply on the textual output. 24 /// Annotations to apply on the textual output.
24 Annotator get annotator => null; 25 Annotator get annotator => null;
25 26
26 List<String> transformProgram(Program program); 27 List<String> transformProgram(Program program);
27 } 28 }
28 29
29 void runBaselineTests(String folderName, TestTarget target) { 30 void runBaselineTests(String folderName, TestTarget target) {
30 String outputDirectory = '$testcaseDirectory/$folderName'; 31 String outputDirectory = '$testcaseDirectory/$folderName';
31 var batch = new DartLoaderBatch(); 32 var batch = new DartLoaderBatch();
32 Directory directory = new Directory(inputDirectory); 33 Directory directory = new Directory(inputDirectory);
34 var applicationRoot = new ApplicationRoot(directory.absolute.path);
33 for (FileSystemEntity file in directory.listSync()) { 35 for (FileSystemEntity file in directory.listSync()) {
34 if (file is File && file.path.endsWith('.dart')) { 36 if (file is File && file.path.endsWith('.dart')) {
35 String name = pathlib.basename(file.path); 37 String name = pathlib.basename(file.path);
36 test(name, () async { 38 test(name, () async {
37 String dartPath = file.path; 39 Uri dartPath =
40 new Uri(scheme: 'file', path: pathlib.absolute(file.path));
38 String shortName = pathlib.withoutExtension(name); 41 String shortName = pathlib.withoutExtension(name);
39 String filenameOfBaseline = '$outputDirectory/$shortName.baseline.txt'; 42 String filenameOfBaseline = '$outputDirectory/$shortName.baseline.txt';
40 String filenameOfCurrent = '$outputDirectory/$shortName.current.txt'; 43 String filenameOfCurrent = '$outputDirectory/$shortName.current.txt';
41 44
42 var repository = new Repository(); 45 var repository = new Repository();
43 var loader = await batch.getLoader( 46 var loader = await batch.getLoader(
44 repository, 47 repository,
45 new DartOptions( 48 new DartOptions(
46 strongMode: target.strongMode, 49 strongMode: target.strongMode,
47 sdk: sdkDirectory, 50 sdk: sdkDirectory,
48 declaredVariables: target.extraDeclaredVariables)); 51 declaredVariables: target.extraDeclaredVariables,
52 applicationRoot: applicationRoot));
49 var program = loader.loadProgram(dartPath, target: target); 53 var program = loader.loadProgram(dartPath, target: target);
50 verifyProgram(program); 54 verifyProgram(program);
51 var errors = target.transformProgram(program); 55 var errors = target.transformProgram(program);
52 verifyProgram(program); 56 verifyProgram(program);
53 57
54 var buffer = new StringBuffer(); 58 var buffer = new StringBuffer();
55 for (var error in errors) { 59 for (var error in errors) {
56 buffer.writeln('// $error'); 60 buffer.writeln('// $error');
57 } 61 }
58 new Printer(buffer, annotator: target.annotator) 62 new Printer(buffer, annotator: target.annotator)
(...skipping 12 matching lines...) Expand all
71 ' rm $filenameOfBaseline\n' 75 ' rm $filenameOfBaseline\n'
72 'Command to see the diff:\n' 76 'Command to see the diff:\n'
73 ' diff -cd $outputDirectory/$shortName.{baseline,current}.txt' 77 ' diff -cd $outputDirectory/$shortName.{baseline,current}.txt'
74 '\n'); 78 '\n');
75 } 79 }
76 } 80 }
77 }); 81 });
78 } 82 }
79 } 83 }
80 } 84 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/repository.dart ('k') | pkg/kernel/test/frontend_bench.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698