| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 docgen.test.only_lib_content_in_pkg; | 5 library docgen.test.only_lib_content_in_pkg; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 import 'package:scheduled_test/descriptor.dart' as d; | 10 import 'package:scheduled_test/descriptor.dart' as d; |
| 11 import 'package:scheduled_test/scheduled_test.dart'; | 11 import 'package:scheduled_test/scheduled_test.dart'; |
| 12 import 'package:unittest/matcher.dart'; | 12 import 'package:unittest/matcher.dart'; |
| 13 | 13 |
| 14 import '../lib/docgen.dart' as dg; | 14 import '../lib/docgen.dart' as dg; |
| 15 import 'util.dart'; | 15 import 'util.dart'; |
| 16 | 16 |
| 17 void main() { | 17 void main() { |
| 18 | 18 |
| 19 setUp(() { | 19 setUp(() { |
| 20 scheduleTempDir(); | 20 scheduleTempDir(); |
| 21 }); | 21 }); |
| 22 | 22 |
| 23 test('exclude non-lib code from package docs', () { | 23 test('exclude non-lib code from package docs', () { |
| 24 schedule(() { | 24 schedule(() { |
| 25 var thisScript = Platform.script; | 25 var thisScript = Platform.script; |
| 26 var thisPath = p.fromUri(thisScript); | 26 var thisPath = p.fromUri(thisScript); |
| 27 expect(p.basename(thisPath), 'only_lib_content_in_pkg_test.dart'); | 27 expect(p.basename(thisPath), 'only_lib_content_in_pkg_test.dart'); |
| 28 expect(p.dirname(thisPath), endsWith('test')); | 28 expect(p.dirname(thisPath), endsWith('test')); |
| 29 | 29 |
| 30 var packageRoot = Platform.packageRoot; |
| 31 if (packageRoot == '') packageRoot = null; |
| 32 |
| 30 var codeDir = p.normalize(p.join(thisPath, '..', '..')); | 33 var codeDir = p.normalize(p.join(thisPath, '..', '..')); |
| 31 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); | 34 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); |
| 32 return dg.docgen(['$codeDir/'], out: p.join(d.defaultRoot, 'docs'), | 35 return dg.docgen(['$codeDir/'], out: p.join(d.defaultRoot, 'docs'), |
| 33 packageRoot: Platform.packageRoot); | 36 packageRoot: packageRoot); |
| 34 }); | 37 }); |
| 35 | 38 |
| 36 d.dir('docs', [ | 39 d.dir('docs', [ |
| 37 d.dir('docgen', [ | 40 d.dir('docgen', [ |
| 38 d.matcherFile('docgen.json', isJsonMap) | 41 d.matcherFile('docgen.json', isJsonMap) |
| 39 ]), | 42 ]), |
| 40 d.matcherFile('index.json', isJsonMap), | 43 d.matcherFile('index.json', isJsonMap), |
| 41 d.matcherFile('index.txt', hasSortedLines), | 44 d.matcherFile('index.txt', hasSortedLines), |
| 42 d.matcherFile('library_list.json', isJsonMap), | 45 d.matcherFile('library_list.json', isJsonMap), |
| 43 d.nothing('test_lib.json'), | 46 d.nothing('test_lib.json'), |
| 44 d.nothing('test_lib-bar.json'), | 47 d.nothing('test_lib-bar.json'), |
| 45 d.nothing('test_lib-foo.json') | 48 d.nothing('test_lib-foo.json') |
| 46 ]).validate(); | 49 ]).validate(); |
| 47 | 50 |
| 48 }); | 51 }); |
| 49 } | 52 } |
| OLD | NEW |