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

Unified Diff: tests/standalone/io/skipping_dart2js_compilations_test.dart

Issue 12257026: Fixed tests to reliably clean up temporary files/directories (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/skipping_dart2js_compilations_test.dart
diff --git a/tests/standalone/io/skipping_dart2js_compilations_test.dart b/tests/standalone/io/skipping_dart2js_compilations_test.dart
index d6b7eb46774d683e0ecb233125ba7563bac482ef..c6ce377a277cda10e5f8b8eb865cbbfd894e0d71 100644
--- a/tests/standalone/io/skipping_dart2js_compilations_test.dart
+++ b/tests/standalone/io/skipping_dart2js_compilations_test.dart
@@ -141,13 +141,10 @@ class TestCompletedHandler {
Expect.isFalse(new File(fileUtils.scriptOutputPath.toNativePath())
.existsSync());
}
- fileUtils.cleanup();
}
}
-runner.TestCase makeTestCase(String testName,
- TestCompletedHandler completedHandler) {
- var fileUtils = completedHandler.fileUtils;
+runner.TestCase makeTestCase(String testName, FileUtils fileUtils) {
var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0];
var scriptDirPath = new Path(new Options().script).directoryPath;
var createFileScript = scriptDirPath.
@@ -166,7 +163,7 @@ runner.TestCase makeTestCase(String testName,
testName,
commands,
config,
- completedHandler.processCompletedTest,
+ (_) {},
new Set<String>.from([status.PASS]));
}
@@ -199,26 +196,52 @@ void main() {
createJsDeps: true,
createDart: true,
createSnapshot: true);
+ void cleanup() {
+ fs_noTestJs.cleanup();
+ fs_noTestJsDeps.cleanup();
+ fs_noTestDart.cleanup();
+ fs_noTestSnapshot.cleanup();
+ fs_notUpToDate_snapshot.cleanup();
+ fs_notUpToDate_dart.cleanup();
+ fs_upToDate.cleanup();
+ }
void touchFilesAndRunTests() {
fs_notUpToDate_snapshot.touchFile(fs_notUpToDate_snapshot.testSnapshot);
fs_notUpToDate_dart.touchFile(fs_notUpToDate_dart.testDart);
fs_upToDate.touchFile(fs_upToDate.testJs);
- void runTest(String name, FileUtils fileUtils, bool shouldRun) {
- var testCase = makeTestCase(
- name, new TestCompletedHandler(fileUtils, shouldRun));
- new runner.RunningProcess(testCase, testCase.commands[0]).start();
+ Future runTest(String name, FileUtils fileUtils, bool shouldRun) {
+ var completedHandler = new TestCompletedHandler(fileUtils, shouldRun);
+ var testCase = makeTestCase(name, fileUtils);
+ var process = new runner.RunningProcess(testCase, testCase.commands[0]);
+ return process.start().then((_) {
+ completedHandler.processCompletedTest(testCase);
+ });
}
- runTest("fs_noTestJs", fs_noTestJs, true);
- runTest("fs_noTestJsDeps", fs_noTestJsDeps, true);
- runTest("fs_noTestDart", fs_noTestDart, true);
- runTest("fs_noTestSnapshot", fs_noTestSnapshot, true);
- runTest("fs_notUpToDate_snapshot", fs_notUpToDate_snapshot, true);
- runTest("fs_notUpToDate_dart", fs_notUpToDate_dart, true);
- // This is the only test where all dependencies are present and the test.js
- // file is newer than all the others. So we pass 'false' for shouldRun.
- runTest("fs_upToDate", fs_upToDate, false);
+ // We run the tests in sequence, so that if one of them failes we clean up
+ // everything and throw.
+ runTest("fs_noTestJs", fs_noTestJs, true).then((_) {
+ return runTest("fs_noTestJsDeps", fs_noTestJsDeps, true);
+ }).then((_) {
+ return runTest("fs_noTestDart", fs_noTestDart, true);
+ }).then((_) {
+ return runTest("fs_noTestSnapshot", fs_noTestSnapshot, true);
+ }).then((_) {
+ return runTest("fs_notUpToDate_snapshot", fs_notUpToDate_snapshot, true);
+ }).then((_) {
+ return runTest("fs_notUpToDate_dart", fs_notUpToDate_dart, true);
+ }).then((_) {
+ // This is the only test where all dependencies are present and the
+ // test.js file is newer than all the others. So we pass 'false' for
+ // shouldRun.
+ return runTest("fs_upToDate", fs_upToDate, false);
+ }).catchError((error) {
+ cleanup();
+ throw error;
+ }).then((_) {
+ cleanup();
+ });
}
// We need to wait some time to make sure that the files we 'touch' get a
// bigger timestamp than the old ones
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698