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 // Dart test program for testing native extensions. | 5 // Dart test program for testing native extensions. |
6 | 6 |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 Future copyFileToDirectory(Path file, Path directory) { | 10 Future copyFileToDirectory(Path file, Path directory) { |
(...skipping 19 matching lines...) Expand all Loading... |
30 case 'windows': | 30 case 'windows': |
31 return buildDirectory.append('test_extension.dll'); | 31 return buildDirectory.append('test_extension.dll'); |
32 default: | 32 default: |
33 Expect.fail('Unknown operating system ${Platform.operatingSystem}'); | 33 Expect.fail('Unknown operating system ${Platform.operatingSystem}'); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 void main() { | 37 void main() { |
38 Options options = new Options(); | 38 Options options = new Options(); |
39 | 39 |
40 Path scriptDirectory = new Path.fromNative(options.script).directoryPath; | 40 Path scriptDirectory = new Path(options.script).directoryPath; |
41 Path buildDirectory = new Path.fromNative(options.executable).directoryPath; | 41 Path buildDirectory = new Path(options.executable).directoryPath; |
42 Directory tempDirectory = new Directory('').createTempSync(); | 42 Directory tempDirectory = new Directory('').createTempSync(); |
43 Path testDirectory = new Path.fromNative(tempDirectory.path); | 43 Path testDirectory = new Path(tempDirectory.path); |
44 | 44 |
45 // Copy test_extension shared library, test_extension.dart and | 45 // Copy test_extension shared library, test_extension.dart and |
46 // test_extension_fail_tester.dart to the temporary test directory. | 46 // test_extension_fail_tester.dart to the temporary test directory. |
47 copyFileToDirectory(getExtensionPath(buildDirectory), | 47 copyFileToDirectory(getExtensionPath(buildDirectory), |
48 testDirectory).then((_) { | 48 testDirectory).then((_) { |
49 Path extensionDartFile = scriptDirectory.append('test_extension.dart'); | 49 Path extensionDartFile = scriptDirectory.append('test_extension.dart'); |
50 return copyFileToDirectory(extensionDartFile, testDirectory); | 50 return copyFileToDirectory(extensionDartFile, testDirectory); |
51 }).then((_) { | 51 }).then((_) { |
52 Path testExtensionTesterFile = | 52 Path testExtensionTesterFile = |
53 scriptDirectory.append('test_extension_fail_tester.dart'); | 53 scriptDirectory.append('test_extension_fail_tester.dart'); |
54 return copyFileToDirectory(testExtensionTesterFile, testDirectory); | 54 return copyFileToDirectory(testExtensionTesterFile, testDirectory); |
55 }).then((_) { | 55 }).then((_) { |
56 Path script = testDirectory.append('test_extension_fail_tester.dart'); | 56 Path script = testDirectory.append('test_extension_fail_tester.dart'); |
57 return Process.run(options.executable, [script.toNativePath()]); | 57 return Process.run(options.executable, [script.toNativePath()]); |
58 }).then((ProcessResult result) { | 58 }).then((ProcessResult result) { |
59 print("ERR: ${result.stderr}\n\n"); | 59 print("ERR: ${result.stderr}\n\n"); |
60 print("OUT: ${result.stdout}\n\n"); | 60 print("OUT: ${result.stdout}\n\n"); |
61 Expect.equals(255, result.exitCode); | 61 Expect.equals(255, result.exitCode); |
62 Expect.isTrue(result.stderr.contains("Unhandled exception:\nball\n")); | 62 Expect.isTrue(result.stderr.contains("Unhandled exception:\nball\n")); |
63 }).whenComplete(() => tempDirectory.deleteSync(recursive: true)); | 63 }).whenComplete(() => tempDirectory.deleteSync(recursive: true)); |
64 } | 64 } |
OLD | NEW |