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

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

Issue 2915843003: Simplify test_suite.dart. (Closed)
Patch Set: Fix path in test. Created 3 years, 6 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
« no previous file with comments | « no previous file | tests/standalone/io/test_runner_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // OtherResources=skipping_dart2js_compilations_helper.dart 5 // OtherResources=skipping_dart2js_compilations_helper.dart
6 6
7 /* 7 /*
8 * This test makes sure that the "skipping Dart2Js compilations if the output is 8 * This test makes sure that the "skipping Dart2Js compilations if the output is
9 * already up to date" feature does work as it should. 9 * already up to date" feature does work as it should.
10 * Therefore this test ensures that compilations are only skipped if the last 10 * Therefore this test ensures that compilations are only skipped if the last
11 * modified date of the output of a dart2js compilation is newer than 11 * modified date of the output of a dart2js compilation is newer than
12 * - the dart application to compile (including it's dependencies) 12 * - the dart application to compile (including it's dependencies)
13 * - the dart2js snapshot 13 * - the dart2js snapshot
14 * Furtheremore it ensure that a compilations is not skipped if any of the 14 * Furtheremore it ensure that a compilations is not skipped if any of the
15 * necessary files could not be found (dart2js snapshots, previous dart2js 15 * necessary files could not be found (dart2js snapshots, previous dart2js
16 * output (+deps file), dart application) 16 * output (+deps file), dart application)
17 */ 17 */
18 18
19 import 'package:expect/expect.dart'; 19 import 'package:expect/expect.dart';
20 import 'package:path/path.dart'; 20 import 'package:path/path.dart';
21 import 'dart:async'; 21 import 'dart:async';
22 import 'dart:io'; 22 import 'dart:io';
23 import '../../../tools/testing/dart/options.dart' as options; 23 import '../../../tools/testing/dart/options.dart' as options;
24 import '../../../tools/testing/dart/path.dart'; 24 import '../../../tools/testing/dart/path.dart';
25 import '../../../tools/testing/dart/test_suite.dart' as suite;
26 import '../../../tools/testing/dart/test_runner.dart' as runner; 25 import '../../../tools/testing/dart/test_runner.dart' as runner;
27 import '../../../tools/testing/dart/utils.dart'; 26 import '../../../tools/testing/dart/utils.dart';
28 27
29 /** 28 /**
30 * This class is reponsible for setting up the files necessary for this test 29 * This class is reponsible for setting up the files necessary for this test
31 * as well as touching a file. 30 * as well as touching a file.
32 */ 31 */
33 class FileUtils { 32 class FileUtils {
34 Directory tempDir; 33 Directory tempDir;
35 File testJs; 34 File testJs;
(...skipping 15 matching lines...) Expand all
51 if (createSnapshot) { 50 if (createSnapshot) {
52 testSnapshot = _createFile(testSnapshotFilePath); 51 testSnapshot = _createFile(testSnapshotFilePath);
53 _writeToFile(testSnapshot, "dart2js snapshot"); 52 _writeToFile(testSnapshot, "dart2js snapshot");
54 } 53 }
55 if (createDart) { 54 if (createDart) {
56 testDart = _createFile(testDartFilePath); 55 testDart = _createFile(testDartFilePath);
57 _writeToFile(testDart, "dart code"); 56 _writeToFile(testDart, "dart code");
58 } 57 }
59 if (createJsDeps) { 58 if (createJsDeps) {
60 testJsDeps = _createFile(testJsDepsFilePath); 59 testJsDeps = _createFile(testJsDepsFilePath);
61 var path = suite.TestUtils 60 var path =
62 .absolutePath(new Path(tempDir.path)) 61 TestUtils.absolutePath(new Path(tempDir.path)).append("test.dart");
63 .append("test.dart");
64 _writeToFile(testJsDeps, "file://$path"); 62 _writeToFile(testJsDeps, "file://$path");
65 } 63 }
66 } 64 }
67 65
68 void cleanup() { 66 void cleanup() {
69 if (testJs != null) testJs.deleteSync(); 67 if (testJs != null) testJs.deleteSync();
70 if (testJsDeps != null) testJsDeps.deleteSync(); 68 if (testJsDeps != null) testJsDeps.deleteSync();
71 if (testDart != null) testDart.deleteSync(); 69 if (testDart != null) testDart.deleteSync();
72 if (testSnapshot != null) testSnapshot.deleteSync(); 70 if (testSnapshot != null) testSnapshot.deleteSync();
73 71
74 // 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
75 File file = new File(scriptOutputPath.toNativePath()); 73 File file = new File(scriptOutputPath.toNativePath());
76 if (file.existsSync()) { 74 if (file.existsSync()) {
77 file.deleteSync(); 75 file.deleteSync();
78 } 76 }
79 77
80 tempDir.deleteSync(); 78 tempDir.deleteSync();
81 } 79 }
82 80
83 Path get scriptOutputPath { 81 Path get scriptOutputPath {
84 return suite.TestUtils.absolutePath( 82 return TestUtils.absolutePath(
85 new Path(tempDir.path).append('created_if_command_did_run.txt')); 83 new Path(tempDir.path).append('created_if_command_did_run.txt'));
86 } 84 }
87 85
88 Path get testDartFilePath { 86 Path get testDartFilePath {
89 return suite.TestUtils 87 return TestUtils.absolutePath(new Path(tempDir.path).append('test.dart'));
90 .absolutePath(new Path(tempDir.path).append('test.dart'));
91 } 88 }
92 89
93 Path get testJsFilePath { 90 Path get testJsFilePath {
94 return suite.TestUtils 91 return TestUtils.absolutePath(new Path(tempDir.path).append('test.js'));
95 .absolutePath(new Path(tempDir.path).append('test.js'));
96 } 92 }
97 93
98 Path get testJsDepsFilePath { 94 Path get testJsDepsFilePath {
99 return suite.TestUtils 95 return TestUtils
100 .absolutePath(new Path(tempDir.path).append('test.js.deps')); 96 .absolutePath(new Path(tempDir.path).append('test.js.deps'));
101 } 97 }
102 98
103 Path get testSnapshotFilePath { 99 Path get testSnapshotFilePath {
104 return suite.TestUtils 100 return TestUtils
105 .absolutePath(new Path(tempDir.path).append('test_dart2js.snapshot')); 101 .absolutePath(new Path(tempDir.path).append('test_dart2js.snapshot'));
106 } 102 }
107 103
108 void touchFile(File file) { 104 void touchFile(File file) {
109 _writeToFile(file, _readFile(file)); 105 _writeToFile(file, _readFile(file));
110 } 106 }
111 107
112 void _writeToFile(File file, String content) { 108 void _writeToFile(File file, String content) {
113 if (content != null) { 109 if (content != null) {
114 var fd = new File(file.resolveSymbolicLinksSync()) 110 var fd = new File(file.resolveSymbolicLinksSync())
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 'dart2js', 158 'dart2js',
163 fileUtils.testJsFilePath.toNativePath(), 159 fileUtils.testJsFilePath.toNativePath(),
164 false, 160 false,
165 bootstrapDeps, 161 bootstrapDeps,
166 executable, 162 executable,
167 arguments, {}); 163 arguments, {});
168 } 164 }
169 165
170 void main() { 166 void main() {
171 // This script is in [sdk]/tests/standalone/io. 167 // This script is in [sdk]/tests/standalone/io.
172 suite.TestUtils.setDartDirUri(Platform.script.resolve('../../..')); 168 TestUtils.setDartDirUri(Platform.script.resolve('../../..'));
173 169
174 var fs_noTestJs = new FileUtils( 170 var fs_noTestJs = new FileUtils(
175 createJs: false, 171 createJs: false,
176 createJsDeps: true, 172 createJsDeps: true,
177 createDart: true, 173 createDart: true,
178 createSnapshot: true); 174 createSnapshot: true);
179 var fs_noTestJsDeps = new FileUtils( 175 var fs_noTestJsDeps = new FileUtils(
180 createJs: true, 176 createJs: true,
181 createJsDeps: false, 177 createJsDeps: false,
182 createDart: true, 178 createDart: true,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 throw error; 248 throw error;
253 }).then((_) { 249 }).then((_) {
254 cleanup(); 250 cleanup();
255 }); 251 });
256 } 252 }
257 253
258 // We need to wait some time to make sure that the files we 'touch' get a 254 // We need to wait some time to make sure that the files we 'touch' get a
259 // bigger timestamp than the old ones 255 // bigger timestamp than the old ones
260 new Timer(new Duration(seconds: 1), touchFilesAndRunTests); 256 new Timer(new Duration(seconds: 1), touchFilesAndRunTests);
261 } 257 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/test_runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698