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

Side by Side Diff: tests/compiler/dart2js/command_line_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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 4
5 // Test the command line options of dart2js. 5 // Test the command line options of dart2js.
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
11 11
12 import 'package:compiler/compiler_new.dart' as api; 12 import 'package:compiler/compiler_new.dart' as api;
13 import 'package:compiler/src/commandline_options.dart'; 13 import 'package:compiler/src/commandline_options.dart';
14 import 'package:compiler/src/dart2js.dart' as entry; 14 import 'package:compiler/src/dart2js.dart' as entry;
15 import 'package:compiler/src/options.dart' show CompilerOptions; 15 import 'package:compiler/src/options.dart' show CompilerOptions;
16 16
17 main() { 17 main() {
18 asyncTest(() async { 18 asyncTest(() async {
19 await test([], exitCode: 1); 19 await test([], exitCode: 1);
20 await test(['foo.dart']); 20 await test(['foo.dart']);
21 await test([Flags.resolveOnly, 'foo.dart'], 21 await test([Flags.resolveOnly, 'foo.dart'],
22 resolveOnly: true, 22 resolveOnly: true, resolutionOutput: Uri.base.resolve('out.data'));
23 resolutionOutput: Uri.base.resolve('out.data'));
24 await test(['--resolution-input=bar.dart', 'foo.dart'], 23 await test(['--resolution-input=bar.dart', 'foo.dart'],
25 resolutionInputs: [Uri.base.resolve('bar.dart')]); 24 resolutionInputs: [Uri.base.resolve('bar.dart')]);
26 await test([Flags.resolveOnly, '--resolution-input=bar.dart', 'foo.dart'], 25 await test([Flags.resolveOnly, '--resolution-input=bar.dart', 'foo.dart'],
27 resolveOnly: true, 26 resolveOnly: true,
28 resolutionOutput: Uri.base.resolve('out.data'), 27 resolutionOutput: Uri.base.resolve('out.data'),
29 resolutionInputs: [Uri.base.resolve('bar.dart')]); 28 resolutionInputs: [Uri.base.resolve('bar.dart')]);
30 await test([Flags.resolveOnly, '--resolution-input=out.data', 'foo.dart'], 29 await test([Flags.resolveOnly, '--resolution-input=out.data', 'foo.dart'],
31 exitCode: 1); 30 exitCode: 1);
32 }); 31 });
33 } 32 }
34 33
35 Future test(List<String> arguments, 34 Future test(List<String> arguments,
36 {int exitCode, 35 {int exitCode,
37 bool resolveOnly: false, 36 bool resolveOnly: false,
38 Uri resolutionOutput, 37 Uri resolutionOutput,
39 List<Uri> resolutionInputs}) async { 38 List<Uri> resolutionInputs}) async {
40 print('--------------------------------------------------------------------'); 39 print('--------------------------------------------------------------------');
41 print('dart2js ${arguments.join(' ')}'); 40 print('dart2js ${arguments.join(' ')}');
42 print('--------------------------------------------------------------------'); 41 print('--------------------------------------------------------------------');
43 entry.CompileFunc oldCompileFunc = entry.compileFunc; 42 entry.CompileFunc oldCompileFunc = entry.compileFunc;
44 entry.ExitFunc oldExitFunc = entry.exitFunc; 43 entry.ExitFunc oldExitFunc = entry.exitFunc;
45 44
46 CompilerOptions options; 45 CompilerOptions options;
47 int actualExitCode; 46 int actualExitCode;
48 entry.compileFunc = (_options, input, diagnostics, output) { 47 entry.compileFunc = (_options, input, diagnostics, output) {
49 options = _options; 48 options = _options;
50 return new Future<api.CompilationResult>.value( 49 return new Future<api.CompilationResult>.value(
51 new api.CompilationResult(null)); 50 new api.CompilationResult(null));
52 }; 51 };
53 entry.exitFunc = (_exitCode) { 52 entry.exitFunc = (_exitCode) {
54 actualExitCode = _exitCode; 53 actualExitCode = _exitCode;
55 throw 'exited'; 54 throw 'exited';
56 }; 55 };
57 try { 56 try {
58 await entry.compilerMain(arguments); 57 await entry.compilerMain(arguments);
59 } catch (e, s) { 58 } catch (e, s) {
60 Expect.equals('exited', e, "Unexpected exception: $e\n$s"); 59 Expect.equals('exited', e, "Unexpected exception: $e\n$s");
61 } 60 }
62 Expect.equals(exitCode, actualExitCode, "Unexpected exit code"); 61 Expect.equals(exitCode, actualExitCode, "Unexpected exit code");
63 if (actualExitCode == null) { 62 if (actualExitCode == null) {
64 Expect.isNotNull(options, "Missing options object"); 63 Expect.isNotNull(options, "Missing options object");
65 Expect.equals(resolveOnly, options.resolveOnly, 64 Expect.equals(
66 "Unexpected resolveOnly value"); 65 resolveOnly, options.resolveOnly, "Unexpected resolveOnly value");
67 Expect.equals(resolutionOutput, options.resolutionOutput, 66 Expect.equals(resolutionOutput, options.resolutionOutput,
68 "Unexpected resolutionOutput value"); 67 "Unexpected resolutionOutput value");
69 if (resolutionInputs == null) { 68 if (resolutionInputs == null) {
70 Expect.isNull(options.resolutionInputs, 69 Expect.isNull(
71 "Unexpected resolutionInputs value"); 70 options.resolutionInputs, "Unexpected resolutionInputs value");
72 } else { 71 } else {
73 Expect.listEquals(resolutionInputs, options.resolutionInputs, 72 Expect.listEquals(resolutionInputs, options.resolutionInputs,
74 "Unexpected resolutionInputs value"); 73 "Unexpected resolutionInputs value");
75 } 74 }
76 } 75 }
77 76
78 entry.compileFunc = oldCompileFunc; 77 entry.compileFunc = oldCompileFunc;
79 entry.exitFunc = oldExitFunc; 78 entry.exitFunc = oldExitFunc;
80 } 79 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/command_line_split_test.dart ('k') | tests/compiler/dart2js/compile_with_empty_libraries_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698