Index: tests/standalone/io/test_extension_fail_test.dart |
diff --git a/tests/standalone/io/test_extension_fail_test.dart b/tests/standalone/io/test_extension_fail_test.dart |
index 3a9d0cfb40176ce498fc62d88255e60d1eb0ce66..c9893678c11a44fbdcee82dd4a37d12926c3cbf0 100644 |
--- a/tests/standalone/io/test_extension_fail_test.dart |
+++ b/tests/standalone/io/test_extension_fail_test.dart |
@@ -35,37 +35,55 @@ String getExtensionPath(String buildDirectory) { |
} |
} |
-void main() { |
+bool checkExitCode(int code) { |
+ return ((code == 255) || (code == 253)); |
+} |
+ |
+bool checkStdError(String err) { |
+ return err.contains("Unhandled exception:") || |
+ err.contains( |
+ "Native extension path must be absolute, or simply the file name"); |
+} |
+ |
+// name is either "extension" or "relative_extension" |
+Future test(String name, bool checkForBall) { |
String scriptDirectory = dirname(Platform.script.toFilePath()); |
String buildDirectory = dirname(Platform.executable); |
Directory tempDirectory = |
- Directory.systemTemp.createTempSync('dart_test_extension_fail'); |
+ Directory.systemTemp.createTempSync('dart_test_${name}_fail'); |
String testDirectory = 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).then((_) { |
- var extensionDartFile = join(scriptDirectory, 'test_extension.dart'); |
+ var extensionDartFile = join(scriptDirectory, 'test_${name}.dart'); |
return copyFileToDirectory(extensionDartFile, testDirectory); |
}).then((_) { |
var testExtensionTesterFile = |
- join(scriptDirectory, 'test_extension_fail_tester.dart'); |
+ join(scriptDirectory, 'test_${name}_fail_tester.dart'); |
return copyFileToDirectory(testExtensionTesterFile, testDirectory); |
}).then((_) { |
- var script = join(testDirectory, 'test_extension_fail_tester.dart'); |
- return Process.run(Platform.executable, [script]); |
+ var script = join(testDirectory, 'test_${name}_fail_tester.dart'); |
+ return Process.run(Platform.executable, ['--trace-loading', script]); |
}).then((ProcessResult result) { |
print("ERR: ${result.stderr}\n\n"); |
print("OUT: ${result.stdout}\n\n"); |
- if (result.exitCode != 255) { |
- throw new StateError("bad exit code"); |
+ if (!checkExitCode(result.exitCode)) { |
+ throw new StateError("bad exit code: ${result.exitCode}"); |
} |
- if (!result.stderr.contains("Unhandled exception:")) { |
+ if (!checkStdError(result.stderr)) { |
throw new StateError("stderr doesn't contain unhandled exception."); |
} |
- if (!result.stderr.contains("ball")) { |
- throw new StateError("stderr doesn't contain 'ball'."); |
+ if (checkForBall) { |
+ if (!result.stderr.contains("ball")) { |
+ throw new StateError("stderr doesn't contain 'ball'."); |
+ } |
} |
}).whenComplete(() => tempDirectory.deleteSync(recursive: true)); |
} |
+ |
+main() async { |
+ await test("extension", true); |
+ await test("relative_extension", false); |
+} |