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

Side by Side Diff: tests/standalone/io/platform_resolved_executable_test.dart

Issue 1180623006: Revert change to Platform.excutable and add Platform.resolvedExecutable (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated dart2js io_patch.dart Created 5 years, 6 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
OLDNEW
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 17 matching lines...) Expand all
28 28
29 if (processResult.exitCode != 0) { 29 if (processResult.exitCode != 0) {
30 throw 'Error with process\n' 30 throw 'Error with process\n'
31 '$scriptPath' 31 '$scriptPath'
32 'Exit code: ${processResult.exitCode}\n' 32 'Exit code: ${processResult.exitCode}\n'
33 ' STDOUT: ${processResult.stdout}\n' 33 ' STDOUT: ${processResult.stdout}\n'
34 ' STDERR: ${processResult.stderr}\n'; 34 ' STDERR: ${processResult.stderr}\n';
35 } 35 }
36 36
37 var result = processResult.stdout.trim(); 37 var result = processResult.stdout.trim();
38 expectEquals(Platform.executable, result); 38 expectEquals(Platform.resolvedExecutable, 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 testShouldSucceedWithEmptyPathEnvironment() { 46 void testShouldSucceedWithEmptyPathEnvironment() {
47 var command = Platform.isWindows ? 'cmd' : 'ls'; 47 var command = Platform.isWindows ? 'cmd' : 'ls';
48 Process.runSync(command, [], 48 Process.runSync(command, [],
49 includeParentEnvironment: false, 49 includeParentEnvironment: false,
50 environment: {_SCRIPT_KEY: 'yes', 'PATH': ''}); 50 environment: {_SCRIPT_KEY: 'yes', 'PATH': ''});
51 } 51 }
52 52
53 void testShouldSucceedWithSourcePlatformExecutable() { 53 void testShouldSucceedWithSourcePlatformExecutable() {
54 verify(Platform.executable); 54 verify(Platform.resolvedExecutable);
55 } 55 }
56 56
57 void testExeSymLinked(Directory dir) { 57 void testExeSymLinked(Directory dir) {
58 var dirUri = new Uri.directory(dir.path); 58 var dirUri = new Uri.directory(dir.path);
59 var link = new Link.fromUri(dirUri.resolve('dart_exe_link')); 59 var link = new Link.fromUri(dirUri.resolve('dart_exe_link'));
60 link.createSync(Platform.executable); 60 link.createSync(Platform.resolvedExecutable);
61 verify(link.path); 61 verify(link.path);
62 } 62 }
63 63
64 void testPathToDirWithExeSymLinked(Directory dir) { 64 void testPathToDirWithExeSymLinked(Directory dir) {
65 var dirUri = new Uri.directory(dir.path); 65 var dirUri = new Uri.directory(dir.path);
66 var link = new Link.fromUri(dirUri.resolve('dart_exe_link')); 66 var link = new Link.fromUri(dirUri.resolve('dart_exe_link'));
67 link.createSync(Platform.executable); 67 link.createSync(Platform.resolvedExecutable);
68 verify('dart_exe_link', altPath: dir.path); 68 verify('dart_exe_link', altPath: dir.path);
69 } 69 }
70 70
71 /// Create a sym-link to the SDK directory and run 'dart' from that path 71 /// Create a sym-link to the SDK directory and run 'dart' from that path
72 void testExeDirSymLinked(Directory dir) { 72 void testExeDirSymLinked(Directory dir) {
73 var dirUri = new Uri.directory(dir.path); 73 var dirUri = new Uri.directory(dir.path);
74 74
75 var linkDirUri = dirUri.resolve('dart_bin_dir_link'); 75 var linkDirUri = dirUri.resolve('dart_bin_dir_link');
76 var link = new Link.fromUri(linkDirUri); 76 var link = new Link.fromUri(linkDirUri);
77 77
78 var exeFile = new File(Platform.executable); 78 var exeFile = new File(Platform.resolvedExecutable);
79 79
80 link.createSync(exeFile.parent.path); 80 link.createSync(exeFile.parent.path);
81 81
82 var linkedBin = 82 var linkedBin =
83 new Uri.directory(linkDirUri.toFilePath()).resolve(platformExeName); 83 new Uri.directory(linkDirUri.toFilePath()).resolve(platformExeName);
84 84
85 verify(linkedBin.toFilePath()); 85 verify(linkedBin.toFilePath());
86 } 86 }
87 87
88 void testPathPointsToSymLinkedSDKPath(Directory dir) { 88 void testPathPointsToSymLinkedSDKPath(Directory dir) {
89 var dirUri = new Uri.directory(dir.path); 89 var dirUri = new Uri.directory(dir.path);
90 90
91 var linkDirUri = dirUri.resolve('dart_bin_dir_link'); 91 var linkDirUri = dirUri.resolve('dart_bin_dir_link');
92 var link = new Link.fromUri(linkDirUri); 92 var link = new Link.fromUri(linkDirUri);
93 93
94 var exeFile = new File(Platform.executable); 94 var exeFile = new File(Platform.resolvedExecutable);
95 95
96 link.createSync(exeFile.parent.path); 96 link.createSync(exeFile.parent.path);
97 97
98 verify(platformExeName, altPath: link.path); 98 verify(platformExeName, altPath: link.path);
99 } 99 }
100 100
101 void testPathToSDKDir() { 101 void testPathToSDKDir() {
102 var exeFile = new File(Platform.executable); 102 var exeFile = new File(Platform.resolvedExecutable);
103 var binDirPath = exeFile.parent.path; 103 var binDirPath = exeFile.parent.path;
104 104
105 verify(platformExeName, altPath: binDirPath); 105 verify(platformExeName, altPath: binDirPath);
106 } 106 }
107 107
108 void withTempDir(void test(Directory dir)) { 108 void withTempDir(void test(Directory dir)) {
109 var tempDir = Directory.systemTemp.createTempSync('dart.sdk.test.'); 109 var tempDir = Directory.systemTemp.createTempSync('dart.sdk.test.');
110 try { 110 try {
111 test(tempDir); 111 test(tempDir);
112 } finally { 112 } finally {
113 tempDir.deleteSync(recursive: true); 113 tempDir.deleteSync(recursive: true);
114 } 114 }
115 } 115 }
116 116
117 String get platformExeName { 117 String get platformExeName {
118 var raw = new Uri.file(Platform.executable); 118 var raw = new Uri.file(Platform.resolvedExecutable);
119 return raw.pathSegments.last; 119 return raw.pathSegments.last;
120 } 120 }
121 121
122 String get scriptPath => Platform.script.toFilePath(); 122 String get scriptPath => Platform.script.toFilePath();
123 123
124 void main() { 124 void main() {
125 // The same script is used for both running the tests and as for starting
126 // child verifying the value of Platform.resolvedExecutable. If the
127 // environment variable _SCRIPT_KEY is set this is a child process which
128 // should print the value of Platform.resolvedExecutable.
125 if (Platform.environment.containsKey(_SCRIPT_KEY)) { 129 if (Platform.environment.containsKey(_SCRIPT_KEY)) {
126 print(Platform.executable); 130 print(Platform.resolvedExecutable);
127 return; 131 return;
128 } 132 }
129 133
130 testDartExecShouldNotBeInCurrentDir(); 134 testDartExecShouldNotBeInCurrentDir();
131 testShouldSucceedWithSourcePlatformExecutable(); /// 00: ok 135 testShouldSucceedWithSourcePlatformExecutable(); /// 00: ok
132 // dart:io does not support linking to files in Windows. 136 // dart:io does not support linking to files in Windows.
133 if (!Platform.isWindows) { 137 if (!Platform.isWindows) {
134 withTempDir(testExeSymLinked); /// 01: ok 138 withTempDir(testExeSymLinked); /// 01: ok
135 } 139 }
136 withTempDir(testExeDirSymLinked); /// 02: ok 140 withTempDir(testExeDirSymLinked); /// 02: ok
137 testPathToSDKDir(); /// 03: ok 141 testPathToSDKDir(); /// 03: ok
138 withTempDir(testPathPointsToSymLinkedSDKPath); /// 04: ok 142 withTempDir(testPathPointsToSymLinkedSDKPath); /// 04: ok
139 // dart:io does not support linking to files in Windows. 143 // dart:io does not support linking to files in Windows.
140 if (!Platform.isWindows) { 144 if (!Platform.isWindows) {
141 withTempDir(testPathToDirWithExeSymLinked); /// 05: ok 145 withTempDir(testPathToDirWithExeSymLinked); /// 05: ok
142 } 146 }
143 testShouldSucceedWithEmptyPathEnvironment(); /// 06: ok 147 testShouldSucceedWithEmptyPathEnvironment(); /// 06: ok
144 } 148 }
OLDNEW
« no previous file with comments | « tests/standalone/io/platform_executable_test.dart ('k') | tests/standalone/io/platform_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698