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

Side by Side Diff: lib/src/backend/operating_system.dart

Issue 1732773003: Use identifiers in OperatingSystem.find. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/runner/plugin/platform_helpers.dart » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// An enum of all operating systems supported by Dart. 5 /// An enum of all operating systems supported by Dart.
6 /// 6 ///
7 /// This is used for selecting which operating systems a test can run on. Even 7 /// This is used for selecting which operating systems a test can run on. Even
8 /// for browser tests, this indicates the operating system of the machine 8 /// for browser tests, this indicates the operating system of the machine
9 /// running the test runner. 9 /// running the test runner.
10 class OperatingSystem { 10 class OperatingSystem {
(...skipping 23 matching lines...) Expand all
34 /// This is used when running in the browser, or if an unrecognized operating 34 /// This is used when running in the browser, or if an unrecognized operating
35 /// system is used. It can't be referenced by name in platform selectors. 35 /// system is used. It can't be referenced by name in platform selectors.
36 static const none = const OperatingSystem._("none", "none"); 36 static const none = const OperatingSystem._("none", "none");
37 37
38 /// A list of all instances of [OperatingSystem] other than [none]. 38 /// A list of all instances of [OperatingSystem] other than [none].
39 static const all = const [windows, macOS, linux, android, iOS]; 39 static const all = const [windows, macOS, linux, android, iOS];
40 40
41 /// Finds an operating system by its name. 41 /// Finds an operating system by its name.
42 /// 42 ///
43 /// If no operating system is found, returns [none]. 43 /// If no operating system is found, returns [none].
44 static OperatingSystem find(String name) => 44 static OperatingSystem find(String name) =>
kevmoo 2016/02/24 23:54:59 Need to clarify name vs identifier in the arg, too
nweiz 2016/02/25 23:44:34 Done.
45 all.firstWhere((platform) => platform.name == name, orElse: () => null); 45 all.firstWhere((platform) => platform.identifier == name,
46 orElse: () => null);
46 47
47 /// Finds an operating system by the return value from `dart:io`'s 48 /// Finds an operating system by the return value from `dart:io`'s
48 /// `Platform.operatingSystem`. 49 /// `Platform.operatingSystem`.
49 /// 50 ///
50 /// If no operating system is found, returns [none]. 51 /// If no operating system is found, returns [none].
51 static OperatingSystem findByIoName(String name) { 52 static OperatingSystem findByIoName(String name) {
52 switch (name) { 53 switch (name) {
53 case "windows": return windows; 54 case "windows": return windows;
54 case "macos": return macOS; 55 case "macos": return macOS;
55 case "linux": return linux; 56 case "linux": return linux;
56 case "android": return android; 57 case "android": return android;
57 case "ios": return iOS; 58 case "ios": return iOS;
58 default: return none; 59 default: return none;
59 } 60 }
60 } 61 }
61 62
62 /// The human-friendly of the operating system. 63 /// The human-friendly of the operating system.
63 final String name; 64 final String name;
64 65
65 /// The identifier used to look up the operating system. 66 /// The identifier used to look up the operating system.
66 final String identifier; 67 final String identifier;
67 68
68 /// Whether this is a POSIX-ish operating system. 69 /// Whether this is a POSIX-ish operating system.
69 bool get isPosix => this != windows && this != none; 70 bool get isPosix => this != windows && this != none;
70 71
71 const OperatingSystem._(this.name, this.identifier); 72 const OperatingSystem._(this.name, this.identifier);
72 73
73 String toString() => name; 74 String toString() => name;
74 } 75 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/runner/plugin/platform_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698