OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 if (createSnapshot) { | 45 if (createSnapshot) { |
46 testSnapshot = _createFile(testSnapshotFilePath); | 46 testSnapshot = _createFile(testSnapshotFilePath); |
47 _writeToFile(testSnapshot, "dart2js snapshot"); | 47 _writeToFile(testSnapshot, "dart2js snapshot"); |
48 } | 48 } |
49 if (createDart) { | 49 if (createDart) { |
50 testDart = _createFile(testDartFilePath); | 50 testDart = _createFile(testDartFilePath); |
51 _writeToFile(testDart, "dart code"); | 51 _writeToFile(testDart, "dart code"); |
52 } | 52 } |
53 if (createJsDeps) { | 53 if (createJsDeps) { |
54 testJsDeps = _createFile(testJsDepsFilePath); | 54 testJsDeps = _createFile(testJsDepsFilePath); |
55 var path = suite.TestUtils.absolutePath(new Path.fromNative(tempDir.path)) | 55 var path = suite.TestUtils.absolutePath(new Path(tempDir.path)) |
56 .append("test.dart"); | 56 .append("test.dart"); |
57 _writeToFile(testJsDeps, "file://$path"); | 57 _writeToFile(testJsDeps, "file://$path"); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 void cleanup() { | 61 void cleanup() { |
62 if (testJs != null) testJs.deleteSync(); | 62 if (testJs != null) testJs.deleteSync(); |
63 if (testJsDeps != null) testJsDeps.deleteSync(); | 63 if (testJsDeps != null) testJsDeps.deleteSync(); |
64 if (testDart != null) testDart.deleteSync(); | 64 if (testDart != null) testDart.deleteSync(); |
65 if (testSnapshot != null) testSnapshot.deleteSync(); | 65 if (testSnapshot != null) testSnapshot.deleteSync(); |
66 | 66 |
67 // if the script did run, it created this file, so we need to delete it | 67 // if the script did run, it created this file, so we need to delete it |
68 File file = new File(scriptOutputPath.toNativePath()); | 68 File file = new File(scriptOutputPath.toNativePath()); |
69 if (file.existsSync()) { | 69 if (file.existsSync()) { |
70 file.deleteSync(); | 70 file.deleteSync(); |
71 } | 71 } |
72 | 72 |
73 tempDir.deleteSync(); | 73 tempDir.deleteSync(); |
74 } | 74 } |
75 | 75 |
76 Path get scriptOutputPath { | 76 Path get scriptOutputPath { |
77 return suite.TestUtils.absolutePath(new Path.fromNative(tempDir.path) | 77 return suite.TestUtils.absolutePath(new Path(tempDir.path) |
78 .append('created_if_command_did_run.txt')); | 78 .append('created_if_command_did_run.txt')); |
79 } | 79 } |
80 | 80 |
81 Path get testDartFilePath { | 81 Path get testDartFilePath { |
82 return suite.TestUtils.absolutePath(new Path.fromNative(tempDir.path) | 82 return suite.TestUtils.absolutePath(new Path(tempDir.path) |
83 .append('test.dart')); | 83 .append('test.dart')); |
84 } | 84 } |
85 | 85 |
86 Path get testJsFilePath { | 86 Path get testJsFilePath { |
87 return suite.TestUtils.absolutePath(new Path.fromNative(tempDir.path) | 87 return suite.TestUtils.absolutePath(new Path(tempDir.path) |
88 .append('test.js')); | 88 .append('test.js')); |
89 } | 89 } |
90 | 90 |
91 Path get testJsDepsFilePath { | 91 Path get testJsDepsFilePath { |
92 return suite.TestUtils.absolutePath(new Path.fromNative(tempDir.path) | 92 return suite.TestUtils.absolutePath(new Path(tempDir.path) |
93 .append('test.js.deps')); | 93 .append('test.js.deps')); |
94 } | 94 } |
95 | 95 |
96 Path get testSnapshotFilePath { | 96 Path get testSnapshotFilePath { |
97 return suite.TestUtils.absolutePath(new Path.fromNative(tempDir.path) | 97 return suite.TestUtils.absolutePath(new Path(tempDir.path) |
98 .append('test_dart2js.snapshot')); | 98 .append('test_dart2js.snapshot')); |
99 } | 99 } |
100 | 100 |
101 void touchFile(File file) { | 101 void touchFile(File file) { |
102 _writeToFile(file, _readFile(file)); | 102 _writeToFile(file, _readFile(file)); |
103 } | 103 } |
104 | 104 |
105 void _writeToFile(File file, String content) { | 105 void _writeToFile(File file, String content) { |
106 if (content != null) { | 106 if (content != null) { |
107 var fd = new File(file.fullPathSync()).openSync(FileMode.WRITE); | 107 var fd = new File(file.fullPathSync()).openSync(FileMode.WRITE); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 .existsSync()); | 142 .existsSync()); |
143 } | 143 } |
144 fileUtils.cleanup(); | 144 fileUtils.cleanup(); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 runner.TestCase makeTestCase(String testName, | 148 runner.TestCase makeTestCase(String testName, |
149 TestCompletedHandler completedHandler) { | 149 TestCompletedHandler completedHandler) { |
150 var fileUtils = completedHandler.fileUtils; | 150 var fileUtils = completedHandler.fileUtils; |
151 var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0]; | 151 var config = new options.TestOptionsParser().parse(['--timeout', '2'])[0]; |
152 var scriptDirPath = new Path.fromNative(new Options().script).directoryPath; | 152 var scriptDirPath = new Path(new Options().script).directoryPath; |
153 var createFileScript = scriptDirPath. | 153 var createFileScript = scriptDirPath. |
154 append('skipping_dart2js_compilations_helper.dart').toNativePath(); | 154 append('skipping_dart2js_compilations_helper.dart').toNativePath(); |
155 var executable = new Options().executable; | 155 var executable = new Options().executable; |
156 var arguments = [createFileScript, fileUtils.scriptOutputPath.toNativePath()]; | 156 var arguments = [createFileScript, fileUtils.scriptOutputPath.toNativePath()]; |
157 var bootstrapDeps = [ | 157 var bootstrapDeps = [ |
158 new Uri("file://${fileUtils.testSnapshotFilePath}")]; | 158 new Uri("file://${fileUtils.testSnapshotFilePath}")]; |
159 var commands = [new runner.CompilationCommand( | 159 var commands = [new runner.CompilationCommand( |
160 fileUtils.testJsFilePath.toNativePath(), | 160 fileUtils.testJsFilePath.toNativePath(), |
161 false, | 161 false, |
162 bootstrapDeps, | 162 bootstrapDeps, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 runTest("fs_notUpToDate_snapshot", fs_notUpToDate_snapshot, true); | 216 runTest("fs_notUpToDate_snapshot", fs_notUpToDate_snapshot, true); |
217 runTest("fs_notUpToDate_dart", fs_notUpToDate_dart, true); | 217 runTest("fs_notUpToDate_dart", fs_notUpToDate_dart, true); |
218 // This is the only test where all dependencies are present and the test.js | 218 // This is the only test where all dependencies are present and the test.js |
219 // file is newer than all the others. So we pass 'false' for shouldRun. | 219 // file is newer than all the others. So we pass 'false' for shouldRun. |
220 runTest("fs_upToDate", fs_upToDate, false); | 220 runTest("fs_upToDate", fs_upToDate, false); |
221 } | 221 } |
222 // We need to wait some time to make sure that the files we 'touch' get a | 222 // We need to wait some time to make sure that the files we 'touch' get a |
223 // bigger timestamp than the old ones | 223 // bigger timestamp than the old ones |
224 new Timer(1000, touchFilesAndRunTests); | 224 new Timer(1000, touchFilesAndRunTests); |
225 } | 225 } |
OLD | NEW |