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

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: rebased 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return file.readAsStringSync(); 115 return file.readAsStringSync();
116 } 116 }
117 117
118 File _createFile(Path path) { 118 File _createFile(Path path) {
119 var file = new File(path.toNativePath()); 119 var file = new File(path.toNativePath());
120 file.createSync(); 120 file.createSync();
121 return file; 121 return file;
122 } 122 }
123 } 123 }
124 124
125 class TestCompletedHandler { 125 class CommandCompletedHandler {
126 FileUtils fileUtils; 126 FileUtils fileUtils;
127 DateTime _expectedTimestamp; 127 DateTime _expectedTimestamp;
128 bool _shouldHaveRun; 128 bool _shouldHaveRun;
129 129
130 TestCompletedHandler(FileUtils this.fileUtils, bool this._shouldHaveRun); 130 CommandCompletedHandler(FileUtils this.fileUtils, bool this._shouldHaveRun);
131 131
132 void processCompletedTest(runner.TestCase testCase) { 132 void processCompletedTest(CommandOutput output) {
133 var output = testCase.lastCommandOutput; 133 Expect.isTrue(output.exitCode == 0);
134
135 Expect.isFalse(output.unexpectedOutput);
136 Expect.isTrue(output.stderr.length == 0); 134 Expect.isTrue(output.stderr.length == 0);
137 if (_shouldHaveRun) { 135 if (_shouldHaveRun) {
138 Expect.isTrue(output.stdout.length == 0); 136 Expect.isTrue(output.stdout.length == 0);
139 Expect.isTrue(new File(fileUtils.scriptOutputPath.toNativePath()) 137 Expect.isTrue(new File(fileUtils.scriptOutputPath.toNativePath())
140 .existsSync()); 138 .existsSync());
141 } else { 139 } else {
142 Expect.isFalse(new File(fileUtils.scriptOutputPath.toNativePath()) 140 Expect.isFalse(new File(fileUtils.scriptOutputPath.toNativePath())
143 .existsSync()); 141 .existsSync());
144 } 142 }
145 } 143 }
146 } 144 }
147 145
148 runner.TestCase makeTestCase(String testName, FileUtils fileUtils) { 146 runner.Command makeCompilationCommand(String testName, FileUtils fileUtils) {
149 var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0]; 147 var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0];
150 var createFileScript = join(dirname(Platform.script), 148 var createFileScript = join(dirname(Platform.script),
151 'skipping_dart2js_compilations_helper.dart'); 149 'skipping_dart2js_compilations_helper.dart');
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') | tools/testing/dart/test_runner.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698