OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "dart:async"; | 5 import "dart:async"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 import "dart:isolate"; | 7 import "dart:isolate"; |
8 | 8 |
9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
11 | 11 |
12 test() { | 12 test() { |
13 Expect.isTrue(Platform.numberOfProcessors > 0); | 13 Expect.isTrue(Platform.numberOfProcessors > 0); |
14 var os = Platform.operatingSystem; | 14 var os = Platform.operatingSystem; |
15 Expect.isTrue(os == "android" || os == "linux" || os == "macos" || | 15 Expect.isTrue(os == "android" || os == "linux" || os == "macos" || |
16 os == "windows"); | 16 os == "windows"); |
17 Expect.equals(Platform.isLinux, Platform.operatingSystem == "linux"); | 17 Expect.equals(Platform.isLinux, Platform.operatingSystem == "linux"); |
18 Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos"); | 18 Expect.equals(Platform.isMacOS, Platform.operatingSystem == "macos"); |
19 Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows"); | 19 Expect.equals(Platform.isWindows, Platform.operatingSystem == "windows"); |
20 Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android"); | 20 Expect.equals(Platform.isAndroid, Platform.operatingSystem == "android"); |
21 var sep = Platform.pathSeparator; | 21 var sep = Platform.pathSeparator; |
22 Expect.isTrue(sep == '/' || (os == 'windows' && sep == '\\')); | 22 Expect.isTrue(sep == '/' || (os == 'windows' && sep == '\\')); |
23 var hostname = Platform.localHostname; | 23 var hostname = Platform.localHostname; |
24 Expect.isTrue(hostname is String && hostname != ""); | 24 Expect.isTrue(hostname is String && hostname != ""); |
25 var environment = Platform.environment; | 25 var environment = Platform.environment; |
26 Expect.isTrue(environment is Map<String, String>); | 26 Expect.isTrue(environment is Map<String, String>); |
27 Expect.isTrue(Platform.executable.contains('dart')); | |
28 if (!Platform.isWindows) { | 27 if (!Platform.isWindows) { |
29 Expect.isTrue(Platform.executable.startsWith('/')); | 28 Expect.isTrue(Platform.executable.endsWith('dart')); |
| 29 Expect.isTrue(Platform.resolvedExecutable.endsWith('dart')); |
| 30 } else { |
| 31 Expect.isTrue(Platform.executable.endsWith('dart.exe')); |
| 32 Expect.isTrue(Platform.resolvedExecutable.endsWith('dart.exe')); |
| 33 } |
| 34 if (!Platform.isWindows) { |
| 35 Expect.isTrue(Platform.resolvedExecutable.startsWith('/')); |
30 } else { | 36 } else { |
31 // This assumes that tests (both locally and on the bots) are | 37 // This assumes that tests (both locally and on the bots) are |
32 // running off a location referred to by a drive letter. If a UNC | 38 // running off a location referred to by a drive letter. If a UNC |
33 // location is used or long names ("\\?\" prefix) is used this | 39 // location is used or long names ("\\?\" prefix) is used this |
34 // needs to be fixed. | 40 // needs to be fixed. |
35 Expect.equals(Platform.executable.substring(1, 3), ':\\'); | 41 Expect.equals(Platform.executable.substring(1, 3), ':\\'); |
36 } | 42 } |
37 // Move directory to be sure script is correct. | 43 // Move directory to be sure script is correct. |
38 var oldDir = Directory.current; | 44 var oldDir = Directory.current; |
39 Directory.current = Directory.current.parent; | 45 Directory.current = Directory.current.parent; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 Expect.throws(() => checkValidVersion('x.y.z')); | 132 Expect.throws(() => checkValidVersion('x.y.z')); |
127 } | 133 } |
128 | 134 |
129 main() { | 135 main() { |
130 // This tests assumes paths relative to dart main directory | 136 // This tests assumes paths relative to dart main directory |
131 Directory.current = Platform.script.resolve('../../..').toFilePath(); | 137 Directory.current = Platform.script.resolve('../../..').toFilePath(); |
132 test(); | 138 test(); |
133 testIsolate(); | 139 testIsolate(); |
134 testVersion(); | 140 testVersion(); |
135 } | 141 } |
OLD | NEW |