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

Unified Diff: tests/standalone/io/test_extension_test.dart

Issue 10699006: Add test for native extensions that copies the extension to a test directory and runs it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix comment and long line in multitest.dart Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/test_extension_tester.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ });
+ });
}
« no previous file with comments | « no previous file | tests/standalone/io/test_extension_tester.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698