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

Side by Side Diff: pkg/testing/lib/src/suite.dart

Issue 2624373003: Move package:testing to SDK. (Closed)
Patch Set: Created 3 years, 11 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 | « pkg/testing/lib/src/stdio_process.dart ('k') | pkg/testing/lib/src/test_dart/README.md » ('j') | 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.md file.
4
5 library testing.suite;
6
7 import 'chain.dart' show
8 Chain;
9
10 /// Records the properties of a test suite.
11 abstract class Suite {
12 final String name;
13
14 final String kind;
15
16 final Uri statusFile;
17
18 Suite(this.name, this.kind, this.statusFile);
19
20 factory Suite.fromJsonMap(Uri base, Map json) {
21 String kind = json["kind"].toLowerCase();
22 String name = json["name"];
23 switch (kind) {
24 case "dart":
25 return new Dart.fromJsonMap(base, json, name);
26
27 case "chain":
28 return new Chain.fromJsonMap(base, json, name, kind);
29
30 default:
31 throw "Suite '$name' has unknown kind '$kind'.";
32 }
33 }
34
35 String toString() => "Suite($name, $kind)";
36 }
37
38 /// A suite of standalone tests. The tests are combined and run as one program.
39 ///
40 /// A standalone test is a test with a `main` method. The test is considered
41 /// successful if main doesn't throw an error (or if `main` returns a future,
42 /// that future completes without errors).
43 ///
44 /// The tests are combined by generating a Dart file which imports all the main
45 /// methods and calls them sequentially.
46 ///
47 /// Example JSON configuration:
48 ///
49 /// {
50 /// "name": "test",
51 /// "kind": "Dart",
52 /// # Root directory of tests in this suite.
53 /// "path": "test/",
54 /// # Files in `path` that match any of the following regular expressions
55 /// # are considered to be part of this suite.
56 /// "pattern": [
57 /// "_test.dart$"
58 /// ],
59 /// # Except if they match any of the following regular expressions.
60 /// "exclude": [
61 /// "/golden/"
62 /// ]
63 /// }
64 class Dart extends Suite {
65 final Uri uri;
66
67 final List<RegExp> pattern;
68
69 final List<RegExp> exclude;
70
71 Dart(String name, this.uri, this.pattern, this.exclude)
72 : super(name, "dart", null);
73
74 factory Dart.fromJsonMap(Uri base, Map json, String name) {
75 Uri uri = base.resolve(json["path"]);
76 List<RegExp> pattern = new List<RegExp>.from(
77 json["pattern"].map((String p) => new RegExp(p)));
78 List<RegExp> exclude = new List<RegExp>.from(
79 json["exclude"].map((String p) => new RegExp(p)));
80 return new Dart(name, uri, pattern, exclude);
81 }
82
83 String toString() => "Dart($name, $uri, $pattern, $exclude)";
84 }
OLDNEW
« no previous file with comments | « pkg/testing/lib/src/stdio_process.dart ('k') | pkg/testing/lib/src/test_dart/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698