Index: samples/sample_extension/test/sample_extension_test.dart |
diff --git a/samples/sample_extension/test/sample_extension_test.dart b/samples/sample_extension/test/sample_extension_test.dart |
index 9c0a42d30468c79d2a4caafba5165a0ad5df1a88..dcd925d18e3a72ac17ed4a19cb8678d656b91f2a 100644 |
--- a/samples/sample_extension/test/sample_extension_test.dart |
+++ b/samples/sample_extension/test/sample_extension_test.dart |
@@ -38,27 +38,29 @@ String getNativeLibraryPath(String buildDirectory) { |
} |
} |
-void main() { |
+void main() async { |
String buildDirectory = dirname(Platform.executable); |
Directory tempDirectory = |
Directory.systemTemp.createTempSync('sample_extension_'); |
- String testDirectory = tempDirectory.path; |
- String sourceDirectory = Platform.script.resolve('..').toFilePath(); |
+ try { |
+ String testDirectory = tempDirectory.path; |
+ String sourceDirectory = Platform.script.resolve('..').toFilePath(); |
- // 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(join(sourceDirectory, file), testDirectory) |
- )) |
+ // Copy sample_extension shared library, sample_extension dart files and |
+ // sample_extension tests to the temporary test directory. |
+ await copyFileToDirectory(getNativeLibraryPath(buildDirectory), |
+ testDirectory); |
+ for (var file in ['sample_synchronous_extension.dart', |
+ 'sample_asynchronous_extension.dart', |
+ 'test_sample_synchronous_extension.dart', |
+ 'test_sample_asynchronous_extension.dart']) { |
+ await copyFileToDirectory(join(sourceDirectory, file), testDirectory); |
+ } |
- .then((_) => Future.forEach(['test_sample_synchronous_extension.dart', |
- 'test_sample_asynchronous_extension.dart'], |
- (test) => Process.run(Platform.executable, [join(testDirectory, test)]) |
- .then((ProcessResult result) { |
+ for (var test in ['test_sample_synchronous_extension.dart', |
+ 'test_sample_asynchronous_extension.dart']) { |
+ String script = join(testDirectory, test); |
+ ProcessResult result = await Process.run(Platform.executable, [script]); |
if (result.exitCode != 0) { |
print('Failing test: ${join(sourceDirectory, test)}'); |
print('Failing process stdout: ${result.stdout}'); |
@@ -66,7 +68,8 @@ void main() { |
print('End failing process stderr'); |
Expect.fail('Test failed with exit code ${result.exitCode}'); |
} |
- }) |
- )) |
- .whenComplete(() => tempDirectory.deleteSync(recursive: true)); |
+ } |
+ } finally { |
+ await tempDirectory.deleteSync(recursive: true); |
+ } |
} |