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

Unified Diff: samples/tests/samples/standalone/sample_extension_test.dart

Issue 18073003: dart:io | Add automated testing for samples/sample_extension to buildbot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add sample_extension to the targets of the runtime build. Created 7 years, 5 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 | « samples/sample_extension/test_sample_synchronous_extension.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/tests/samples/standalone/sample_extension_test.dart
diff --git a/samples/tests/samples/standalone/sample_extension_test.dart b/samples/tests/samples/standalone/sample_extension_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f95791fa25a01379588b3806c194ce231a89cd2d
--- /dev/null
+++ b/samples/tests/samples/standalone/sample_extension_test.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2013, 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 "package:expect/expect.dart";
+import 'dart:async';
+import 'dart:io';
+import 'dart:isolate';
+
+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 getNativeLibraryPath(Path buildDirectory) {
+ switch (Platform.operatingSystem) {
+ case 'linux':
+ return buildDirectory.append('lib.target/libsample_extension.so');
+ case 'macos':
+ return buildDirectory.append('libsample_extension.dylib');
+ case 'windows':
+ return buildDirectory.append('sample_extension.dll');
+ default:
+ Expect.fail('Unknown operating system ${Platform.operatingSystem}');
+ }
+}
+
+void main() {
+ Path scriptDirectory = new Path(Platform.script).directoryPath;
+ Path buildDirectory = new Path(Platform.executable).directoryPath;
+ Directory tempDirectory = new Directory('').createTempSync();
+ Path testDirectory = new Path(tempDirectory.path);
+ Path sourceDirectory = scriptDirectory.append('../../../sample_extension');
+
+ // Copy sample_extension shared library, sample_extension dart files and
+ // sample_extension tests to the temporary test directory.
+ copyFileToDirectory(getNativeLibraryPath(buildDirectory), testDirectory)
+ .then((_) => Future.forEach(['sample_synchronous_extension.dart',
+ 'sample_asynchronous_extension.dart',
+ 'test_sample_synchronous_extension.dart',
+ 'test_sample_asynchronous_extension.dart'],
+ (file) => copyFileToDirectory(sourceDirectory.append(file), testDirectory)
+ ))
+
+ .then((_) => Future.forEach(['test_sample_synchronous_extension.dart',
+ 'test_sample_asynchronous_extension.dart'],
+ (test) => Process.run(Platform.executable,
+ [testDirectory.append(test).toNativePath()])
+ .then((ProcessResult result) {
+ if (result.exitCode != 0) {
+ print('Failing test: ${sourceDirectory.append(test).toNativePath()}');
+ print('Failing process stdout: ${result.stdout}');
+ print('Failing process stderr: ${result.stderr}');
+ print('End failing process stderr');
+ Expect.fail('Test failed with exit code ${result.exitCode}');
+ }
+ })
+ ))
+ .whenComplete(() => tempDirectory.deleteSync(recursive: true));
+}
« no previous file with comments | « samples/sample_extension/test_sample_synchronous_extension.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698