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

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

Issue 2770063002: Revert "Format all multitests" (Closed)
Patch Set: Created 3 years, 9 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
11 const _SCRIPT_KEY = '_test_script'; 11 const _SCRIPT_KEY = '_test_script';
12 12
13 void expectEquals(a, b) { 13 void expectEquals(a, b) {
14 if (a != b) { 14 if (a != b) {
15 throw 'Expected: $a\n' 15 throw 'Expected: $a\n'
16 ' Actual: $b'; 16 ' Actual: $b';
17 } 17 }
18 } 18 }
19 19
20 void verify(String exePath, {String altPath}) { 20 void verify(String exePath, {String altPath}) {
21 var env = {_SCRIPT_KEY: 'yes'}; 21 var env = {_SCRIPT_KEY: 'yes'};
22 if (altPath != null) { 22 if (altPath != null) {
23 env['PATH'] = altPath; 23 env['PATH'] = altPath;
24 } 24 }
25 25
26 var processResult = Process.runSync(exePath, [scriptPath], 26 var processResult = Process.runSync(exePath, [scriptPath],
27 includeParentEnvironment: false, runInShell: true, environment: env); 27 includeParentEnvironment: false, runInShell: true, environment: env);
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.resolvedExecutable, 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 testShouldFailOutsidePath() { 46 void testShouldFailOutsidePath() {
47 var threw = false; 47 var threw = false;
48 try { 48 try {
49 Process.runSync(platformExeName, ['--version'], 49 Process.runSync(platformExeName, ['--version'],
50 includeParentEnvironment: false, 50 includeParentEnvironment: false,
51 environment: {_SCRIPT_KEY: 'yes', 'PATH': ''}); 51 environment: {_SCRIPT_KEY: 'yes', 'PATH': ''});
52 } catch (_) { 52 } catch (_) {
53 threw = true; 53 threw = true;
54 } 54 }
55 55
56 if (!threw) { 56 if (!threw) {
57 throw 'Expected running the dart executable – "$platformExeName" without' 57 throw 'Expected running the dart executable – "$platformExeName" without'
58 ' the parent environment or path to fail.'; 58 ' the parent environment or path to fail.';
59 } 59 }
60 } 60 }
61 61
62 void testShouldSucceedWithSourcePlatformExecutable() { 62 void testShouldSucceedWithSourcePlatformExecutable() {
63 verify(Platform.resolvedExecutable); 63 verify(Platform.resolvedExecutable);
64 } 64 }
65 65
66 void testExeSymLinked(Directory dir) { 66 void testExeSymLinked(Directory dir) {
67 var dirUri = new Uri.directory(dir.path); 67 var dirUri = new Uri.directory(dir.path);
68 var link = new Link.fromUri(dirUri.resolve('dart_exe_link')); 68 var link = new Link.fromUri(dirUri.resolve('dart_exe_link'));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 withTempDir(testExeDirSymLinked); //# 02: ok 149 withTempDir(testExeDirSymLinked); //# 02: ok
150 testPathToSDKDir(); //# 03: ok 150 testPathToSDKDir(); //# 03: ok
151 withTempDir(testPathPointsToSymLinkedSDKPath); //# 04: ok 151 withTempDir(testPathPointsToSymLinkedSDKPath); //# 04: ok
152 // dart:io does not support linking to files in Windows. 152 // dart:io does not support linking to files in Windows.
153 if (!Platform.isWindows) { 153 if (!Platform.isWindows) {
154 withTempDir(testPathToDirWithExeSymLinked); //# 05: ok 154 withTempDir(testPathToDirWithExeSymLinked); //# 05: ok
155 } 155 }
156 testShouldFailOutsidePath(); //# 06: ok 156 testShouldFailOutsidePath(); //# 06: ok
157 } 157 }
OLDNEW
« no previous file with comments | « tests/lib_strong/mirrors/variable_is_const_test.dart ('k') | tests/standalone/packages_file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698