Skip to content

Reenable basic NNBD testing and unblock NNBD support development #2200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: dart
sudo: false
dart:
- stable
- "dev/raw/latest"
- "dev/raw/2.9.0-5.0.dev"
env:
- DARTDOC_BOT=main
- DARTDOC_BOT=flutter
Expand All @@ -18,7 +18,7 @@ matrix:
include:
- env: DARTDOC_BOT=main
os: osx
dart: "dev/raw/latest"
dart: "dev/raw/2.9.0-5.0.dev"

install:
- ./tool/install_travis.sh
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ branches:
- master

install:
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
- 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
- cmd: echo "Unzipping dart-sdk..."
- cmd: 7z x dart-sdk.zip -o"C:\tools" -y > nul
- cmd: del dart-sdk.zip
Expand Down
16 changes: 15 additions & 1 deletion test/model_special_cases_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ import 'package:dartdoc/dartdoc.dart';
import 'package:dartdoc/src/model/model.dart';
import 'package:dartdoc/src/special_elements.dart';
import 'package:dartdoc/src/warnings.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:test/test.dart';

import 'src/utils.dart' as utils;

final String _platformVersionString = Platform.version.split(' ').first;
final Version _platformVersion = Version.parse(_platformVersionString);

void main() {
var sdkDir = defaultSdkDir;

Expand All @@ -26,11 +30,19 @@ void main() {
exit(1);
}

// This doesn't have the `max` because NNBD is supposed to work after this
// version, and if the `max` is placed here we'll silently pass 2.10 stable
// if we haven't figured out how to switch on NNBD outside of `dev` builds
// as specified in #2148.
final _nnbdExperimentAllowed =
VersionRange(min: Version.parse('2.9.0'), includeMin: true);

// Experimental features not yet enabled by default. Move tests out of this block
// when the feature is enabled by default.
group('Experiments', () {
Library lateFinalWithoutInitializer, nnbdClassMemberDeclarations;
Class b;

setUpAll(() async {
lateFinalWithoutInitializer = (await utils.testPackageGraphExperiments)
.libraries
Expand Down Expand Up @@ -120,7 +132,9 @@ void main() {
expect(initializeMe.isLate, isTrue);
expect(initializeMe.features, contains('late'));
});
}, skip: 'dart-lang/dartdoc#2148');
},
skip: (!_nnbdExperimentAllowed.allows(_platformVersion) &&
!_platformVersionString.contains('edge')));

group('HTML Injection when allowed', () {
Class htmlInjection;
Expand Down
1 change: 1 addition & 0 deletions testing/test_package_experiments/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: test_package_experiments
version: 0.0.1
sdk: '>=2.9.0 <2.10.0'
description: Experimental flags are tested here.
49 changes: 39 additions & 10 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ Directory get flutterDir => _flutterDir ??= createTempSync('flutter');
Directory get testPackage =>
Directory(path.joinAll(['testing', 'test_package']));

Directory get testPackageExperiments =>
Directory(path.joinAll(['testing', 'test_package_experiments']));

Directory get pluginPackage =>
Directory(path.joinAll(['testing', 'test_package_flutter_plugin']));

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

Directory _testPackageExperimentsDocsDir;
Directory get testPackageExperimentsDocsDir =>
_testPackageExperimentsDocsDir ??=
createTempSync('test_package_experiments');

Directory _pluginPackageDocsDir;

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

Future<List<Map>> _buildTestPackageDocs(
String outputDir, Future<String> futureCwd,
[String label]) async {
label ??= '';
Future<List<Map>> _buildTestPackageDocs(String outputDir, String cwd,
{List<String> params, String label = '', String testPackagePath}) async {
if (label != '') label = '-$label';
testPackagePath ??= testPackage.absolute.path;
params ??= [];
var launcher = SubprocessLauncher('build-test-package-docs$label');
Future testPackagePubGet = launcher.runStreamed(sdkBin('pub'), ['get'],
workingDirectory: testPackage.absolute.path);
var cwd = await futureCwd;
workingDirectory: testPackagePath);
Future dartdocPubGet =
launcher.runStreamed(sdkBin('pub'), ['get'], workingDirectory: cwd);
await Future.wait([testPackagePubGet, dartdocPubGet]);
Expand All @@ -522,16 +529,33 @@ Future<List<Map>> _buildTestPackageDocs(
'--json',
'--link-to-remote',
'--pretty-index-json',
...params,
...extraDartdocParameters,
],
workingDirectory: testPackage.absolute.path);
workingDirectory: testPackagePath);
}

@Task('Build generated test package docs from the experiment test package')
@Depends(clean)
Future<void> buildTestExperimentsPackageDocs() async {
await _buildTestPackageDocs(
testPackageExperimentsDocsDir.absolute.path, Directory.current.path,
testPackagePath: testPackageExperiments.absolute.path,
params: ['--enable-experiment', 'non-nullable', '--no-link-to-remote']);
}

@Task('Serve experimental test package on port 8003.')
@Depends(buildTestExperimentsPackageDocs)
Future<void> serveTestExperimentsPackageDocs() async {
await _serveDocsFrom(testPackageExperimentsDocsDir.absolute.path, 8003,
'test-package-docs-experiments');
}

@Task('Build generated test package docs (with inherited docs and source code)')
@Depends(clean)
Future<void> buildTestPackageDocs() async {
await _buildTestPackageDocs(
testPackageDocsDir.absolute.path, Future.value(Directory.current.path));
testPackageDocsDir.absolute.path, Directory.current.path);
}

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

bool _serveReady = false;

Future<void> _serveDocsFrom(String servePath, int port, String context) async {
log('launching dhttpd on port $port for $context');
var launcher = SubprocessLauncher(context);
await launcher.runStreamed(sdkBin('pub'), ['get']);
await launcher.runStreamed(sdkBin('pub'), ['global', 'activate', 'dhttpd']);
if (!_serveReady) {
await launcher.runStreamed(sdkBin('pub'), ['get']);
await launcher.runStreamed(sdkBin('pub'), ['global', 'activate', 'dhttpd']);
_serveReady = true;
}
await launcher.runStreamed(
sdkBin('pub'), ['run', 'dhttpd', '--port', '$port', '--path', servePath]);
}
Expand Down