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

Side by Side Diff: pkg/smoke/test/codegen/end_to_end_test.dart

Issue 204113005: Fix end_to_end_test in windows (File takes posix style paths) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 4
5 /// And end-to-end test that generates code and checks that the output matches 5 /// And end-to-end test that generates code and checks that the output matches
6 /// the code in `static_test.dart`. Techincally we could run the result in an 6 /// the code in `static_test.dart`. Techincally we could run the result in an
7 /// isolate, but instead we decided to split that up in two tests. This test 7 /// isolate, but instead we decided to split that up in two tests. This test
8 /// ensures that we generate the code as it was written in static_test, and 8 /// ensures that we generate the code as it was written in static_test, and
9 /// separately static_test ensures that the smoke.static library behaves as 9 /// separately static_test ensures that the smoke.static library behaves as
10 /// expected. 10 /// expected.
11 library smoke.test.codegen.end_to_end_test; 11 library smoke.test.codegen.end_to_end_test;
12 12
13 import 'dart:io'; 13 import 'dart:io';
14 14
15 import 'package:analyzer/src/generated/element.dart'; 15 import 'package:analyzer/src/generated/element.dart';
16 import 'package:smoke/codegen/generator.dart'; 16 import 'package:smoke/codegen/generator.dart';
17 import 'package:smoke/codegen/recorder.dart'; 17 import 'package:smoke/codegen/recorder.dart';
18 import 'package:unittest/unittest.dart'; 18 import 'package:unittest/unittest.dart';
19 import 'package:path/path.dart' as path; 19 import 'package:path/path.dart' as path;
20 20
21 import 'testing_resolver_utils.dart' show initAnalyzer; 21 import 'testing_resolver_utils.dart' show initAnalyzer;
22 22
23 main(args) { 23 main(args) {
24 final updateStaticTest = args.length > 0 && args[0] == '--update_static_test'; 24 final updateStaticTest = args.length > 0 && args[0] == '--update_static_test';
25 25
26 test('static_test is up to date', () { 26 test('static_test is up to date', () {
27 var scriptPath = Platform.script.path; 27 var scriptPath = Platform.script.path;
28 var testDir = path.dirname(path.dirname(scriptPath)); 28 var testDir = path.posix.dirname(path.posix.dirname(scriptPath));
29 var commonPath = path.join(testDir, 'common.dart'); 29 var commonPath = path.posix.join(testDir, 'common.dart');
30 var testCode = new File('$commonPath').readAsStringSync(); 30 var testCode = new File('$commonPath').readAsStringSync();
31 var lib = initAnalyzer({'common.dart' : testCode}) 31 var lib = initAnalyzer({'common.dart' : testCode})
32 .libraryFor('common.dart'); 32 .libraryFor('common.dart');
33 var coreLib = lib.visibleLibraries.firstWhere( 33 var coreLib = lib.visibleLibraries.firstWhere(
34 (l) => l.displayName == 'dart.core'); 34 (l) => l.displayName == 'dart.core');
35 var generator = new SmokeCodeGenerator(); 35 var generator = new SmokeCodeGenerator();
36 var recorder = new Recorder(generator, resolveImportUrl); 36 var recorder = new Recorder(generator, resolveImportUrl);
37 37
38 // Record all getters and setters we use in the tests. 38 // Record all getters and setters we use in the tests.
39 generator.addGetter("i"); 39 generator.addGetter("i");
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 new QueryOptions(includeInherited: true)); 98 new QueryOptions(includeInherited: true));
99 99
100 var vars = lib.definingCompilationUnit.topLevelVariables; 100 var vars = lib.definingCompilationUnit.topLevelVariables;
101 expect(vars[0].name, 'a1'); 101 expect(vars[0].name, 'a1');
102 expect(vars[1].name, 'a2'); 102 expect(vars[1].name, 'a2');
103 var options = new QueryOptions(includeInherited: true, 103 var options = new QueryOptions(includeInherited: true,
104 withAnnotations: [vars[0], vars[1], lib.getType('Annot')]); 104 withAnnotations: [vars[0], vars[1], lib.getType('Annot')]);
105 recorder.runQuery(lib.getType('H'), options); 105 recorder.runQuery(lib.getType('H'), options);
106 106
107 var code = _createEntrypoint(generator); 107 var code = _createEntrypoint(generator);
108 var staticTestFile = new File(path.join(testDir, 'static_test.dart')); 108 var staticTestFile = new File(path.posix.join(testDir, 'static_test.dart'));
109 var existingCode = staticTestFile.readAsStringSync(); 109 var existingCode = staticTestFile.readAsStringSync();
110 if (!updateStaticTest) { 110 if (!updateStaticTest) {
111 expect(code, existingCode); 111 expect(code, existingCode);
112 } else if (code == existingCode) { 112 } else if (code == existingCode) {
113 print('static_test.dart is already up to date'); 113 print('static_test.dart is already up to date');
114 } else { 114 } else {
115 staticTestFile.writeAsStringSync(code); 115 staticTestFile.writeAsStringSync(code);
116 print('static_test.dart has been updated.'); 116 print('static_test.dart has been updated.');
117 } 117 }
118 }); 118 });
(...skipping 19 matching lines...) Expand all
138 sb.writeln('}'); 138 sb.writeln('}');
139 return sb.toString(); 139 return sb.toString();
140 } 140 }
141 141
142 142
143 resolveImportUrl(LibraryElement lib) { 143 resolveImportUrl(LibraryElement lib) {
144 if (lib.isDartCore) return 'dart:core'; 144 if (lib.isDartCore) return 'dart:core';
145 if (lib.displayName == 'smoke.test.common') return 'common.dart'; 145 if (lib.displayName == 'smoke.test.common') return 'common.dart';
146 return 'unknown.dart'; 146 return 'unknown.dart';
147 } 147 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698