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

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

Issue 11447010: - Add an extension test which throws from native code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | « tests/standalone/io/test_extension.dart ('k') | tests/standalone/io/test_extension_fail_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_fail_test.dart
===================================================================
--- tests/standalone/io/test_extension_fail_test.dart (revision 0)
+++ tests/standalone/io/test_extension_fail_test.dart (revision 0)
@@ -0,0 +1,66 @@
+// 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.
+
+#import('dart:io');
+
+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}');
+ }
+}
+
+Path getExtensionPath(Path buildDirectory) {
+ switch (Platform.operatingSystem) {
+ case 'linux':
+ return buildDirectory.append('lib.target/libtest_extension.so');
+ case 'macos':
+ return buildDirectory.append('libtest_extension.dylib');
+ case 'windows':
+ return buildDirectory.append('test_extension.dll');
+ default:
+ Expect.fail('Unknown operating system ${Platform.operatingSystem}');
+ }
+}
+
+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_fail_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_fail_tester.dart');
+ return copyFileToDirectory(testExtensionTesterFile, testDirectory);
+ }).chain((_) {
+ Path script = testDirectory.append('test_extension_fail_tester.dart');
+ return Process.run(options.executable, [script.toNativePath()]);
+ })..then((ProcessResult result) {
+ print("ERR: ${result.stderr}\n\n");
+ print("OUT: ${result.stdout}\n\n");
+ Expect.equals(255, result.exitCode);
+ Expect.isTrue(result.stderr.contains("Unhandled exception:\nball\n"));
+ tempDirectory.deleteSync(recursive: true);
+ })..handleException((_) {
+ tempDirectory.deleteSync(recursive: true);
+ });
+}
« no previous file with comments | « tests/standalone/io/test_extension.dart ('k') | tests/standalone/io/test_extension_fail_tester.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698