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

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

Issue 841193003: cleanup to tools/testing/dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: one last bit Created 5 years, 11 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)
11 * - the dart2js snapshot 11 * - the dart2js snapshot
12 * Furtheremore it ensure that a compilations is not skipped if any of the 12 * Furtheremore it ensure that a compilations is not skipped if any of the
13 * necessary files could not be found (dart2js snapshots, previous dart2js 13 * necessary files could not be found (dart2js snapshots, previous dart2js
14 * output (+deps file), dart application) 14 * output (+deps file), dart application)
15 */ 15 */
16 16
17 import 'dart:async';
18 import 'dart:io';
19
17 import 'package:expect/expect.dart'; 20 import 'package:expect/expect.dart';
18 import 'package:path/path.dart'; 21 import 'package:path/path.dart';
19 import 'dart:async'; 22
20 import 'dart:io'; 23 import '../../../tools/testing/dart/lib/path.dart';
21 import '../../../tools/testing/dart/path.dart'; 24 import '../../../tools/testing/dart/lib/test_utils.dart';
22 import '../../../tools/testing/dart/test_suite.dart' as suite; 25 import '../../../tools/testing/dart/lib/command.dart' as command;
23 import '../../../tools/testing/dart/test_runner.dart' as runner; 26 import '../../../tools/testing/dart/test_runner.dart' as runner;
24 import '../../../tools/testing/dart/test_options.dart' as options; 27 import '../../../tools/testing/dart/test_options.dart' as options;
25 import '../../../tools/testing/dart/status_file_parser.dart' as status;
26 import '../../../tools/testing/dart/utils.dart';
27 28
28 /** 29 /**
29 * This class is reponsible for setting up the files necessary for this test 30 * This class is reponsible for setting up the files necessary for this test
30 * as well as touching a file. 31 * as well as touching a file.
31 */ 32 */
32 class FileUtils { 33 class FileUtils {
33 Directory tempDir; 34 Directory tempDir;
34 File testJs; 35 File testJs;
35 File testJsDeps; 36 File testJsDeps;
36 File testDart; 37 File testDart;
(...skipping 12 matching lines...) Expand all
49 if (createSnapshot) { 50 if (createSnapshot) {
50 testSnapshot = _createFile(testSnapshotFilePath); 51 testSnapshot = _createFile(testSnapshotFilePath);
51 _writeToFile(testSnapshot, "dart2js snapshot"); 52 _writeToFile(testSnapshot, "dart2js snapshot");
52 } 53 }
53 if (createDart) { 54 if (createDart) {
54 testDart = _createFile(testDartFilePath); 55 testDart = _createFile(testDartFilePath);
55 _writeToFile(testDart, "dart code"); 56 _writeToFile(testDart, "dart code");
56 } 57 }
57 if (createJsDeps) { 58 if (createJsDeps) {
58 testJsDeps = _createFile(testJsDepsFilePath); 59 testJsDeps = _createFile(testJsDepsFilePath);
59 var path = suite.TestUtils.absolutePath(new Path(tempDir.path)) 60 var path = TestUtils.absolutePath(new Path(tempDir.path))
60 .append("test.dart"); 61 .append("test.dart");
61 _writeToFile(testJsDeps, "file://$path"); 62 _writeToFile(testJsDeps, "file://$path");
62 } 63 }
63 } 64 }
64 65
65 void cleanup() { 66 void cleanup() {
66 if (testJs != null) testJs.deleteSync(); 67 if (testJs != null) testJs.deleteSync();
67 if (testJsDeps != null) testJsDeps.deleteSync(); 68 if (testJsDeps != null) testJsDeps.deleteSync();
68 if (testDart != null) testDart.deleteSync(); 69 if (testDart != null) testDart.deleteSync();
69 if (testSnapshot != null) testSnapshot.deleteSync(); 70 if (testSnapshot != null) testSnapshot.deleteSync();
70 71
71 // if the script did run, it created this file, so we need to delete it 72 // if the script did run, it created this file, so we need to delete it
72 File file = new File(scriptOutputPath.toNativePath()); 73 File file = new File(scriptOutputPath.toNativePath());
73 if (file.existsSync()) { 74 if (file.existsSync()) {
74 file.deleteSync(); 75 file.deleteSync();
75 } 76 }
76 77
77 tempDir.deleteSync(); 78 tempDir.deleteSync();
78 } 79 }
79 80
80 Path get scriptOutputPath { 81 Path get scriptOutputPath {
81 return suite.TestUtils.absolutePath(new Path(tempDir.path) 82 return TestUtils.absolutePath(new Path(tempDir.path)
82 .append('created_if_command_did_run.txt')); 83 .append('created_if_command_did_run.txt'));
83 } 84 }
84 85
85 Path get testDartFilePath { 86 Path get testDartFilePath {
86 return suite.TestUtils.absolutePath(new Path(tempDir.path) 87 return TestUtils.absolutePath(new Path(tempDir.path)
87 .append('test.dart')); 88 .append('test.dart'));
88 } 89 }
89 90
90 Path get testJsFilePath { 91 Path get testJsFilePath {
91 return suite.TestUtils.absolutePath(new Path(tempDir.path) 92 return TestUtils.absolutePath(new Path(tempDir.path)
92 .append('test.js')); 93 .append('test.js'));
93 } 94 }
94 95
95 Path get testJsDepsFilePath { 96 Path get testJsDepsFilePath {
96 return suite.TestUtils.absolutePath(new Path(tempDir.path) 97 return TestUtils.absolutePath(new Path(tempDir.path)
97 .append('test.js.deps')); 98 .append('test.js.deps'));
98 } 99 }
99 100
100 Path get testSnapshotFilePath { 101 Path get testSnapshotFilePath {
101 return suite.TestUtils.absolutePath(new Path(tempDir.path) 102 return TestUtils.absolutePath(new Path(tempDir.path)
102 .append('test_dart2js.snapshot')); 103 .append('test_dart2js.snapshot'));
103 } 104 }
104 105
105 void touchFile(File file) { 106 void touchFile(File file) {
106 _writeToFile(file, _readFile(file)); 107 _writeToFile(file, _readFile(file));
107 } 108 }
108 109
109 void _writeToFile(File file, String content) { 110 void _writeToFile(File file, String content) {
110 if (content != null) { 111 if (content != null) {
111 var fd = new File(file.resolveSymbolicLinksSync()) 112 var fd = new File(file.resolveSymbolicLinksSync())
(...skipping 14 matching lines...) Expand all
126 } 127 }
127 } 128 }
128 129
129 class CommandCompletedHandler { 130 class CommandCompletedHandler {
130 FileUtils fileUtils; 131 FileUtils fileUtils;
131 DateTime _expectedTimestamp; 132 DateTime _expectedTimestamp;
132 bool _shouldHaveRun; 133 bool _shouldHaveRun;
133 134
134 CommandCompletedHandler(FileUtils this.fileUtils, bool this._shouldHaveRun); 135 CommandCompletedHandler(FileUtils this.fileUtils, bool this._shouldHaveRun);
135 136
136 void processCompletedTest(runner.CommandOutput output) { 137 void processCompletedTest(command.CommandOutput output) {
137 Expect.isTrue(output.exitCode == 0); 138 Expect.isTrue(output.exitCode == 0);
138 Expect.isTrue(output.stderr.length == 0); 139 Expect.isTrue(output.stderr.length == 0);
139 if (_shouldHaveRun) { 140 if (_shouldHaveRun) {
140 Expect.isTrue(output.stdout.length == 0); 141 Expect.isTrue(output.stdout.length == 0);
141 Expect.isTrue(new File(fileUtils.scriptOutputPath.toNativePath()) 142 Expect.isTrue(new File(fileUtils.scriptOutputPath.toNativePath())
142 .existsSync()); 143 .existsSync());
143 } else { 144 } else {
144 Expect.isFalse(new File(fileUtils.scriptOutputPath.toNativePath()) 145 Expect.isFalse(new File(fileUtils.scriptOutputPath.toNativePath())
145 .existsSync()); 146 .existsSync());
146 } 147 }
147 } 148 }
148 } 149 }
149 150
150 runner.Command makeCompilationCommand(String testName, FileUtils fileUtils) { 151 command.Command makeCompilationCommand(String testName, FileUtils fileUtils) {
151 var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0]; 152 var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0];
152 var createFileScript = Platform.script 153 var createFileScript = Platform.script
153 .resolve('skipping_dart2js_compilations_helper.dart').toFilePath(); 154 .resolve('skipping_dart2js_compilations_helper.dart').toFilePath();
154 var executable = Platform.executable; 155 var executable = Platform.executable;
155 var arguments = [createFileScript, fileUtils.scriptOutputPath.toNativePath()]; 156 var arguments = [createFileScript, fileUtils.scriptOutputPath.toNativePath()];
156 var bootstrapDeps = [ 157 var bootstrapDeps = [
157 Uri.parse("file://${fileUtils.testSnapshotFilePath}")]; 158 Uri.parse("file://${fileUtils.testSnapshotFilePath}")];
158 return runner.CommandBuilder.instance.getCompilationCommand( 159 return command.CommandBuilder.instance.getCompilationCommand(
159 'dart2js', 160 'dart2js',
160 fileUtils.testJsFilePath.toNativePath(), 161 fileUtils.testJsFilePath.toNativePath(),
161 false, 162 false,
162 bootstrapDeps, 163 bootstrapDeps,
163 executable, 164 executable,
164 arguments, {}); 165 arguments, {});
165 } 166 }
166 167
167 void main() { 168 void main() {
168 var fs_noTestJs = new FileUtils(createJs: false, 169 var fs_noTestJs = new FileUtils(createJs: false,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 cleanup(); 238 cleanup();
238 throw error; 239 throw error;
239 }).then((_) { 240 }).then((_) {
240 cleanup(); 241 cleanup();
241 }); 242 });
242 } 243 }
243 // We need to wait some time to make sure that the files we 'touch' get a 244 // We need to wait some time to make sure that the files we 'touch' get a
244 // bigger timestamp than the old ones 245 // bigger timestamp than the old ones
245 new Timer(new Duration(seconds: 1), touchFilesAndRunTests); 246 new Timer(new Duration(seconds: 1), touchFilesAndRunTests);
246 } 247 }
OLDNEW
« no previous file with comments | « tests/standalone/io/dependency_graph_test.dart ('k') | tests/standalone/io/status_file_parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698