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

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

Issue 21001003: test.py: First step towards support of caching dart2js compilations across runtimes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /* 5 /*
6 * This test makes sure that the "skipping Dart2Js compilations if the output is 6 * This test makes sure that the "skipping Dart2Js compilations if the output is
7 * already up to date" feature does work as it should. 7 * already up to date" feature does work as it should.
8 * Therefore this test ensures that compilations are only skipped if the last 8 * Therefore this test ensures that compilations are only skipped if the last
9 * modified date of the output of a dart2js compilation is newer than 9 * modified date of the output of a dart2js compilation is newer than
10 * - the the dart application to compile (including it's dependencies) 10 * - the the dart application to compile (including it's dependencies)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return file.readAsStringSync(); 114 return file.readAsStringSync();
115 } 115 }
116 116
117 File _createFile(Path path) { 117 File _createFile(Path path) {
118 var file = new File(path.toNativePath()); 118 var file = new File(path.toNativePath());
119 file.createSync(); 119 file.createSync();
120 return file; 120 return file;
121 } 121 }
122 } 122 }
123 123
124 class TestCompletedHandler { 124 class CommandCompletedHandler {
125 FileUtils fileUtils; 125 FileUtils fileUtils;
126 DateTime _expectedTimestamp; 126 DateTime _expectedTimestamp;
127 bool _shouldHaveRun; 127 bool _shouldHaveRun;
128 128
129 TestCompletedHandler(FileUtils this.fileUtils, bool this._shouldHaveRun); 129 CommandCompletedHandler(FileUtils this.fileUtils, bool this._shouldHaveRun);
130 130
131 void processCompletedTest(runner.TestCase testCase) { 131 void processCompletedTest(CommandOutput output) {
132 var output = testCase.lastCommandOutput; 132 Expect.isTrue(output.exitCode == 0);
133
134 Expect.isFalse(output.unexpectedOutput);
135 Expect.isTrue(output.stderr.length == 0); 133 Expect.isTrue(output.stderr.length == 0);
136 if (_shouldHaveRun) { 134 if (_shouldHaveRun) {
137 Expect.isTrue(output.stdout.length == 0); 135 Expect.isTrue(output.stdout.length == 0);
138 Expect.isTrue(new File(fileUtils.scriptOutputPath.toNativePath()) 136 Expect.isTrue(new File(fileUtils.scriptOutputPath.toNativePath())
139 .existsSync()); 137 .existsSync());
140 } else { 138 } else {
141 Expect.isFalse(new File(fileUtils.scriptOutputPath.toNativePath()) 139 Expect.isFalse(new File(fileUtils.scriptOutputPath.toNativePath())
142 .existsSync()); 140 .existsSync());
143 } 141 }
144 } 142 }
145 } 143 }
146 144
147 runner.TestCase makeTestCase(String testName, FileUtils fileUtils) { 145 runner.Command makeCompilationCommand(String testName, FileUtils fileUtils) {
148 var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0]; 146 var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0];
149 var scriptDirPath = new Path(Platform.script).directoryPath; 147 var scriptDirPath = new Path(Platform.script).directoryPath;
150 var createFileScript = scriptDirPath. 148 var createFileScript = scriptDirPath.
151 append('skipping_dart2js_compilations_helper.dart').toNativePath(); 149 append('skipping_dart2js_compilations_helper.dart').toNativePath();
152 var executable = Platform.executable; 150 var executable = Platform.executable;
153 var arguments = [createFileScript, fileUtils.scriptOutputPath.toNativePath()]; 151 var arguments = [createFileScript, fileUtils.scriptOutputPath.toNativePath()];
154 var bootstrapDeps = [ 152 var bootstrapDeps = [
155 Uri.parse("file://${fileUtils.testSnapshotFilePath}")]; 153 Uri.parse("file://${fileUtils.testSnapshotFilePath}")];
156 var commands = [new runner.CompilationCommand( 154 return runner.CommandBuilder.instance.getCompilationCommand(
157 'dart2js', 155 'dart2js',
158 fileUtils.testJsFilePath.toNativePath(), 156 fileUtils.testJsFilePath.toNativePath(),
159 false, 157 false,
160 bootstrapDeps, 158 bootstrapDeps,
161 executable, 159 executable,
162 arguments)]; 160 arguments,
163 return new runner.TestCase( 161 'ReleaseIA32');
164 testName,
165 commands,
166 config,
167 (_) {},
168 new Set<String>.from([status.PASS]));
169 } 162 }
170 163
171 void main() { 164 void main() {
172 var fs_noTestJs = new FileUtils(createJs: false, 165 var fs_noTestJs = new FileUtils(createJs: false,
173 createJsDeps: true, 166 createJsDeps: true,
174 createDart: true, 167 createDart: true,
175 createSnapshot: true); 168 createSnapshot: true);
176 var fs_noTestJsDeps = new FileUtils(createJs: true, 169 var fs_noTestJsDeps = new FileUtils(createJs: true,
177 createJsDeps: false, 170 createJsDeps: false,
178 createDart: true, 171 createDart: true,
(...skipping 27 matching lines...) Expand all
206 fs_notUpToDate_dart.cleanup(); 199 fs_notUpToDate_dart.cleanup();
207 fs_upToDate.cleanup(); 200 fs_upToDate.cleanup();
208 } 201 }
209 202
210 void touchFilesAndRunTests() { 203 void touchFilesAndRunTests() {
211 fs_notUpToDate_snapshot.touchFile(fs_notUpToDate_snapshot.testSnapshot); 204 fs_notUpToDate_snapshot.touchFile(fs_notUpToDate_snapshot.testSnapshot);
212 fs_notUpToDate_dart.touchFile(fs_notUpToDate_dart.testDart); 205 fs_notUpToDate_dart.touchFile(fs_notUpToDate_dart.testDart);
213 fs_upToDate.touchFile(fs_upToDate.testJs); 206 fs_upToDate.touchFile(fs_upToDate.testJs);
214 207
215 Future runTest(String name, FileUtils fileUtils, bool shouldRun) { 208 Future runTest(String name, FileUtils fileUtils, bool shouldRun) {
216 var completedHandler = new TestCompletedHandler(fileUtils, shouldRun); 209 var completedHandler = new CommandCompletedHandler(fileUtils, shouldRun);
217 var testCase = makeTestCase(name, fileUtils); 210 var command = makeCompilationCommand(name, fileUtils);
218 var process = new runner.RunningProcess(testCase, testCase.commands[0]); 211 var process = new runner.RunningProcess(command, 60);
219 return process.start().then((_) { 212 return process.run().then((CommandOutput output) {
220 completedHandler.processCompletedTest(testCase); 213 completedHandler.processCompletedTest(output);
221 }); 214 });
222 } 215 }
223 // We run the tests in sequence, so that if one of them failes we clean up 216 // We run the tests in sequence, so that if one of them failes we clean up
224 // everything and throw. 217 // everything and throw.
225 runTest("fs_noTestJs", fs_noTestJs, true).then((_) { 218 runTest("fs_noTestJs", fs_noTestJs, true).then((_) {
226 return runTest("fs_noTestJsDeps", fs_noTestJsDeps, true); 219 return runTest("fs_noTestJsDeps", fs_noTestJsDeps, true);
227 }).then((_) { 220 }).then((_) {
228 return runTest("fs_noTestDart", fs_noTestDart, true); 221 return runTest("fs_noTestDart", fs_noTestDart, true);
229 }).then((_) { 222 }).then((_) {
230 return runTest("fs_noTestSnapshot", fs_noTestSnapshot, true); 223 return runTest("fs_noTestSnapshot", fs_noTestSnapshot, true);
(...skipping 10 matching lines...) Expand all
241 cleanup(); 234 cleanup();
242 throw error; 235 throw error;
243 }).then((_) { 236 }).then((_) {
244 cleanup(); 237 cleanup();
245 }); 238 });
246 } 239 }
247 // We need to wait some time to make sure that the files we 'touch' get a 240 // We need to wait some time to make sure that the files we 'touch' get a
248 // bigger timestamp than the old ones 241 // bigger timestamp than the old ones
249 new Timer(new Duration(seconds: 1), touchFilesAndRunTests); 242 new Timer(new Duration(seconds: 1), touchFilesAndRunTests);
250 } 243 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/test_runner_test.dart » ('j') | tests/standalone/io/test_runner_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698