Skip to content

Commit e2fb7e7

Browse files
authored
Reenable basic NNBD testing and unblock NNBD support development (#2200)
* Reenable basic NNBD testing and unblock NNBD support development * new version format * Fix path again * fix mac too
1 parent 7c1feb1 commit e2fb7e7

File tree

5 files changed

+58
-14
lines changed

5 files changed

+58
-14
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: dart
22
sudo: false
33
dart:
44
- stable
5-
- "dev/raw/latest"
5+
- "dev/raw/2.9.0-5.0.dev"
66
env:
77
- DARTDOC_BOT=main
88
- DARTDOC_BOT=flutter
@@ -18,7 +18,7 @@ matrix:
1818
include:
1919
- env: DARTDOC_BOT=main
2020
os: osx
21-
dart: "dev/raw/latest"
21+
dart: "dev/raw/2.9.0-5.0.dev"
2222

2323
install:
2424
- ./tool/install_travis.sh

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ branches:
77
- master
88

99
install:
10-
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
10+
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/release/2.9.0-5.0.dev/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
1111
- cmd: echo "Unzipping dart-sdk..."
1212
- cmd: 7z x dart-sdk.zip -o"C:\tools" -y > nul
1313
- cmd: del dart-sdk.zip

test/model_special_cases_test.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ import 'package:dartdoc/dartdoc.dart';
1414
import 'package:dartdoc/src/model/model.dart';
1515
import 'package:dartdoc/src/special_elements.dart';
1616
import 'package:dartdoc/src/warnings.dart';
17+
import 'package:pub_semver/pub_semver.dart';
1718
import 'package:test/test.dart';
1819

1920
import 'src/utils.dart' as utils;
2021

22+
final String _platformVersionString = Platform.version.split(' ').first;
23+
final Version _platformVersion = Version.parse(_platformVersionString);
24+
2125
void main() {
2226
var sdkDir = defaultSdkDir;
2327

@@ -26,11 +30,19 @@ void main() {
2630
exit(1);
2731
}
2832

33+
// This doesn't have the `max` because NNBD is supposed to work after this
34+
// version, and if the `max` is placed here we'll silently pass 2.10 stable
35+
// if we haven't figured out how to switch on NNBD outside of `dev` builds
36+
// as specified in #2148.
37+
final _nnbdExperimentAllowed =
38+
VersionRange(min: Version.parse('2.9.0'), includeMin: true);
39+
2940
// Experimental features not yet enabled by default. Move tests out of this block
3041
// when the feature is enabled by default.
3142
group('Experiments', () {
3243
Library lateFinalWithoutInitializer, nnbdClassMemberDeclarations;
3344
Class b;
45+
3446
setUpAll(() async {
3547
lateFinalWithoutInitializer = (await utils.testPackageGraphExperiments)
3648
.libraries
@@ -120,7 +132,9 @@ void main() {
120132
expect(initializeMe.isLate, isTrue);
121133
expect(initializeMe.features, contains('late'));
122134
});
123-
}, skip: 'dart-lang/dartdoc#2148');
135+
},
136+
skip: (!_nnbdExperimentAllowed.allows(_platformVersion) &&
137+
!_platformVersionString.contains('edge')));
124138

125139
group('HTML Injection when allowed', () {
126140
Class htmlInjection;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
name: test_package_experiments
22
version: 0.0.1
3+
sdk: '>=2.9.0 <2.10.0'
34
description: Experimental flags are tested here.

tool/grind.dart

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ Directory get flutterDir => _flutterDir ??= createTempSync('flutter');
117117
Directory get testPackage =>
118118
Directory(path.joinAll(['testing', 'test_package']));
119119

120+
Directory get testPackageExperiments =>
121+
Directory(path.joinAll(['testing', 'test_package_experiments']));
122+
120123
Directory get pluginPackage =>
121124
Directory(path.joinAll(['testing', 'test_package_flutter_plugin']));
122125

@@ -125,6 +128,11 @@ Directory _testPackageDocsDir;
125128
Directory get testPackageDocsDir =>
126129
_testPackageDocsDir ??= createTempSync('test_package');
127130

131+
Directory _testPackageExperimentsDocsDir;
132+
Directory get testPackageExperimentsDocsDir =>
133+
_testPackageExperimentsDocsDir ??=
134+
createTempSync('test_package_experiments');
135+
128136
Directory _pluginPackageDocsDir;
129137

130138
Directory get pluginPackageDocsDir =>
@@ -497,15 +505,14 @@ Future<List<Map>> _buildSdkDocs(String sdkDocsPath, Future<String> futureCwd,
497505
workingDirectory: cwd);
498506
}
499507

500-
Future<List<Map>> _buildTestPackageDocs(
501-
String outputDir, Future<String> futureCwd,
502-
[String label]) async {
503-
label ??= '';
508+
Future<List<Map>> _buildTestPackageDocs(String outputDir, String cwd,
509+
{List<String> params, String label = '', String testPackagePath}) async {
504510
if (label != '') label = '-$label';
511+
testPackagePath ??= testPackage.absolute.path;
512+
params ??= [];
505513
var launcher = SubprocessLauncher('build-test-package-docs$label');
506514
Future testPackagePubGet = launcher.runStreamed(sdkBin('pub'), ['get'],
507-
workingDirectory: testPackage.absolute.path);
508-
var cwd = await futureCwd;
515+
workingDirectory: testPackagePath);
509516
Future dartdocPubGet =
510517
launcher.runStreamed(sdkBin('pub'), ['get'], workingDirectory: cwd);
511518
await Future.wait([testPackagePubGet, dartdocPubGet]);
@@ -522,16 +529,33 @@ Future<List<Map>> _buildTestPackageDocs(
522529
'--json',
523530
'--link-to-remote',
524531
'--pretty-index-json',
532+
...params,
525533
...extraDartdocParameters,
526534
],
527-
workingDirectory: testPackage.absolute.path);
535+
workingDirectory: testPackagePath);
536+
}
537+
538+
@Task('Build generated test package docs from the experiment test package')
539+
@Depends(clean)
540+
Future<void> buildTestExperimentsPackageDocs() async {
541+
await _buildTestPackageDocs(
542+
testPackageExperimentsDocsDir.absolute.path, Directory.current.path,
543+
testPackagePath: testPackageExperiments.absolute.path,
544+
params: ['--enable-experiment', 'non-nullable', '--no-link-to-remote']);
545+
}
546+
547+
@Task('Serve experimental test package on port 8003.')
548+
@Depends(buildTestExperimentsPackageDocs)
549+
Future<void> serveTestExperimentsPackageDocs() async {
550+
await _serveDocsFrom(testPackageExperimentsDocsDir.absolute.path, 8003,
551+
'test-package-docs-experiments');
528552
}
529553

530554
@Task('Build generated test package docs (with inherited docs and source code)')
531555
@Depends(clean)
532556
Future<void> buildTestPackageDocs() async {
533557
await _buildTestPackageDocs(
534-
testPackageDocsDir.absolute.path, Future.value(Directory.current.path));
558+
testPackageDocsDir.absolute.path, Directory.current.path);
535559
}
536560

537561
@Task('Serve test package docs locally with dhttpd on port 8002')
@@ -549,11 +573,16 @@ Future<void> serveTestPackageDocs() async {
549573
]);
550574
}
551575

576+
bool _serveReady = false;
577+
552578
Future<void> _serveDocsFrom(String servePath, int port, String context) async {
553579
log('launching dhttpd on port $port for $context');
554580
var launcher = SubprocessLauncher(context);
555-
await launcher.runStreamed(sdkBin('pub'), ['get']);
556-
await launcher.runStreamed(sdkBin('pub'), ['global', 'activate', 'dhttpd']);
581+
if (!_serveReady) {
582+
await launcher.runStreamed(sdkBin('pub'), ['get']);
583+
await launcher.runStreamed(sdkBin('pub'), ['global', 'activate', 'dhttpd']);
584+
_serveReady = true;
585+
}
557586
await launcher.runStreamed(
558587
sdkBin('pub'), ['run', 'dhttpd', '--port', '$port', '--path', servePath]);
559588
}

0 commit comments

Comments
 (0)