Skip to content

Migrate the testing/ packages #2881

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 3 commits into from
Jan 6, 2022
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
15 changes: 14 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,21 @@ analyzer:
- 'lib/src/third_party/pkg/**'
- 'lib/templates/*.html'
- 'pub.dartlang.org/**'
- 'testing/**'
# These have a lot of lint.
- 'testing/test_package/**'
- 'testing/test_package_custom_templates/**'
- 'testing/test_package_experiments/**'
- 'testing/test_package_export_error/**'
- 'testing/test_package_extensions/**'
- 'testing/test_package_import_export_error/**'
- 'testing/test_package_imported/**'
- 'testing/test_package_options/**'
# This package imports flutter, which is perhaps not found by the base `dart analyze` tool.
- 'testing/flutter_packages/test_package_flutter_plugin/**'
# This package is meant to mock the sky_engine package.
- 'testing/sky_engine/**'
# These packages have compile-time errors.
- 'testing/test_package_bad/**'
- 'testing/test_package_export_error/**'
linter:
rules:
Expand Down
16 changes: 14 additions & 2 deletions analysis_options_presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,21 @@ analyzer:
- 'lib/src/third_party/pkg/**'
- 'lib/templates/*.html'
- 'pub.dartlang.org/**'
- 'testing/**'
- 'testing/flutter_packages/test_package_flutter_plugin/**'
# These have a lot of lint.
- 'testing/test_package/**'
- 'testing/test_package_custom_templates/**'
- 'testing/test_package_experiments/**'
- 'testing/test_package_export_error/**'
- 'testing/test_package_extensions/**'
- 'testing/test_package_import_export_error/**'
- 'testing/test_package_imported/**'
- 'testing/test_package_options/**'
# This package imports flutter, which is perhaps not found by the base `dart analyze` tool.
- 'testing/flutter_packages/test_package_flutter_plugin/**'
# This package is meant to mock the sky_engine package.
- 'testing/sky_engine/**'
# These packages have compile-time errors.
- 'testing/test_package_bad/**'
linter:
rules:
- always_declare_return_types
Expand Down
41 changes: 25 additions & 16 deletions test/end2end/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,9 @@ void main() {
});

test('does not have a null safety label if not null safe', () {
expect(exLibrary.isNullSafety, isFalse);
var optOutLibrary = packageGraph.libraries
.firstWhere((lib) => lib.name == 'opt_out_of_nnbd');
expect(optOutLibrary.isNullSafety, isFalse);
});

test('has a line number and column', () {
Expand Down Expand Up @@ -3381,7 +3383,7 @@ void main() {
expect(
thisIsFutureOrT.modelType.returnType.linkedName,
equals(
'FutureOr<span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>'));
'FutureOr<span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>?'));
});

test('function with a parameter having type FutureOr<Null>', () {
Expand Down Expand Up @@ -3417,7 +3419,7 @@ void main() {
test('has source code', () {
expect(topLevelFunction.sourceCode, startsWith('@deprecated'));
expect(topLevelFunction.sourceCode, endsWith('''
String topLevelFunction(int param1, bool param2, Cool coolBeans,
String? topLevelFunction(int param1, bool param2, Cool coolBeans,
[double optionalPositional = 0.0]) {
return null;
}'''));
Expand Down Expand Up @@ -3486,15 +3488,19 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
test('parameterized type from field is correctly displayed', () {
var aField = TemplatedInterface.instanceFields
.singleWhere((f) => f.name == 'aField');
expect(aField.modelType.linkedName,
'<a href="${htmlBasePlaceholder}ex/AnotherParameterizedClass-class.html">AnotherParameterizedClass</a><span class="signature">&lt;<wbr><span class="type-parameter">Stream<span class="signature">&lt;<wbr><span class="type-parameter">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span>&gt;</span></span>&gt;</span>');
expect(
aField.modelType.linkedName,
'<a href="${htmlBasePlaceholder}ex/AnotherParameterizedClass-class.html">AnotherParameterizedClass</a>'
'<span class="signature">&lt;<wbr><span class="type-parameter">Stream<span class="signature">&lt;<wbr><span class="type-parameter">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span>&gt;</span></span>&gt;</span>?');
});

test('parameterized type from inherited field is correctly displayed', () {
var aInheritedField = TemplatedInterface.inheritedFields
.singleWhere((f) => f.name == 'aInheritedField');
expect(aInheritedField.modelType.linkedName,
'<a href="${htmlBasePlaceholder}ex/AnotherParameterizedClass-class.html">AnotherParameterizedClass</a><span class="signature">&lt;<wbr><span class="type-parameter">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span>&gt;</span>');
expect(
aInheritedField.modelType.linkedName,
'<a href="${htmlBasePlaceholder}ex/AnotherParameterizedClass-class.html">AnotherParameterizedClass</a>'
'<span class="signature">&lt;<wbr><span class="type-parameter">List<span class="signature">&lt;<wbr><span class="type-parameter">int</span>&gt;</span></span>&gt;</span>?');
});

test(
Expand Down Expand Up @@ -3751,7 +3757,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,

test('method source code indents correctly', () {
expect(convertToMap.sourceCode,
'Map&lt;X, Y&gt; convertToMap() =&gt; null;');
'Map&lt;X, Y&gt;? convertToMap() =&gt; null;');
});
});

Expand Down Expand Up @@ -4283,7 +4289,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
expect(
genericTypedefCombo.modelType.linkedName,
equals(
'<a href="%%__HTMLBASE_dartdoc_internal__%%fake/NewGenericTypedef.html">NewGenericTypedef</a>'));
'<a href="%%__HTMLBASE_dartdoc_internal__%%fake/NewGenericTypedef.html">NewGenericTypedef</a>?'));
});

test('Verify that final and late show up (or not) appropriately', () {
Expand Down Expand Up @@ -4323,7 +4329,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
expect(
complicatedReturn.modelType.linkedName,
equals(
'<a href="${htmlBasePlaceholder}fake/ATypeTakingClass-class.html">ATypeTakingClass</a><span class="signature">&lt;<wbr><span class="type-parameter">String Function<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">int</span></span>)</span></span>&gt;</span>'));
'<a href="${htmlBasePlaceholder}fake/ATypeTakingClass-class.html">ATypeTakingClass</a>'
'<span class="signature">&lt;<wbr><span class="type-parameter">String Function<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">int</span></span>)</span></span>&gt;</span>?'));
});

test('@nodoc on simple property works', () {
Expand Down Expand Up @@ -4878,7 +4885,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,

test('param with annotations', () {
var method =
fakeLibrary.functions.firstWhere((f) => f.name == 'paintImage1');
fakeLibrary.functions.firstWhere((f) => f.name == 'paintImage2');
var params =
ParameterRendererHtml().renderLinkedParams(method.parameters);
expect(
Expand Down Expand Up @@ -5104,16 +5111,18 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
});

test('Property fields are terminated with semicolon', () {
expect(finalProperty.sourceCode.trim(), endsWith('List&lt;int&gt;();'));
expect(simpleProperty.sourceCode.trim(), endsWith('List&lt;int&gt;();'));
expect(finalProperty.sourceCode.trim(),
endsWith('List&lt;int&gt;.filled(1, 1);'));
expect(simpleProperty.sourceCode.trim(),
endsWith('List&lt;int&gt;.filled(1, 1);'));
expect(forInheriting.sourceCode.trim(), endsWith('forInheriting;'));
});

test('Arrow accessors are terminated with semicolon', () {
expect(explicitGetterImplicitSetter.getter.sourceCode.trim(),
endsWith('List&lt;int&gt;();'));
endsWith('List&lt;int&gt;.filled(1, 1);'));
expect(explicitGetterSetter.getter.sourceCode.trim(),
endsWith('List&lt;int&gt;();'));
endsWith('List&lt;int&gt;.filled(1, 1);'));
});

test('Traditional accessors are not terminated with semicolon', () {
Expand All @@ -5124,7 +5133,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,

test('Whole declaration is visible when declaration spans many lines', () {
expect(ensureWholeDeclarationIsVisible.sourceCode,
contains('List&lt;int&gt; '));
contains('List&lt;int&gt;? '));
});
});

Expand Down
2 changes: 0 additions & 2 deletions testing/test_package/bin/drill.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

// This is a sample "tool" used to test external tool integration into dartdoc.
// It has no practical purpose other than that.

Expand Down
2 changes: 0 additions & 2 deletions testing/test_package/bin/print_macro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

// This is a sample "tool" used to test external tool integration into dartdoc.
// It has no other purpose.

Expand Down
2 changes: 0 additions & 2 deletions testing/test_package/bin/setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

// This is a sample setup "tool" used to test external tool integration into
// dartdoc. It has no practical purpose other than that.

Expand Down
2 changes: 0 additions & 2 deletions testing/test_package/lib/anonymous_library.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// DO NOT give this library a name

// @dart=2.9

String doesStuff() => 'hi';
2 changes: 0 additions & 2 deletions testing/test_package/lib/another_anonymous_lib.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// DO NOT give this library a name

// @dart=2.9

String greeting() => "Hello";
2 changes: 0 additions & 2 deletions testing/test_package/lib/base_class.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @dart=2.9

library base_class;

/// Abstract class Constraints
Expand Down
2 changes: 0 additions & 2 deletions testing/test_package/lib/code_in_comments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
/// - 3.14
/// ```

// @dart=2.9

library code_in_comments;
2 changes: 1 addition & 1 deletion testing/test_package/lib/completely_empty_lib.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// @dart=2.9

2 changes: 0 additions & 2 deletions testing/test_package/lib/css.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
/// with directories created by dartdoc.
/// {@category Other}

// @dart=2.9

library css;

String theOnlyThingInTheLibrary = 'hello';
2 changes: 0 additions & 2 deletions testing/test_package/lib/csspub.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @dart=2.9

library csspub;

String theOnlyThingInTheLibrary = 'hello';
Loading