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

Side by Side Diff: samples/sample_extension/test/sample_extension_test.dart

Issue 131103025: Fixes ABI bug in MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Dart test program for testing native extensions. 5 // Dart test program for testing native extensions.
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 10
11 import "package:expect/expect.dart"; 11 import "package:expect/expect.dart";
12 import "package:path/path.dart"; 12 import "package:path/path.dart";
13 13
14 Future copyFileToDirectory(String file, String directory) { 14 Future copyFileToDirectory(String file, String directory) {
15 String src = file; 15 String src = file;
16 String dst = directory; 16 String dst = directory;
17 switch (Platform.operatingSystem) { 17 switch (Platform.operatingSystem) {
18 case 'linux': 18 case 'linux':
19 case 'macos': 19 case 'macos':
20 return Process.run('cp', [src, dst]); 20 return Process.run('cp', [src, dst]);
21 case 'windows': 21 case 'windows':
22 return Process.run('cmd.exe', ['/C', 'copy $src $dst']); 22 return Process.run('cmd.exe', ['/C', 'copy $src $dst']);
23 default: 23 default:
24 Expect.fail('Unknown operating system ${Platform.operatingSystem}'); 24 Expect.fail('Unknown operating system ${Platform.operatingSystem}');
25 } 25 }
26 } 26 }
27 27
28 String getNativeLibraryPath(String buildDirectory) { 28 String getNativeLibraryPath(String buildDirectory, String libname) {
29 switch (Platform.operatingSystem) { 29 switch (Platform.operatingSystem) {
30 case 'linux': 30 case 'linux':
31 return join(buildDirectory, 'lib.target', 'libsample_extension.so'); 31 return join(buildDirectory, 'lib.target', 'lib${libname}.so');
32 case 'macos': 32 case 'macos':
33 return join(buildDirectory, 'libsample_extension.dylib'); 33 return join(buildDirectory, 'lib${libname}.dylib');
34 case 'windows': 34 case 'windows':
35 return join(buildDirectory, 'sample_extension.dll'); 35 return join(buildDirectory, '${libname}.dll');
36 default: 36 default:
37 Expect.fail('Unknown operating system ${Platform.operatingSystem}'); 37 Expect.fail('Unknown operating system ${Platform.operatingSystem}');
38 } 38 }
39 } 39 }
40 40
41 void main() { 41 void main() {
42 String buildDirectory = dirname(Platform.executable); 42 String buildDirectory = dirname(Platform.executable);
43 Directory tempDirectory = 43 Directory tempDirectory =
44 Directory.systemTemp.createTempSync('sample_extension_'); 44 Directory.systemTemp.createTempSync('sample_extension_');
45 String testDirectory = tempDirectory.path; 45 String testDirectory = tempDirectory.path;
46 String sourceDirectory = Platform.script.resolve('..').toFilePath(); 46 String sourceDirectory = Platform.script.resolve('..').toFilePath();
47 47
48 // Copy sample_extension shared library, sample_extension dart files and 48 // Copy sample_extension shared library, sample_extension dart files and
49 // sample_extension tests to the temporary test directory. 49 // sample_extension tests to the temporary test directory.
50 copyFileToDirectory(getNativeLibraryPath(buildDirectory), testDirectory) 50 copyFileToDirectory(
51 .then((_) => Future.forEach(['sample_synchronous_extension.dart', 51 getNativeLibraryPath(buildDirectory, "sample_extension"),
52 'sample_asynchronous_extension.dart', 52 testDirectory)
53 'test_sample_synchronous_extension.dart', 53 .then((_) => copyFileToDirectory(
54 'test_sample_asynchronous_extension.dart'], 54 getNativeLibraryPath(buildDirectory, "sample_extension_no_autoscope"),
55 testDirectory))
56 .then((_) => Future.forEach([
57 'sample_synchronous_extension.dart',
58 'sample_asynchronous_extension.dart',
59 'sample_synchronous_extension_no_autoscope.dart',
60 'sample_asynchronous_extension_no_autoscope.dart',
61 'test_sample_synchronous_extension.dart',
62 'test_sample_asynchronous_extension.dart',
63 'test_sample_synchronous_extension_no_autoscope.dart',
64 'test_sample_asynchronous_extension_no_autoscope.dart'],
55 (file) => copyFileToDirectory(join(sourceDirectory, file), testDirectory) 65 (file) => copyFileToDirectory(join(sourceDirectory, file), testDirectory)
56 )) 66 ))
57 67
58 .then((_) => Future.forEach(['test_sample_synchronous_extension.dart', 68 .then((_) => Future.forEach(
59 'test_sample_asynchronous_extension.dart'], 69 ['test_sample_synchronous_extension.dart',
70 'test_sample_asynchronous_extension.dart',
71 'test_sample_synchronous_extension_no_autoscope.dart',
72 'test_sample_asynchronous_extension_no_autoscope.dart'],
60 (test) => Process.run(Platform.executable, [join(testDirectory, test)]) 73 (test) => Process.run(Platform.executable, [join(testDirectory, test)])
61 .then((ProcessResult result) { 74 .then((ProcessResult result) {
62 if (result.exitCode != 0) { 75 if (result.exitCode != 0) {
63 print('Failing test: ${join(sourceDirectory, test)}'); 76 print('Failing test: ${join(sourceDirectory, test)}');
64 print('Failing process stdout: ${result.stdout}'); 77 print('Failing process stdout: ${result.stdout}');
65 print('Failing process stderr: ${result.stderr}'); 78 print('Failing process stderr: ${result.stderr}');
66 print('End failing process stderr'); 79 print('End failing process stderr');
67 Expect.fail('Test failed with exit code ${result.exitCode}'); 80 Expect.fail('Test failed with exit code ${result.exitCode}');
68 } 81 }
69 }) 82 })
70 )) 83 ))
71 .whenComplete(() => tempDirectory.deleteSync(recursive: true)); 84 .whenComplete(() => tempDirectory.deleteSync(recursive: true));
72 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698