| 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 // Process test program to test process communication. | 5 // Process test program to test process communication. |
| 6 | 6 |
| 7 library PlatformExecutableTest; | 7 library PlatformExecutableTest; |
| 8 | 8 |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 var result = processResult.stdout.trim(); | 37 var result = processResult.stdout.trim(); |
| 38 expectEquals(Platform.executable, result); | 38 expectEquals(Platform.executable, result); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void testDartExecShouldNotBeInCurrentDir() { | 41 void testDartExecShouldNotBeInCurrentDir() { |
| 42 var type = FileSystemEntity.typeSync(platformExeName); | 42 var type = FileSystemEntity.typeSync(platformExeName); |
| 43 expectEquals(FileSystemEntityType.NOT_FOUND, type); | 43 expectEquals(FileSystemEntityType.NOT_FOUND, type); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void testShouldFailOutsidePath() { | 46 void testShouldSucceedWithEmptyPathEnvironment() { |
| 47 var threw = false; | 47 Process.runSync(platformExeName, ['--version'], |
| 48 try { | 48 includeParentEnvironment: false, |
| 49 Process.runSync(platformExeName, ['--version'], | 49 environment: {_SCRIPT_KEY: 'yes', 'PATH': ''}); |
| 50 includeParentEnvironment: false, | |
| 51 environment: {_SCRIPT_KEY: 'yes', 'PATH': ''}); | |
| 52 } catch (_) { | |
| 53 threw = true; | |
| 54 } | |
| 55 | |
| 56 if (!threw) { | |
| 57 throw 'Expected running the dart executable – "$platformExeName" without' | |
| 58 ' the parent environment or path to fail.'; | |
| 59 } | |
| 60 } | 50 } |
| 61 | 51 |
| 62 void testShouldSucceedWithSourcePlatformExecutable() { | 52 void testShouldSucceedWithSourcePlatformExecutable() { |
| 63 //print('*** Running normally'); | 53 //print('*** Running normally'); |
| 64 verify(Platform.executable); | 54 verify(Platform.executable); |
| 65 } | 55 } |
| 66 | 56 |
| 67 void testExeSymLinked(Directory dir) { | 57 void testExeSymLinked(Directory dir) { |
| 68 var dirUri = new Uri.directory(dir.path); | 58 var dirUri = new Uri.directory(dir.path); |
| 69 var link = new Link.fromUri(dirUri.resolve('dart_exe_link')); | 59 var link = new Link.fromUri(dirUri.resolve('dart_exe_link')); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return; | 132 return; |
| 143 } | 133 } |
| 144 | 134 |
| 145 testDartExecShouldNotBeInCurrentDir(); | 135 testDartExecShouldNotBeInCurrentDir(); |
| 146 testShouldSucceedWithSourcePlatformExecutable(); /// 00: ok | 136 testShouldSucceedWithSourcePlatformExecutable(); /// 00: ok |
| 147 withTempDir(testExeSymLinked); /// 01: ok | 137 withTempDir(testExeSymLinked); /// 01: ok |
| 148 withTempDir(testExeDirSymLinked); /// 02: ok | 138 withTempDir(testExeDirSymLinked); /// 02: ok |
| 149 testPathToSDKDir(); /// 03: ok | 139 testPathToSDKDir(); /// 03: ok |
| 150 withTempDir(testPathPointsToSymLinkedSDKPath); /// 04: ok | 140 withTempDir(testPathPointsToSymLinkedSDKPath); /// 04: ok |
| 151 withTempDir(testPathToDirWithExeSymLinked); /// 05: ok | 141 withTempDir(testPathToDirWithExeSymLinked); /// 05: ok |
| 152 testShouldFailOutsidePath(); /// 06: ok | 142 testShouldSucceedWithEmptyPathEnvironment(); /// 06: ok |
| 153 } | 143 } |
| OLD | NEW |