Skip to content

Commit 6af09a2

Browse files
authored
Migrate the testing/ packages (#2881)
1 parent ffd75b7 commit 6af09a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+204
-238
lines changed

analysis_options.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,21 @@ analyzer:
1414
- 'lib/src/third_party/pkg/**'
1515
- 'lib/templates/*.html'
1616
- 'pub.dartlang.org/**'
17-
- 'testing/**'
17+
# These have a lot of lint.
18+
- 'testing/test_package/**'
19+
- 'testing/test_package_custom_templates/**'
20+
- 'testing/test_package_experiments/**'
21+
- 'testing/test_package_export_error/**'
22+
- 'testing/test_package_extensions/**'
23+
- 'testing/test_package_import_export_error/**'
24+
- 'testing/test_package_imported/**'
25+
- 'testing/test_package_options/**'
26+
# This package imports flutter, which is perhaps not found by the base `dart analyze` tool.
1827
- 'testing/flutter_packages/test_package_flutter_plugin/**'
28+
# This package is meant to mock the sky_engine package.
29+
- 'testing/sky_engine/**'
30+
# These packages have compile-time errors.
31+
- 'testing/test_package_bad/**'
1932
- 'testing/test_package_export_error/**'
2033
linter:
2134
rules:

analysis_options_presubmit.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@ analyzer:
1919
- 'lib/src/third_party/pkg/**'
2020
- 'lib/templates/*.html'
2121
- 'pub.dartlang.org/**'
22-
- 'testing/**'
23-
- 'testing/flutter_packages/test_package_flutter_plugin/**'
22+
# These have a lot of lint.
23+
- 'testing/test_package/**'
24+
- 'testing/test_package_custom_templates/**'
25+
- 'testing/test_package_experiments/**'
2426
- 'testing/test_package_export_error/**'
27+
- 'testing/test_package_extensions/**'
28+
- 'testing/test_package_import_export_error/**'
29+
- 'testing/test_package_imported/**'
30+
- 'testing/test_package_options/**'
31+
# This package imports flutter, which is perhaps not found by the base `dart analyze` tool.
32+
- 'testing/flutter_packages/test_package_flutter_plugin/**'
33+
# This package is meant to mock the sky_engine package.
34+
- 'testing/sky_engine/**'
35+
# These packages have compile-time errors.
36+
- 'testing/test_package_bad/**'
2537
linter:
2638
rules:
2739
- always_declare_return_types

test/end2end/model_test.dart

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,9 @@ void main() {
936936
});
937937

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

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

33873389
test('function with a parameter having type FutureOr<Null>', () {
@@ -3417,7 +3419,7 @@ void main() {
34173419
test('has source code', () {
34183420
expect(topLevelFunction.sourceCode, startsWith('@deprecated'));
34193421
expect(topLevelFunction.sourceCode, endsWith('''
3420-
String topLevelFunction(int param1, bool param2, Cool coolBeans,
3422+
String? topLevelFunction(int param1, bool param2, Cool coolBeans,
34213423
[double optionalPositional = 0.0]) {
34223424
return null;
34233425
}'''));
@@ -3486,15 +3488,19 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
34863488
test('parameterized type from field is correctly displayed', () {
34873489
var aField = TemplatedInterface.instanceFields
34883490
.singleWhere((f) => f.name == 'aField');
3489-
expect(aField.modelType.linkedName,
3490-
'<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>');
3491+
expect(
3492+
aField.modelType.linkedName,
3493+
'<a href="${htmlBasePlaceholder}ex/AnotherParameterizedClass-class.html">AnotherParameterizedClass</a>'
3494+
'<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>?');
34913495
});
34923496

34933497
test('parameterized type from inherited field is correctly displayed', () {
34943498
var aInheritedField = TemplatedInterface.inheritedFields
34953499
.singleWhere((f) => f.name == 'aInheritedField');
3496-
expect(aInheritedField.modelType.linkedName,
3497-
'<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>');
3500+
expect(
3501+
aInheritedField.modelType.linkedName,
3502+
'<a href="${htmlBasePlaceholder}ex/AnotherParameterizedClass-class.html">AnotherParameterizedClass</a>'
3503+
'<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>?');
34983504
});
34993505

35003506
test(
@@ -3751,7 +3757,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
37513757

37523758
test('method source code indents correctly', () {
37533759
expect(convertToMap.sourceCode,
3754-
'Map&lt;X, Y&gt; convertToMap() =&gt; null;');
3760+
'Map&lt;X, Y&gt;? convertToMap() =&gt; null;');
37553761
});
37563762
});
37573763

@@ -4283,7 +4289,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
42834289
expect(
42844290
genericTypedefCombo.modelType.linkedName,
42854291
equals(
4286-
'<a href="%%__HTMLBASE_dartdoc_internal__%%fake/NewGenericTypedef.html">NewGenericTypedef</a>'));
4292+
'<a href="%%__HTMLBASE_dartdoc_internal__%%fake/NewGenericTypedef.html">NewGenericTypedef</a>?'));
42874293
});
42884294

42894295
test('Verify that final and late show up (or not) appropriately', () {
@@ -4323,7 +4329,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
43234329
expect(
43244330
complicatedReturn.modelType.linkedName,
43254331
equals(
4326-
'<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>'));
4332+
'<a href="${htmlBasePlaceholder}fake/ATypeTakingClass-class.html">ATypeTakingClass</a>'
4333+
'<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>?'));
43274334
});
43284335

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

48794886
test('param with annotations', () {
48804887
var method =
4881-
fakeLibrary.functions.firstWhere((f) => f.name == 'paintImage1');
4888+
fakeLibrary.functions.firstWhere((f) => f.name == 'paintImage2');
48824889
var params =
48834890
ParameterRendererHtml().renderLinkedParams(method.parameters);
48844891
expect(
@@ -5104,16 +5111,18 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
51045111
});
51055112

51065113
test('Property fields are terminated with semicolon', () {
5107-
expect(finalProperty.sourceCode.trim(), endsWith('List&lt;int&gt;();'));
5108-
expect(simpleProperty.sourceCode.trim(), endsWith('List&lt;int&gt;();'));
5114+
expect(finalProperty.sourceCode.trim(),
5115+
endsWith('List&lt;int&gt;.filled(1, 1);'));
5116+
expect(simpleProperty.sourceCode.trim(),
5117+
endsWith('List&lt;int&gt;.filled(1, 1);'));
51095118
expect(forInheriting.sourceCode.trim(), endsWith('forInheriting;'));
51105119
});
51115120

51125121
test('Arrow accessors are terminated with semicolon', () {
51135122
expect(explicitGetterImplicitSetter.getter.sourceCode.trim(),
5114-
endsWith('List&lt;int&gt;();'));
5123+
endsWith('List&lt;int&gt;.filled(1, 1);'));
51155124
expect(explicitGetterSetter.getter.sourceCode.trim(),
5116-
endsWith('List&lt;int&gt;();'));
5125+
endsWith('List&lt;int&gt;.filled(1, 1);'));
51175126
});
51185127

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

51255134
test('Whole declaration is visible when declaration spans many lines', () {
51265135
expect(ensureWholeDeclarationIsVisible.sourceCode,
5127-
contains('List&lt;int&gt; '));
5136+
contains('List&lt;int&gt;? '));
51285137
});
51295138
});
51305139

testing/test_package/bin/drill.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
// This is a sample "tool" used to test external tool integration into dartdoc.
86
// It has no practical purpose other than that.
97

testing/test_package/bin/print_macro.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
// This is a sample "tool" used to test external tool integration into dartdoc.
86
// It has no other purpose.
97

testing/test_package/bin/setup.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
// This is a sample setup "tool" used to test external tool integration into
86
// dartdoc. It has no practical purpose other than that.
97

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
// DO NOT give this library a name
22

3-
// @dart=2.9
4-
53
String doesStuff() => 'hi';
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
// DO NOT give this library a name
22

3-
// @dart=2.9
4-
53
String greeting() => "Hello";

testing/test_package/lib/base_class.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @dart=2.9
2-
31
library base_class;
42

53
/// Abstract class Constraints

testing/test_package/lib/code_in_comments.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@
1111
/// - 3.14
1212
/// ```
1313
14-
// @dart=2.9
15-
1614
library code_in_comments;

0 commit comments

Comments
 (0)