Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library docs_test; | |
| 6 | |
| 7 import 'dart:io'; | |
| 8 | |
| 9 import '../../../../pkg/unittest/lib/unittest.dart'; | |
| 10 | |
| 11 import '../bin/docs.dart'; | |
| 12 import '../lib/docs.dart'; | |
| 13 | |
| 14 final Path test_json_path = scriptDir.append('test.json').canonicalize(); | |
|
Bob Nystrom
2013/03/28 14:18:40
Camel-case "testJsonPath" and others. This isn't p
Andrei Mouravski
2013/03/28 17:01:14
Done.
| |
| 15 | |
| 16 main() { | |
| 17 test('Ensure that docs.json is up to date', () { | |
| 18 var oldJson = new File.fromPath(json_path); | |
| 19 var testJson = new File.fromPath(test_json_path); | |
| 20 | |
| 21 // We should find a json file where we expect it. | |
| 22 expect(oldJson.existsSync(), isTrue); | |
| 23 | |
| 24 // Save the last modified time to check it at the end. | |
| 25 var oldJsonModified = oldJson.lastModifiedSync(); | |
| 26 | |
| 27 // There should be no test file yet. | |
| 28 if (testJson.existsSync()) { | |
| 29 testJson.deleteSync(); | |
| 30 } | |
|
Bob Nystrom
2013/03/28 14:18:40
You can make this a one-line if if you want.
Andrei Mouravski
2013/03/28 17:01:14
Done.
| |
| 31 expect(testJson.existsSync(), isFalse); | |
| 32 | |
| 33 expect( | |
| 34 convert(lib_path, test_json_path) | |
| 35 .then((bool anyErrors) { | |
|
Bob Nystrom
2013/03/28 14:18:40
We still don't have an ideal style for code like t
Andrei Mouravski
2013/03/28 17:01:14
Will defer because I'm not that concerned about th
| |
| 36 expect(anyErrors, isFalse); | |
| 37 oldJson = new File.fromPath(json_path); | |
| 38 testJson = new File.fromPath(test_json_path); | |
|
Bob Nystrom
2013/03/28 14:18:40
Are these needed?
Andrei Mouravski
2013/03/28 17:01:14
Done.
| |
| 39 | |
| 40 // We should have a file now. | |
| 41 expect(testJson.existsSync(), isTrue); | |
| 42 | |
| 43 // Ensure that there's nothing different between the new JSON and old. | |
| 44 expect(testJson.readAsLinesSync(), equals(oldJson.readAsLinesSync())); | |
|
Bob Nystrom
2013/03/28 14:18:40
Nit, but I would probably do readAsStringSync().
Andrei Mouravski
2013/03/28 17:01:14
Done.
| |
| 45 | |
| 46 // Ensure that the old JSON file didn't actually change. | |
| 47 expect(oldJsonModified, equals(oldJson.lastModifiedSync())); | |
| 48 | |
| 49 // Clean up. | |
| 50 if (testJson.existsSync()) { | |
| 51 testJson.deleteSync(); | |
| 52 } | |
| 53 expect(testJson.existsSync(), isFalse); | |
| 54 return false; | |
|
Bob Nystrom
2013/03/28 14:18:40
You don't use the completion value, so just remove
Andrei Mouravski
2013/03/28 17:01:14
Done.
| |
| 55 }), completes); | |
| 56 }); | |
| 57 } | |
| OLD | NEW |