Chromium Code Reviews| 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 cd3ae4d2631c0d7b6a1ddd5566b89d1732ed544e..765b3c301322ecd57c1acb03f950a741e0d1c1a3 100644 |
| --- a/tests/standalone/io/test_extension_test.dart |
| +++ b/tests/standalone/io/test_extension_test.dart |
| @@ -1,16 +1,77 @@ |
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| +// |
| +// Dart test program for testing native extensions. |
| -#library("test_extension_test"); |
| +#import("dart:io"); |
| +#import("dart:isolate"); |
| -#import('test_extension.dart'); |
| +// The following import statements, hidden in a string, fool the test script |
|
Søren Gjesse
2012/06/29 12:32:11
import -> source
|
| +// tools/testing/dart/multitest.dart |
| +// into copying the files into the generated_tests directory. |
| +final dummyString = ''' |
| +#source('test_extension_tester.dart'); |
| +#source('test_extension.dart'); |
| +'''; |
| -main() { |
| - Expect.equals('cat 13', new Cat(13).toString(), 'new Cat(13).toString()'); |
| +void main() { |
| + Options options = new Options(); |
| - Expect.equals(3, Cat.ifNull(null, 3), 'Cat.ifNull(null, 3)'); |
| - Expect.equals(4, Cat.ifNull(4, null), 'Cat.ifNull(4, null)'); |
| - Expect.equals(5, Cat.ifNull(5, 9), 'Cat.ifNull(5, 9)'); |
| - Expect.isNull(Cat.ifNull(null, null), 'Cat.ifNull(null, null)'); |
| + // Make this a multitest so that the test scripts run a copy of it in |
|
Søren Gjesse
2012/06/29 12:32:11
I am not sure that I like the way you get this fil
Bill Hesse
2012/06/29 12:46:32
You are write - if this is not a multitest, then w
|
| + // [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; |
| + |
| + // 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. |
| + switch (Platform.operatingSystem) { |
| + case 'linux': |
| + var source = buildDirectory.append('lib.target/libtest_extension.so'); |
| + sharedLibraryCopied = Process.run('cp', |
| + [source.toNativePath(), |
| + testDirectory.toNativePath()]); |
| + break; |
| + case 'macos': |
| + var source = buildDirectory.append('libtest_extension.dylib'); |
| + sharedLibraryCopied = Process.run('cp', |
| + [source.toNativePath(), |
| + testDirectory.toNativePath()]); |
| + break; |
| + case 'windows': |
| + var source = buildDirectory.append('test_extension.dll'); |
| + sharedLibraryCopied = Process.run('cmd.exe', |
| + ['/C', |
| + 'copy ${source.toNativePath()} ${testDirectory.toNativePath()}']); |
| + break; |
| + default: |
| + 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); |
| + }); |
| + }); |
| } |