Skip to content

Commit d1dcc39

Browse files
authored
Make dartdoc tests work where --preview-dart-2 is the default (#1719)
* Make dartdoc tests work where --preview-dart-2 is the default * Fix a type problem in grinder script (first time using it in Dart 2) * Replace checked with --enable-asserts * Fix more Future<Null>s and re-allow broader SDK versioning
1 parent 136e892 commit d1dcc39

File tree

5 files changed

+30
-49
lines changed

5 files changed

+30
-49
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: dart
22
sudo: false
33
dart:
4-
- "dev/raw/2.0.0-dev.63.0"
4+
- "dev/raw/latest"
55
env:
66
- DARTDOC_BOT=main
77
# TODO(devoncarew): add angulardart support

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# BSD-style license that can be found in the LICENSE file.
44

55
install:
6-
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/raw/2.0.0-dev.63.0/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
6+
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/raw/latest/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
77
- cmd: echo "Unzipping dart-sdk..."
88
- cmd: 7z x dart-sdk.zip -o"C:\tools" -y > nul
99
- set PATH=%PATH%;C:\tools\dart-sdk\bin

lib/src/io_utils.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ final newLinePartOfRegexp = new RegExp('\npart of ');
6666

6767
final RegExp quotables = new RegExp(r'[ "\r\n\$]');
6868

69-
/// Best used with Future<Null>.
69+
/// Best used with Future<void>.
7070
class MultiFutureTracker<T> {
7171
/// Approximate maximum number of simultaneous active Futures.
7272
final int parallel;
@@ -105,7 +105,7 @@ class SubprocessLauncher {
105105
String get prefix => context.isNotEmpty ? '$context: ' : '';
106106

107107
// from flutter:dev/tools/dartdoc.dart, modified
108-
static Future<Null> _printStream(Stream<List<int>> stream, Stdout output,
108+
static Future<void> _printStream(Stream<List<int>> stream, Stdout output,
109109
{String prefix: '', Iterable<String> Function(String line) filter}) {
110110
assert(prefix != null);
111111
if (filter == null) filter = (line) => [line];
@@ -188,9 +188,9 @@ class SubprocessLauncher {
188188

189189
Process process = await Process.start(executable, arguments,
190190
workingDirectory: workingDirectory, environment: environment);
191-
Future<Null> stdoutFuture = _printStream(process.stdout, stdout,
191+
Future<void> stdoutFuture = _printStream(process.stdout, stdout,
192192
prefix: prefix, filter: jsonCallback);
193-
Future<Null> stderrFuture = _printStream(process.stderr, stderr,
193+
Future<void> stderrFuture = _printStream(process.stderr, stderr,
194194
prefix: prefix, filter: jsonCallback);
195195
await Future.wait([stderrFuture, stdoutFuture, process.exitCode]);
196196

pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,4 +492,4 @@ packages:
492492
source: hosted
493493
version: "2.1.13"
494494
sdks:
495-
dart: ">=2.0.0-dev.59.0 <=2.0.0-dev.63.0"
495+
dart: ">=2.0.0-dev.59.0 <=2.0.0-dev.63.0.flutter-4c9689c1d2"

tool/grind.dart

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Directory createTempSync(String prefix) =>
5050
final Memoizer tempdirsCache = new Memoizer();
5151

5252
/// Global so that the lock is retained for the life of the process.
53-
Future<Null> _lockFuture;
53+
Future<void> _lockFuture;
5454
Completer<FlutterRepo> _cleanFlutterRepo;
5555

5656
/// Returns true if we need to replace the existing flutter. We never release
@@ -337,7 +337,7 @@ Future<List<Map>> _buildSdkDocs(String sdkDocsPath, Future<String> futureCwd,
337337
return await launcher.runStreamed(
338338
Platform.resolvedExecutable,
339339
[
340-
'--checked',
340+
'--enable-asserts',
341341
pathLib.join('bin', 'dartdoc.dart'),
342342
'--output',
343343
'${sdkDocsPath}',
@@ -361,7 +361,7 @@ Future<List<Map>> _buildTestPackageDocs(
361361
return await launcher.runStreamed(
362362
Platform.resolvedExecutable,
363363
[
364-
'--checked',
364+
'--enable-asserts',
365365
pathLib.join(cwd, 'bin', 'dartdoc.dart'),
366366
'--output',
367367
outputDir,
@@ -520,7 +520,7 @@ class FlutterRepo {
520520
new SubprocessLauncher('flutter${label == null ? "" : "-$label"}', env);
521521
}
522522

523-
Future<Null> _init() async {
523+
Future<void> _init() async {
524524
new Directory(flutterPath).createSync(recursive: true);
525525
await launcher.runStreamed(
526526
'git', ['clone', 'https://github.com/flutter/flutter.git', '.'],
@@ -605,7 +605,7 @@ Future<String> _buildPubPackageDocs(String pubPackageName,
605605
await launcher.runStreamed(
606606
Platform.resolvedExecutable,
607607
[
608-
'--checked',
608+
'--enable-asserts',
609609
pathLib.join(Directory.current.absolute.path, 'bin', 'dartdoc.dart'),
610610
'--json',
611611
'--show-progress',
@@ -654,7 +654,8 @@ _getPackageVersion() {
654654
@Task('Rebuild generated files')
655655
build() async {
656656
var launcher = new SubprocessLauncher('build');
657-
await launcher.runStreamed(sdkBin('pub'), ['run', 'build_runner', 'build', '--delete-conflicting-outputs']);
657+
await launcher.runStreamed(sdkBin('pub'),
658+
['run', 'build_runner', 'build', '--delete-conflicting-outputs']);
658659
}
659660

660661
/// Paths in this list are relative to lib/.
@@ -677,7 +678,8 @@ checkBuild() async {
677678
}
678679
}
679680

680-
await launcher.runStreamed(sdkBin('pub'), ['run', 'build_runner', 'build', '--delete-conflicting-outputs']);
681+
await launcher.runStreamed(sdkBin('pub'),
682+
['run', 'build_runner', 'build', '--delete-conflicting-outputs']);
681683
for (String relPath in _generated_files_list) {
682684
File newVersion = new File(pathLib.join('lib', relPath));
683685
if (!await newVersion.exists()) {
@@ -707,25 +709,24 @@ publish() async {
707709

708710
@Task('Run all the tests.')
709711
test() async {
710-
await testPreviewDart2();
711-
await testDart1();
712+
await testDart2();
712713
await testFutures.wait();
713714
}
714715

715716
List<File> get binFiles => new Directory('bin')
716717
.listSync(recursive: true)
717718
.where((e) => e is File && e.path.endsWith('.dart'))
718719
.cast<File>()
719-
..toList();
720+
.toList();
720721

721722
List<File> get testFiles => new Directory('test')
722723
.listSync(recursive: true)
723724
.where((e) => e is File && e.path.endsWith('test.dart'))
724725
.cast<File>()
725-
..toList();
726+
.toList();
726727

727-
testPreviewDart2() async {
728-
List<String> parameters = ['--preview-dart-2', '--enable-asserts'];
728+
testDart2() async {
729+
List<String> parameters = ['--enable-asserts'];
729730

730731
for (File dartFile in testFiles) {
731732
await testFutures.addFuture(
@@ -749,35 +750,15 @@ testPreviewDart2() async {
749750
}
750751
}
751752

752-
testDart1() async {
753-
List<String> parameters = ['--checked'];
754-
for (File dartFile in testFiles) {
755-
await testFutures.addFuture(
756-
new SubprocessLauncher('dart1-${pathLib.basename(dartFile.path)}')
757-
.runStreamed(
758-
Platform.resolvedExecutable,
759-
<String>[]
760-
..addAll(parameters)
761-
..add(dartFile.path)));
762-
}
763-
764-
for (File dartFile in binFiles) {
765-
await testFutures.addFuture(new SubprocessLauncher(
766-
'dart1-bin-${pathLib.basename(dartFile.path)}-help')
767-
.runStreamed(
768-
Platform.resolvedExecutable,
769-
<String>[]
770-
..addAll(parameters)
771-
..add(dartFile.path)
772-
..add('--help')));
773-
}
774-
}
775-
776753
@Task('Generate docs for dartdoc')
777754
testDartdoc() async {
778755
var launcher = new SubprocessLauncher('test-dartdoc');
779-
await launcher.runStreamed(Platform.resolvedExecutable,
780-
['--checked', 'bin/dartdoc.dart', '--output', dartdocDocsDir.path]);
756+
await launcher.runStreamed(Platform.resolvedExecutable, [
757+
'--enable-asserts',
758+
'bin/dartdoc.dart',
759+
'--output',
760+
dartdocDocsDir.path
761+
]);
781762
expectFileContains(pathLib.join(dartdocDocsDir.path, 'index.html'),
782763
['<title>dartdoc - Dart API docs</title>']);
783764
final RegExp object = new RegExp('<li>Object</li>', multiLine: true);
@@ -793,7 +774,7 @@ testDartdocRemote() async {
793774
'<a href="https://api.dartlang.org/(dev|stable)/[^/]*/dart-core/Object-class.html">Object</a>',
794775
multiLine: true);
795776
await launcher.runStreamed(Platform.resolvedExecutable, [
796-
'--checked',
777+
'--enable-asserts',
797778
'bin/dartdoc.dart',
798779
'--link-to-remote',
799780
'--output',
@@ -821,7 +802,7 @@ Future<WarningsCollection> _buildDartdocFlutterPluginDocs() async {
821802
await flutterRepo.launcher.runStreamed(
822803
Platform.resolvedExecutable,
823804
[
824-
'--checked',
805+
'--enable-asserts',
825806
pathLib.join(Directory.current.path, 'bin', 'dartdoc.dart'),
826807
'--json',
827808
'--link-to-remote',
@@ -869,7 +850,7 @@ updateTestPackageDocs() async {
869850
await launcher.runStreamed(
870851
Platform.resolvedExecutable,
871852
[
872-
'--checked',
853+
'--enable-asserts',
873854
pathLib.join('..', '..', 'bin', 'dartdoc.dart'),
874855
'--auto-include-dependencies',
875856
'--example-path-prefix',

0 commit comments

Comments
 (0)