OLD | NEW |
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 library docs_test; | 5 library docs_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
11 | 11 |
12 import '../bin/docs.dart'; | 12 import '../bin/docs.dart'; |
13 import '../lib/docs.dart'; | 13 import '../lib/docs.dart'; |
14 | 14 |
15 final testJsonPath = Platform.script.resolve('test.json').toFilePath(); | 15 final testJsonPath = path.normalize(path.join(scriptDir, 'test.json')); |
16 | 16 |
17 main() { | 17 main() { |
18 // Some tests take more than the default 20 second unittest timeout. | 18 // Some tests take more than the default 20 second unittest timeout. |
19 unittestConfiguration.timeout = null; | 19 unittestConfiguration.timeout = null; |
20 group('docs', () { | 20 group('docs', () { |
21 var oldJson = new File(json_path); | 21 var oldJson = new File(json_path); |
22 var testJson = new File(testJsonPath); | 22 var testJson = new File(testJsonPath); |
23 | 23 |
24 tearDown(() { | 24 tearDown(() { |
25 // Clean up. | 25 // Clean up. |
26 if (testJson.existsSync()) { | 26 if (testJson.existsSync()) { |
27 testJson.deleteSync(); | 27 testJson.deleteSync(); |
28 } | 28 } |
29 assert(!testJson.existsSync()); | 29 assert(!testJson.existsSync()); |
30 }); | 30 }); |
31 | 31 |
32 test('Ensure that docs.json is up to date', () { | 32 test('Ensure that docs.json is up to date', () { |
33 // We should find a json file where we expect it. | 33 // We should find a json file where we expect it. |
34 expect(oldJson.existsSync(), isTrue); | 34 expect(oldJson.existsSync(), isTrue); |
35 | 35 |
36 // Save the last modified time to check it at the end. | 36 // Save the last modified time to check it at the end. |
37 var oldJsonModified = oldJson.lastModifiedSync(); | 37 var oldJsonModified = oldJson.lastModifiedSync(); |
38 | 38 |
39 // There should be no test file yet. | 39 // There should be no test file yet. |
40 if (testJson.existsSync()) testJson.deleteSync(); | 40 if (testJson.existsSync()) testJson.deleteSync(); |
41 assert(!testJson.existsSync()); | 41 assert(!testJson.existsSync()); |
42 | 42 |
43 expect(convert(lib_uri, testJsonPath) | 43 expect(convert(lib_path, testJsonPath) |
44 .then((bool anyErrors) { | 44 .then((bool anyErrors) { |
45 expect(anyErrors, isFalse); | 45 expect(anyErrors, isFalse); |
46 | 46 |
47 // We should have a file now. | 47 // We should have a file now. |
48 expect(testJson.existsSync(), isTrue); | 48 expect(testJson.existsSync(), isTrue); |
49 | 49 |
50 // Ensure that there's nothing different between the new JSON and old. | 50 // Ensure that there's nothing different between the new JSON and old. |
51 expect(testJson.readAsStringSync(), equals(oldJson.readAsStringSync())); | 51 expect(testJson.readAsStringSync(), equals(oldJson.readAsStringSync())); |
52 | 52 |
53 // Ensure that the old JSON file didn't actually change. | 53 // Ensure that the old JSON file didn't actually change. |
54 expect(oldJsonModified, equals(oldJson.lastModifiedSync())); | 54 expect(oldJsonModified, equals(oldJson.lastModifiedSync())); |
55 }), completes); | 55 }), completes); |
56 }); | 56 }); |
57 }); | 57 }); |
58 } | 58 } |
OLD | NEW |