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

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

Issue 19967002: Remove uses of Path class from tests/standalone. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix windows error Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « tests/standalone/io/stdin_sync_test.dart ('k') | tests/standalone/io/test_extension_test.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) 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 // Dart test program for testing native extensions. 5 // Dart test program for testing native extensions.
6 6
7 import "package:path/path.dart";
7 import "dart:async"; 8 import "dart:async";
8 import "dart:io"; 9 import "dart:io";
9 10
10 Future copyFileToDirectory(Path file, Path directory) { 11 Future copyFileToDirectory(String file, String directory) {
11 String src = file.toNativePath();
12 String dst = directory.toNativePath();
13 switch (Platform.operatingSystem) { 12 switch (Platform.operatingSystem) {
14 case 'linux': 13 case 'linux':
15 case 'macos': 14 case 'macos':
16 return Process.run('cp', [src, dst]); 15 return Process.run('cp', [file, directory]);
17 case 'windows': 16 case 'windows':
18 return Process.run('cmd.exe', ['/C', 'copy $src $dst']); 17 return Process.run('cmd.exe', ['/C', 'copy $file $directory']);
19 default: 18 default:
20 throw new StateError( 19 throw new StateError(
21 'Unknown operating system ${Platform.operatingSystem}'); 20 'Unknown operating system ${Platform.operatingSystem}');
22 } 21 }
23 } 22 }
24 23
25 Path getExtensionPath(Path buildDirectory) { 24 String getExtensionPath(String buildDirectory) {
26 switch (Platform.operatingSystem) { 25 switch (Platform.operatingSystem) {
27 case 'linux': 26 case 'linux':
28 return buildDirectory.append('lib.target/libtest_extension.so'); 27 return join(buildDirectory, 'lib.target', 'libtest_extension.so');
29 case 'macos': 28 case 'macos':
30 return buildDirectory.append('libtest_extension.dylib'); 29 return join(buildDirectory, 'libtest_extension.dylib');
31 case 'windows': 30 case 'windows':
32 return buildDirectory.append('test_extension.dll'); 31 return join(buildDirectory, 'test_extension.dll');
33 default: 32 default:
34 throw new StateError( 33 throw new StateError(
35 'Unknown operating system ${Platform.operatingSystem}'); 34 'Unknown operating system ${Platform.operatingSystem}');
36 } 35 }
37 } 36 }
38 37
39 void main() { 38 void main() {
40 Path scriptDirectory = new Path(Platform.script).directoryPath; 39 String scriptDirectory = dirname(Platform.script);
41 Path buildDirectory = new Path(Platform.executable).directoryPath; 40 String buildDirectory = dirname(Platform.executable);
42 Directory tempDirectory = new Directory('').createTempSync(); 41 Directory tempDirectory = new Directory('').createTempSync();
43 Path testDirectory = new Path(tempDirectory.path); 42 String testDirectory = tempDirectory.path;
44 43
45 // Copy test_extension shared library, test_extension.dart and 44 // Copy test_extension shared library, test_extension.dart and
46 // test_extension_fail_tester.dart to the temporary test directory. 45 // test_extension_fail_tester.dart to the temporary test directory.
47 copyFileToDirectory(getExtensionPath(buildDirectory), 46 copyFileToDirectory(getExtensionPath(buildDirectory),
48 testDirectory).then((_) { 47 testDirectory).then((_) {
49 Path extensionDartFile = scriptDirectory.append('test_extension.dart'); 48 var extensionDartFile = join(scriptDirectory, 'test_extension.dart');
50 return copyFileToDirectory(extensionDartFile, testDirectory); 49 return copyFileToDirectory(extensionDartFile, testDirectory);
51 }).then((_) { 50 }).then((_) {
52 Path testExtensionTesterFile = 51 var testExtensionTesterFile =
53 scriptDirectory.append('test_extension_fail_tester.dart'); 52 join(scriptDirectory, 'test_extension_fail_tester.dart');
54 return copyFileToDirectory(testExtensionTesterFile, testDirectory); 53 return copyFileToDirectory(testExtensionTesterFile, testDirectory);
55 }).then((_) { 54 }).then((_) {
56 Path script = testDirectory.append('test_extension_fail_tester.dart'); 55 var script = join(testDirectory, 'test_extension_fail_tester.dart');
57 return Process.run(Platform.executable, [script.toNativePath()]); 56 return Process.run(Platform.executable, [script]);
58 }).then((ProcessResult result) { 57 }).then((ProcessResult result) {
59 print("ERR: ${result.stderr}\n\n"); 58 print("ERR: ${result.stderr}\n\n");
60 print("OUT: ${result.stdout}\n\n"); 59 print("OUT: ${result.stdout}\n\n");
61 if (result.exitCode != 255) { 60 if (result.exitCode != 255) {
62 throw new StateError("bad exit code"); 61 throw new StateError("bad exit code");
63 } 62 }
64 if (!result.stderr.contains("Unhandled exception:")) { 63 if (!result.stderr.contains("Unhandled exception:")) {
65 throw new StateError("stderr doesn't contain unhandled exception."); 64 throw new StateError("stderr doesn't contain unhandled exception.");
66 } 65 }
67 if (!result.stderr.contains("ball")) { 66 if (!result.stderr.contains("ball")) {
68 throw new StateError("stderr doesn't contain 'ball'."); 67 throw new StateError("stderr doesn't contain 'ball'.");
69 } 68 }
70 }).whenComplete(() => tempDirectory.deleteSync(recursive: true)); 69 }).whenComplete(() => tempDirectory.deleteSync(recursive: true));
71 } 70 }
OLDNEW
« no previous file with comments | « tests/standalone/io/stdin_sync_test.dart ('k') | tests/standalone/io/test_extension_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698