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

Unified Diff: test/command_line_test.dart

Issue 945583004: If no paths are provided, read source from stdin. Fix #165. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/io.dart ('k') | test/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/command_line_test.dart
diff --git a/test/command_line_test.dart b/test/command_line_test.dart
index 64f31acc81072a9175727a93edf7ae96e8eda6ae..8b130b6e68e7c20798ace4c3fe4647bf0c0e34f9 100644
--- a/test/command_line_test.dart
+++ b/test/command_line_test.dart
@@ -20,12 +20,12 @@ void main() {
d.file("a.dart", unformattedSource)
]).create();
- var process = runFormatter();
+ var process = runFormatterOnDir();
process.shouldExit(0);
});
test("Exits with 64 on a command line argument error.", () {
- var process = runFormatter(["-wat"]);
+ var process = runFormatterOnDir(["-wat"]);
process.shouldExit(64);
});
@@ -34,7 +34,7 @@ void main() {
d.file("a.dart", "herp derp i are a dart")
]).create();
- var process = runFormatter();
+ var process = runFormatterOnDir();
process.shouldExit(65);
});
@@ -43,7 +43,25 @@ void main() {
d.file("a.dart", unformattedSource)
]).create();
- var process = runFormatter(["--dry-run", "--overwrite"]);
+ var process = runFormatterOnDir(["--dry-run", "--overwrite"]);
+ process.shouldExit(64);
+ });
+
+ test("Errors if --dry-run and --machine are both passed.", () {
+ d.dir("code", [
+ d.file("a.dart", unformattedSource)
+ ]).create();
+
+ var process = runFormatterOnDir(["--dry-run", "--machine"]);
+ process.shouldExit(64);
+ });
+
+ test("Errors if --machine and --overwrite are both passed.", () {
+ d.dir("code", [
+ d.file("a.dart", unformattedSource)
+ ]).create();
+
+ var process = runFormatterOnDir(["--machine", "--overwrite"]);
process.shouldExit(64);
});
@@ -74,7 +92,7 @@ void main() {
d.file("d_good.dart", formattedSource)
]).create();
- var process = runFormatter(["--dry-run"]);
+ var process = runFormatterOnDir(["--dry-run"]);
process.stdout.expect(p.join("code", "a_bad.dart"));
process.stdout.expect(p.join("code", "c_bad.dart"));
process.shouldExit();
@@ -85,13 +103,13 @@ void main() {
d.file("a.dart", unformattedSource)
]).create();
- var process = runFormatter(["--dry-run"]);
+ var process = runFormatterOnDir(["--dry-run"]);
process.stdout.expect(p.join("code", "a.dart"));
process.shouldExit();
d.dir('code', [
d.file('a.dart', unformattedSource)
- ]).validate();
+ ]).validate();
});
});
@@ -102,7 +120,7 @@ void main() {
d.file("b.dart", unformattedSource)
]).create();
- var process = runFormatter(["--machine", "code"]);
+ var process = runFormatterOnDir(["--machine"]);
var json = {
"path": p.join("code", "a.dart"),
@@ -118,4 +136,21 @@ void main() {
process.shouldExit();
});
});
+
+ group("with no paths", () {
+ test("errors on --overwrite.", () {
+ var process = runFormatter(["--overwrite"]);
+ process.shouldExit(64);
+ });
+
+ test("reads from stdin.", () {
+ var process = runFormatter();
+ process.writeLine(unformattedSource);
+ process.closeStdin();
+
+ // No trailing newline at the end.
+ process.stdout.expect(formattedSource.trimRight());
+ process.shouldExit();
+ });
+ });
}
« no previous file with comments | « lib/src/io.dart ('k') | test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698