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

Side by Side Diff: test/runner/shard_test.dart

Issue 1890853003: Add support for sharding test runs. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 8 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 | « test/runner/configuration/configuration_test.dart ('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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 @TestOn("vm")
6
7 import 'package:scheduled_test/descriptor.dart' as d;
8 import 'package:scheduled_test/scheduled_stream.dart';
9 import 'package:scheduled_test/scheduled_test.dart';
10
11 import 'package:test/src/util/exit_codes.dart' as exit_codes;
12
13 import '../io.dart';
14
15 void main() {
16 useSandbox();
17
18 test("divides all the tests among the available shards", () {
19 d.file("test.dart", """
20 import 'package:test/test.dart';
21
22 void main() {
23 test("test 1", () {});
24 test("test 2", () {});
25 test("test 3", () {});
26 test("test 4", () {});
27 test("test 5", () {});
28 test("test 6", () {});
29 test("test 7", () {});
30 test("test 8", () {});
31 test("test 9", () {});
32 test("test 10", () {});
33 }
34 """).create();
35
36 var test = runTest(["test.dart", "--shard-index=0", "--total-shards=3"]);
37 test.stdout.expect(containsInOrder([
38 "+0: test 1",
39 "+1: test 2",
40 "+2: test 3",
41 "+3: All tests passed!"
42 ]));
43 test.shouldExit(0);
44
45 test = runTest(["test.dart", "--shard-index=1", "--total-shards=3"]);
46 test.stdout.expect(containsInOrder([
47 "+0: test 4",
48 "+1: test 5",
49 "+2: test 6",
50 "+3: test 7",
51 "+4: All tests passed!"
52 ]));
53 test.shouldExit(0);
54
55 test = runTest(["test.dart", "--shard-index=2", "--total-shards=3"]);
56 test.stdout.expect(containsInOrder([
57 "+0: test 8",
58 "+1: test 9",
59 "+2: test 10",
60 "+3: All tests passed!"
61 ]));
62 test.shouldExit(0);
63 });
64
65 test("shards each suite", () {
66 d.file("1_test.dart", """
67 import 'package:test/test.dart';
68
69 void main() {
70 test("test 1.1", () {});
71 test("test 1.2", () {});
72 test("test 1.3", () {});
73 }
74 """).create();
75
76 d.file("2_test.dart", """
77 import 'package:test/test.dart';
78
79 void main() {
80 test("test 2.1", () {});
81 test("test 2.2", () {});
82 test("test 2.3", () {});
83 }
84 """).create();
85
86 var test = runTest([".", "--shard-index=0", "--total-shards=3"]);
87 test.stdout.expect(inOrder([
88 either(containsInOrder([
89 "+0: ./1_test.dart: test 1.1",
90 "+1: ./2_test.dart: test 2.1"
91 ]), containsInOrder([
92 "+0: ./2_test.dart: test 2.1",
93 "+1: ./1_test.dart: test 1.1"
94 ])),
95 contains("+2: All tests passed!")
96 ]));
97 test.shouldExit(0);
98
99
100 test = runTest([".", "--shard-index=1", "--total-shards=3"]);
101 test.stdout.expect(inOrder([
102 either(containsInOrder([
103 "+0: ./1_test.dart: test 1.2",
104 "+1: ./2_test.dart: test 2.2"
105 ]), containsInOrder([
106 "+0: ./2_test.dart: test 2.2",
107 "+1: ./1_test.dart: test 1.2"
108 ])),
109 contains("+2: All tests passed!")
110 ]));
111 test.shouldExit(0);
112
113 test = runTest([".", "--shard-index=2", "--total-shards=3"]);
114 test.stdout.expect(inOrder([
115 either(containsInOrder([
116 "+0: ./1_test.dart: test 1.3",
117 "+1: ./2_test.dart: test 2.3"
118 ]), containsInOrder([
119 "+0: ./2_test.dart: test 2.3",
120 "+1: ./1_test.dart: test 1.3"
121 ])),
122 contains("+2: All tests passed!")
123 ]));
124 test.shouldExit(0);
125 });
126
127 test("an empty shard reports success", () {
128 d.file("test.dart", """
129 import 'package:test/test.dart';
130
131 void main() {
132 test("test 1", () {});
133 test("test 2", () {});
134 }
135 """).create();
136
137 var test = runTest(["test.dart", "--shard-index=1", "--total-shards=3"]);
138 test.stdout.expect(consumeThrough("No tests ran."));
139 test.shouldExit(0);
140 });
141
142 group("reports an error if", () {
143 test("--shard-index is provided alone", () {
144 var test = runTest(["--shard-index=1"]);
145 test.stderr.expect(
146 "--shard-index and --total-shards may only be passed together.");
147 test.shouldExit(exit_codes.usage);
148 });
149
150 test("--total-shards is provided alone", () {
151 var test = runTest(["--total-shards=5"]);
152 test.stderr.expect(
153 "--shard-index and --total-shards may only be passed together.");
154 test.shouldExit(exit_codes.usage);
155 });
156
157 test("--shard-index is negative", () {
158 var test = runTest(["--shard-index=-1", "--total-shards=5"]);
159 test.stderr.expect("--shard-index may not be negative.");
160 test.shouldExit(exit_codes.usage);
161 });
162
163 test("--shard-index is equal to --total-shards", () {
164 var test = runTest(["--shard-index=5", "--total-shards=5"]);
165 test.stderr.expect("--shard-index must be less than --total-shards.");
166 test.shouldExit(exit_codes.usage);
167 });
168 });
169 }
OLDNEW
« no previous file with comments | « test/runner/configuration/configuration_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698