| 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 "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 case 'macos': | 30 case 'macos': |
| 31 return buildDirectory.append('libtest_extension.dylib'); | 31 return buildDirectory.append('libtest_extension.dylib'); |
| 32 case 'windows': | 32 case 'windows': |
| 33 return buildDirectory.append('test_extension.dll'); | 33 return buildDirectory.append('test_extension.dll'); |
| 34 default: | 34 default: |
| 35 Expect.fail('Unknown operating system ${Platform.operatingSystem}'); | 35 Expect.fail('Unknown operating system ${Platform.operatingSystem}'); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 void main() { | 39 void main() { |
| 40 Options options = new Options(); | 40 Path scriptDirectory = new Path(Platform.script).directoryPath; |
| 41 | 41 Path buildDirectory = new Path(Platform.executable).directoryPath; |
| 42 Path scriptDirectory = new Path(options.script).directoryPath; | |
| 43 Path buildDirectory = new Path(options.executable).directoryPath; | |
| 44 Directory tempDirectory = new Directory('').createTempSync(); | 42 Directory tempDirectory = new Directory('').createTempSync(); |
| 45 Path testDirectory = new Path(tempDirectory.path); | 43 Path testDirectory = new Path(tempDirectory.path); |
| 46 | 44 |
| 47 // Copy test_extension shared library, test_extension.dart and | 45 // Copy test_extension shared library, test_extension.dart and |
| 48 // test_extension_tester.dart to the temporary test directory. | 46 // test_extension_tester.dart to the temporary test directory. |
| 49 copyFileToDirectory(getExtensionPath(buildDirectory), | 47 copyFileToDirectory(getExtensionPath(buildDirectory), |
| 50 testDirectory).then((_) { | 48 testDirectory).then((_) { |
| 51 Path extensionDartFile = scriptDirectory.append('test_extension.dart'); | 49 Path extensionDartFile = scriptDirectory.append('test_extension.dart'); |
| 52 return copyFileToDirectory(extensionDartFile, testDirectory); | 50 return copyFileToDirectory(extensionDartFile, testDirectory); |
| 53 }).then((_) { | 51 }).then((_) { |
| 54 Path testExtensionTesterFile = | 52 Path testExtensionTesterFile = |
| 55 scriptDirectory.append('test_extension_tester.dart'); | 53 scriptDirectory.append('test_extension_tester.dart'); |
| 56 return copyFileToDirectory(testExtensionTesterFile, testDirectory); | 54 return copyFileToDirectory(testExtensionTesterFile, testDirectory); |
| 57 }).then((_) { | 55 }).then((_) { |
| 58 Path script = testDirectory.append('test_extension_tester.dart'); | 56 Path script = testDirectory.append('test_extension_tester.dart'); |
| 59 return Process.run(options.executable, [script.toNativePath()]); | 57 return Process.run(Platform.executable, [script.toNativePath()]); |
| 60 })..then((ProcessResult result) { | 58 })..then((ProcessResult result) { |
| 61 Expect.equals(0, result.exitCode); | 59 Expect.equals(0, result.exitCode); |
| 62 tempDirectory.deleteSync(recursive: true); | 60 tempDirectory.deleteSync(recursive: true); |
| 63 })..catchError((_) { | 61 })..catchError((_) { |
| 64 tempDirectory.deleteSync(recursive: true); | 62 tempDirectory.deleteSync(recursive: true); |
| 65 }); | 63 }); |
| 66 } | 64 } |
| OLD | NEW |