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

Side by Side Diff: test/command_line_test.dart

Issue 966443004: Don't rely on directory traversal order in test. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Bump version. Created 5 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
« no previous file with comments | « pubspec.yaml ('k') | 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 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;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 }); 119 });
120 }); 120 });
121 121
122 group("--machine", () { 122 group("--machine", () {
123 test("writes each output as json", () { 123 test("writes each output as json", () {
124 d.dir("code", [ 124 d.dir("code", [
125 d.file("a.dart", unformattedSource), 125 d.file("a.dart", unformattedSource),
126 d.file("b.dart", unformattedSource) 126 d.file("b.dart", unformattedSource)
127 ]).create(); 127 ]).create();
128 128
129 var process = runFormatterOnDir(["--machine"]); 129 var jsonA = JSON.encode({
130
131 var json = {
132 "path": p.join("code", "a.dart"), 130 "path": p.join("code", "a.dart"),
133 "source": formattedSource, 131 "source": formattedSource,
134 "selection": {"offset": -1, "length": -1} 132 "selection": {"offset": -1, "length": -1}
135 }; 133 });
136 134
137 process.stdout.expect(JSON.encode(json)); 135 var jsonB = JSON.encode({
136 "path": p.join("code", "b.dart"),
137 "source": formattedSource,
138 "selection": {"offset": -1, "length": -1}
139 });
138 140
139 json["path"] = p.join("code", "b.dart"); 141 var process = runFormatterOnDir(["--machine"]);
140 process.stdout.expect(JSON.encode(json));
141 142
143 // The order isn't specified.
144 process.stdout.expect(either(jsonA, jsonB));
145 process.stdout.expect(either(jsonA, jsonB));
142 process.shouldExit(); 146 process.shouldExit();
143 }); 147 });
144 }); 148 });
145 149
146 group("with no paths", () { 150 group("with no paths", () {
147 test("errors on --overwrite.", () { 151 test("errors on --overwrite.", () {
148 var process = runFormatter(["--overwrite"]); 152 var process = runFormatter(["--overwrite"]);
149 process.shouldExit(64); 153 process.shouldExit(64);
150 }); 154 });
151 155
152 test("reads from stdin.", () { 156 test("reads from stdin.", () {
153 var process = runFormatter(); 157 var process = runFormatter();
154 process.writeLine(unformattedSource); 158 process.writeLine(unformattedSource);
155 process.closeStdin(); 159 process.closeStdin();
156 160
157 // No trailing newline at the end. 161 // No trailing newline at the end.
158 process.stdout.expect(formattedSource.trimRight()); 162 process.stdout.expect(formattedSource.trimRight());
159 process.shouldExit(); 163 process.shouldExit();
160 }); 164 });
161 }); 165 });
162 } 166 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698