| Index: tests/standalone/io/test_extension_test.dart
|
| diff --git a/tests/standalone/io/test_extension_test.dart b/tests/standalone/io/test_extension_test.dart
|
| index 3f074f9e2de54b2d99077137239b5a792d8fdf97..552a6b334c8e6e600fc0a96f4cb6bb089ccbd631 100644
|
| --- a/tests/standalone/io/test_extension_test.dart
|
| +++ b/tests/standalone/io/test_extension_test.dart
|
| @@ -4,75 +4,60 @@
|
| //
|
| // Dart test program for testing native extensions.
|
|
|
| -#import("dart:io");
|
| -#import("dart:isolate");
|
| +#import('dart:io');
|
|
|
| -// The following source statements, hidden in a string, fool the test script
|
| -// tools/testing/dart/multitest.dart
|
| -// into copying the files into the generated_tests directory.
|
| -// TODO(3919): Rewrite this test, not as a multitest, to copy them manually.
|
| -const dummyString = '''
|
| -#source('test_extension_tester.dart');
|
| -#source('test_extension.dart');
|
| -''';
|
| -
|
| -void main() {
|
| - Options options = new Options();
|
| -
|
| - // Make this a multitest so that the test scripts run a copy of it in
|
| - // [build directory]/generated_tests. This way, we can copy the shared
|
| - // library for test_extension.dart to the test directory.
|
| - // The "none" case of the multitest, without the following
|
| - // line, is the one that runs the test of the extension.
|
| - foo foo foo foo foo; /// 01: compile-time error
|
| -
|
| - Path testDirectory = new Path.fromNative(options.script).directoryPath;
|
| - Path buildDirectory = new Path.fromNative(options.executable).directoryPath;
|
| +Future copyFileToDirectory(Path file, Path directory) {
|
| + String src = file.toNativePath();
|
| + String dst = directory.toNativePath();
|
| + switch (Platform.operatingSystem) {
|
| + case 'linux':
|
| + case 'macos':
|
| + return Process.run('cp', [src, dst]);
|
| + case 'windows':
|
| + return Process.run('cmd.exe', ['/C', 'copy $src $dst']);
|
| + default:
|
| + Expect.fail('Unknown operating system ${Platform.operatingSystem}');
|
| + }
|
| +}
|
|
|
| - // Copy test_extension shared library from the build directory to the
|
| - // test directory.
|
| - Future sharedLibraryCopied;
|
| - // Use the platforms' copy file commands, to preserve executable privilege.
|
| +Path getExtensionPath(Path buildDirectory) {
|
| switch (Platform.operatingSystem) {
|
| case 'linux':
|
| - var source = buildDirectory.append('lib.target/libtest_extension.so');
|
| - sharedLibraryCopied = Process.run('cp',
|
| - [source.toNativePath(),
|
| - testDirectory.toNativePath()]);
|
| - break;
|
| + return buildDirectory.append('lib.target/libtest_extension.so');
|
| case 'macos':
|
| - var source = buildDirectory.append('libtest_extension.dylib');
|
| - sharedLibraryCopied = Process.run('cp',
|
| - [source.toNativePath(),
|
| - testDirectory.toNativePath()]);
|
| - break;
|
| + return buildDirectory.append('libtest_extension.dylib');
|
| case 'windows':
|
| - var source = buildDirectory.append('test_extension.dll');
|
| - sharedLibraryCopied = Process.run('cmd.exe',
|
| - ['/C',
|
| - 'copy ${source.toNativePath()} ${testDirectory.toNativePath()}']);
|
| - break;
|
| + return buildDirectory.append('test_extension.dll');
|
| default:
|
| - Expect.fail("Unknown operating system ${Platform.operatingSystem}");
|
| + Expect.fail('Unknown operating system ${Platform.operatingSystem}');
|
| }
|
| +}
|
|
|
| - sharedLibraryCopied.handleException((e) {
|
| - print('Copying of shared library test_extension failed.');
|
| - throw e;
|
| - });
|
| - sharedLibraryCopied.then((ignore) {
|
| - print('Shared library copied to test directory.');
|
| - Path copiedTest = testDirectory.append("test_extension_tester.dart");
|
| - var result = Process.run(options.executable,
|
| - [copiedTest.toNativePath()]);
|
| - result.then((processResult) {
|
| - print('Output of test_extension_tester.dart:');
|
| - print(' stdout:');
|
| - print(processResult.stdout);
|
| - print(' stderr:');
|
| - print(processResult.stderr);
|
| - stdout.flush();
|
| - exit(processResult.exitCode);
|
| - });
|
| +void main() {
|
| + Options options = new Options();
|
| +
|
| + Path scriptDirectory = new Path.fromNative(options.script).directoryPath;
|
| + Path buildDirectory = new Path.fromNative(options.executable).directoryPath;
|
| + Directory tempDirectory = new Directory('').createTempSync();
|
| + Path testDirectory = new Path.fromNative(tempDirectory.path);
|
| +
|
| + // Copy test_extension shared library, test_extension.dart and
|
| + // test_extension_tester.dart to the temporary test directory.
|
| + copyFileToDirectory(getExtensionPath(buildDirectory),
|
| + testDirectory).chain((_) {
|
| + Path extensionDartFile = scriptDirectory.append('test_extension.dart');
|
| + return copyFileToDirectory(extensionDartFile, testDirectory);
|
| + }).chain((_) {
|
| + Path testExtensionTesterFile =
|
| + scriptDirectory.append('test_extension_tester.dart');
|
| + return copyFileToDirectory(testExtensionTesterFile, testDirectory);
|
| + }).chain((_) {
|
| + Path script = testDirectory.append('test_extension_tester.dart');
|
| + return Process.run(options.executable, [script.toNativePath()]);
|
| + })..then((processResult result) {
|
| + Expect.equals(0, result.exitCode);
|
| + tempDirectory.deleteSync(recursive: true);
|
| + })..handleException((_) {
|
| + tempDirectory.deleteSync(recursive: true);
|
| });
|
| }
|
|
|