| OLD | NEW |
| 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 library dart_style.test.command_line; | 5 library dart_style.test.command_line; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 import 'package:scheduled_test/descriptor.dart' as d; | 10 import 'package:scheduled_test/descriptor.dart' as d; |
| 11 import 'package:scheduled_test/scheduled_test.dart'; | 11 import 'package:scheduled_test/scheduled_test.dart'; |
| 12 import 'package:scheduled_test/scheduled_stream.dart'; |
| 12 | 13 |
| 13 import 'utils.dart'; | 14 import 'utils.dart'; |
| 14 | 15 |
| 15 void main() { | 16 void main() { |
| 16 setUpTestSuite(); | 17 setUpTestSuite(); |
| 17 | 18 |
| 18 test("Exits with 0 on success.", () { | 19 test("Exits with 0 on success.", () { |
| 19 d.dir("code", [ | 20 d.dir("code", [ |
| 20 d.file("a.dart", unformattedSource) | 21 d.file("a.dart", unformattedSource) |
| 21 ]).create(); | 22 ]).create(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 86 |
| 86 group("--dry-run", () { | 87 group("--dry-run", () { |
| 87 test("prints names of files that would change.", () { | 88 test("prints names of files that would change.", () { |
| 88 d.dir("code", [ | 89 d.dir("code", [ |
| 89 d.file("a_bad.dart", unformattedSource), | 90 d.file("a_bad.dart", unformattedSource), |
| 90 d.file("b_good.dart", formattedSource), | 91 d.file("b_good.dart", formattedSource), |
| 91 d.file("c_bad.dart", unformattedSource), | 92 d.file("c_bad.dart", unformattedSource), |
| 92 d.file("d_good.dart", formattedSource) | 93 d.file("d_good.dart", formattedSource) |
| 93 ]).create(); | 94 ]).create(); |
| 94 | 95 |
| 96 var aBad = p.join("code", "a_bad.dart"); |
| 97 var cBad = p.join("code", "c_bad.dart"); |
| 98 |
| 95 var process = runFormatterOnDir(["--dry-run"]); | 99 var process = runFormatterOnDir(["--dry-run"]); |
| 96 process.stdout.expect(p.join("code", "a_bad.dart")); | 100 |
| 97 process.stdout.expect(p.join("code", "c_bad.dart")); | 101 // The order isn't specified. |
| 102 process.stdout.expect(either(aBad, cBad)); |
| 103 process.stdout.expect(either(aBad, cBad)); |
| 98 process.shouldExit(); | 104 process.shouldExit(); |
| 99 }); | 105 }); |
| 100 | 106 |
| 101 test("does not modify files.", () { | 107 test("does not modify files.", () { |
| 102 d.dir("code", [ | 108 d.dir("code", [ |
| 103 d.file("a.dart", unformattedSource) | 109 d.file("a.dart", unformattedSource) |
| 104 ]).create(); | 110 ]).create(); |
| 105 | 111 |
| 106 var process = runFormatterOnDir(["--dry-run"]); | 112 var process = runFormatterOnDir(["--dry-run"]); |
| 107 process.stdout.expect(p.join("code", "a.dart")); | 113 process.stdout.expect(p.join("code", "a.dart")); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 var process = runFormatter(); | 153 var process = runFormatter(); |
| 148 process.writeLine(unformattedSource); | 154 process.writeLine(unformattedSource); |
| 149 process.closeStdin(); | 155 process.closeStdin(); |
| 150 | 156 |
| 151 // No trailing newline at the end. | 157 // No trailing newline at the end. |
| 152 process.stdout.expect(formattedSource.trimRight()); | 158 process.stdout.expect(formattedSource.trimRight()); |
| 153 process.shouldExit(); | 159 process.shouldExit(); |
| 154 }); | 160 }); |
| 155 }); | 161 }); |
| 156 } | 162 } |
| OLD | NEW |