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

Side by Side Diff: tests/standalone/io/test_extension_fail_test.dart

Issue 2285223003: Fix native extension lookup (Closed)
Patch Set: Add back test for '/' Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "package:path/path.dart"; 7 import "package:path/path.dart";
8 import "dart:async"; 8 import "dart:async";
9 import "dart:io"; 9 import "dart:io";
10 10
(...skipping 17 matching lines...) Expand all
28 case 'macos': 28 case 'macos':
29 return join(buildDirectory, 'libtest_extension.dylib'); 29 return join(buildDirectory, 'libtest_extension.dylib');
30 case 'windows': 30 case 'windows':
31 return join(buildDirectory, 'test_extension.dll'); 31 return join(buildDirectory, 'test_extension.dll');
32 default: 32 default:
33 throw new StateError( 33 throw new StateError(
34 'Unknown operating system ${Platform.operatingSystem}'); 34 'Unknown operating system ${Platform.operatingSystem}');
35 } 35 }
36 } 36 }
37 37
38 void main() { 38 bool checkExitCode(int code) {
39 return ((code == 255) || (code == 253));
40 }
41
42 bool checkStdError(String err) {
43 return err.contains("Unhandled exception:") ||
44 err.contains("Relative paths for dart extensions are not supported");
45 }
46
47 // name is either "extension" or "relative_extension"
48 Future test(String name, bool checkForBall) {
39 String scriptDirectory = dirname(Platform.script.toFilePath()); 49 String scriptDirectory = dirname(Platform.script.toFilePath());
40 String buildDirectory = dirname(Platform.executable); 50 String buildDirectory = dirname(Platform.executable);
41 Directory tempDirectory = 51 Directory tempDirectory =
42 Directory.systemTemp.createTempSync('dart_test_extension_fail'); 52 Directory.systemTemp.createTempSync('dart_test_${name}_fail');
43 String testDirectory = tempDirectory.path; 53 String testDirectory = tempDirectory.path;
44 54
45 // Copy test_extension shared library, test_extension.dart and 55 // Copy test_extension shared library, test_extension.dart and
46 // test_extension_fail_tester.dart to the temporary test directory. 56 // test_extension_fail_tester.dart to the temporary test directory.
47 copyFileToDirectory(getExtensionPath(buildDirectory), 57 copyFileToDirectory(getExtensionPath(buildDirectory),
48 testDirectory).then((_) { 58 testDirectory).then((_) {
49 var extensionDartFile = join(scriptDirectory, 'test_extension.dart'); 59 var extensionDartFile = join(scriptDirectory, 'test_${name}.dart');
50 return copyFileToDirectory(extensionDartFile, testDirectory); 60 return copyFileToDirectory(extensionDartFile, testDirectory);
51 }).then((_) { 61 }).then((_) {
52 var testExtensionTesterFile = 62 var testExtensionTesterFile =
53 join(scriptDirectory, 'test_extension_fail_tester.dart'); 63 join(scriptDirectory, 'test_${name}_fail_tester.dart');
54 return copyFileToDirectory(testExtensionTesterFile, testDirectory); 64 return copyFileToDirectory(testExtensionTesterFile, testDirectory);
55 }).then((_) { 65 }).then((_) {
56 var script = join(testDirectory, 'test_extension_fail_tester.dart'); 66 var script = join(testDirectory, 'test_${name}_fail_tester.dart');
57 return Process.run(Platform.executable, [script]); 67 return Process.run(Platform.executable, ['--trace-loading', script]);
58 }).then((ProcessResult result) { 68 }).then((ProcessResult result) {
59 print("ERR: ${result.stderr}\n\n"); 69 print("ERR: ${result.stderr}\n\n");
60 print("OUT: ${result.stdout}\n\n"); 70 print("OUT: ${result.stdout}\n\n");
61 if (result.exitCode != 255) { 71 if (!checkExitCode(result.exitCode)) {
62 throw new StateError("bad exit code"); 72 throw new StateError("bad exit code: ${result.exitCode}");
63 } 73 }
64 if (!result.stderr.contains("Unhandled exception:")) { 74 if (!checkStdError(result.stderr)) {
65 throw new StateError("stderr doesn't contain unhandled exception."); 75 throw new StateError("stderr doesn't contain unhandled exception.");
66 } 76 }
67 if (!result.stderr.contains("ball")) { 77 if (checkForBall) {
68 throw new StateError("stderr doesn't contain 'ball'."); 78 if (!result.stderr.contains("ball")) {
79 throw new StateError("stderr doesn't contain 'ball'.");
80 }
69 } 81 }
70 }).whenComplete(() => tempDirectory.deleteSync(recursive: true)); 82 }).whenComplete(() => tempDirectory.deleteSync(recursive: true));
71 } 83 }
84
85 main() async {
86 await test("extension", true);
87 await test("relative_extension", false);
88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698