Index: samples/sample_extension/test/sample_extension_script_snapshot_test.dart |
diff --git a/samples/sample_extension/test/sample_extension_test.dart b/samples/sample_extension/test/sample_extension_script_snapshot_test.dart |
similarity index 50% |
copy from samples/sample_extension/test/sample_extension_test.dart |
copy to samples/sample_extension/test/sample_extension_script_snapshot_test.dart |
index 9c0a42d30468c79d2a4caafba5165a0ad5df1a88..08ba5bbe78af5e02d93969a1b4135b9594dcad22 100644 |
--- a/samples/sample_extension/test/sample_extension_test.dart |
+++ b/samples/sample_extension/test/sample_extension_script_snapshot_test.dart |
@@ -38,27 +38,32 @@ 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); |
+ String snapshot = join(testDirectory, "$test.snapshot"); |
+ ProcessResult result = await Process.run(Platform.executable, |
Cutch
2016/11/03 17:45:34
the only difference between this file and the prev
|
+ ['--snapshot=$snapshot', |
+ script]); |
if (result.exitCode != 0) { |
print('Failing test: ${join(sourceDirectory, test)}'); |
print('Failing process stdout: ${result.stdout}'); |
@@ -66,7 +71,18 @@ void main() { |
print('End failing process stderr'); |
Expect.fail('Test failed with exit code ${result.exitCode}'); |
} |
- }) |
- )) |
- .whenComplete(() => tempDirectory.deleteSync(recursive: true)); |
+ |
+ result = await Process.run(Platform.executable, |
+ [snapshot]); |
+ if (result.exitCode != 0) { |
+ print('Failing test: ${join(sourceDirectory, test)}'); |
+ 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}'); |
+ } |
+ } |
+ } finally { |
+ await tempDirectory.deleteSync(recursive: true); |
+ } |
} |