Skip to content

Commit 86a4b81

Browse files
committed
Moving tests that are supposed to create errors into a separate package.
1 parent bb3e5d2 commit 86a4b81

File tree

103 files changed

+166
-3211
lines changed

Some content is hidden

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

103 files changed

+166
-3211
lines changed

test/model_test.dart

Lines changed: 99 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ void main() {
5353

5454
PackageGraph packageGraph;
5555
PackageGraph packageGraphSmall;
56+
PackageGraph packageGraphErrors;
5657
PackageGraph ginormousPackageGraph;
5758
Library exLibrary;
5859
Library fakeLibrary;
60+
Library errorLibrary;
5961
Library twoExportsLib;
6062
Library interceptorsLib;
6163
PackageGraph sdkAsPackageGraph;
@@ -65,8 +67,11 @@ void main() {
6567
await utils.init();
6668
packageGraph = utils.testPackageGraph;
6769
packageGraphSmall = utils.testPackageGraphSmall;
70+
packageGraphErrors = utils.testPackageGraphErrors;
6871
ginormousPackageGraph = utils.testPackageGraphGinormous;
6972
exLibrary = packageGraph.libraries.firstWhere((lib) => lib.name == 'ex');
73+
errorLibrary = packageGraphErrors.libraries
74+
.firstWhere((lib) => lib.name == 'doc_errors');
7075
fakeLibrary =
7176
packageGraph.libraries.firstWhere((lib) => lib.name == 'fake');
7277
dartAsync =
@@ -97,10 +102,8 @@ void main() {
97102
invokeTool.documentation,
98103
contains(
99104
new RegExp(r'--source=lib[/\\]example\.dart_[0-9]+_[0-9]+, ')));
100-
expect(
101-
invokeTool.documentation,
102-
contains(new RegExp(
103-
r'--package-path=<PACKAGE_PATH>, ')));
105+
expect(invokeTool.documentation,
106+
contains(new RegExp(r'--package-path=<PACKAGE_PATH>, ')));
104107
expect(
105108
invokeTool.documentation, contains('--package-name=test_package, '));
106109
expect(invokeTool.documentation, contains('--library-name=ex, '));
@@ -115,10 +118,8 @@ void main() {
115118
contains(new RegExp('SOURCE_COLUMN: [0-9]+, ')));
116119
expect(invokeTool.documentation,
117120
contains(new RegExp(r'SOURCE_PATH: lib[/\\]example\.dart, ')));
118-
expect(
119-
invokeTool.documentation,
120-
contains(new RegExp(
121-
r'PACKAGE_PATH: <PACKAGE_PATH>, ')));
121+
expect(invokeTool.documentation,
122+
contains(new RegExp(r'PACKAGE_PATH: <PACKAGE_PATH>, ')));
122123
expect(
123124
invokeTool.documentation, contains('PACKAGE_NAME: test_package, '));
124125
expect(invokeTool.documentation, contains('LIBRARY_NAME: ex, '));
@@ -731,99 +732,50 @@ void main() {
731732
});
732733
});
733734

734-
group('Animation', () {
735-
Class dog;
736-
Method withAnimation;
737-
Method withNamedAnimation;
738-
Method withQuoteNamedAnimation;
735+
group('Animation Errors', () {
736+
Class documentationErrors;
739737
Method withInvalidNamedAnimation;
740-
Method withDeprecatedAnimation;
741738
Method withAnimationNonUnique;
742739
Method withAnimationNonUniqueDeprecated;
743740
Method withAnimationWrongParams;
744741
Method withAnimationBadWidth;
745742
Method withAnimationBadHeight;
746-
Method withAnimationInOneLineDoc;
747-
Method withAnimationInline;
748-
Method withAnimationOutOfOrder;
749743
Method withAnimationUnknownArg;
750744

751745
setUp(() {
752-
dog = exLibrary.classes.firstWhere((c) => c.name == 'Dog');
753-
withAnimation =
754-
dog.allInstanceMethods.firstWhere((m) => m.name == 'withAnimation');
755-
withNamedAnimation = dog.allInstanceMethods
756-
.firstWhere((m) => m.name == 'withNamedAnimation');
757-
withQuoteNamedAnimation = dog.allInstanceMethods
758-
.firstWhere((m) => m.name == 'withQuotedNamedAnimation');
759-
withInvalidNamedAnimation = dog.allInstanceMethods
746+
documentationErrors = errorLibrary.classes
747+
.firstWhere((c) => c.name == 'DocumentationErrors');
748+
withInvalidNamedAnimation = documentationErrors.allInstanceMethods
760749
.firstWhere((m) => m.name == 'withInvalidNamedAnimation');
761-
withDeprecatedAnimation = dog.allInstanceMethods
762-
.firstWhere((m) => m.name == 'withDeprecatedAnimation');
763-
withAnimationNonUnique = dog.allInstanceMethods
750+
withAnimationNonUnique = documentationErrors.allInstanceMethods
764751
.firstWhere((m) => m.name == 'withAnimationNonUnique');
765-
withAnimationNonUniqueDeprecated = dog.allInstanceMethods
752+
withAnimationNonUniqueDeprecated = documentationErrors.allInstanceMethods
766753
.firstWhere((m) => m.name == 'withAnimationNonUniqueDeprecated');
767-
withAnimationWrongParams = dog.allInstanceMethods
754+
withAnimationWrongParams = documentationErrors.allInstanceMethods
768755
.firstWhere((m) => m.name == 'withAnimationWrongParams');
769-
withAnimationBadWidth = dog.allInstanceMethods
756+
withAnimationBadWidth = documentationErrors.allInstanceMethods
770757
.firstWhere((m) => m.name == 'withAnimationBadWidth');
771-
withAnimationBadHeight = dog.allInstanceMethods
758+
withAnimationBadHeight = documentationErrors.allInstanceMethods
772759
.firstWhere((m) => m.name == 'withAnimationBadHeight');
773-
withAnimationInOneLineDoc = dog.allInstanceMethods
774-
.firstWhere((m) => m.name == 'withAnimationInOneLineDoc');
775-
withAnimationInline = dog.allInstanceMethods
776-
.firstWhere((m) => m.name == 'withAnimationInline');
777-
withAnimationOutOfOrder = dog.allInstanceMethods
778-
.firstWhere((m) => m.name == 'withAnimationOutOfOrder');
779-
withAnimationUnknownArg = dog.allInstanceMethods
760+
withAnimationUnknownArg = documentationErrors.allInstanceMethods
780761
.firstWhere((m) => m.name == 'withAnimationUnknownArg');
781-
packageGraph.allLocalModelElements.forEach((m) => m.documentation);
762+
packageGraphErrors.allLocalModelElements.forEach((m) => m.documentation);
782763
});
783764

784-
test("renders an unnamed animation within the method documentation", () {
785-
expect(withAnimation.documentation, contains('<video id="animation_1"'));
786-
});
787-
test("renders a named animation within the method documentation", () {
788-
expect(withNamedAnimation.documentation,
789-
contains('<video id="namedAnimation"'));
790-
});
791-
test("renders a quoted, named animation within the method documentation",
792-
() {
793-
expect(withQuoteNamedAnimation.documentation,
794-
contains('<video id="quotedNamedAnimation"'));
795-
expect(withQuoteNamedAnimation.documentation,
796-
contains('<video id="quotedNamedAnimation2"'));
797-
});
798765
test("warns with invalidly-named animation within the method documentation",
799766
() {
800767
expect(
801-
packageGraph.packageWarningCounter.hasWarning(
768+
packageGraphErrors.packageWarningCounter.hasWarning(
802769
withInvalidNamedAnimation,
803770
PackageWarning.invalidParameter,
804771
'An animation has an invalid identifier, "2isNot-A-ValidName". '
805772
'The identifier can only contain letters, numbers and '
806773
'underscores, and must not begin with a number.'),
807774
isTrue);
808775
});
809-
test("renders a deprecated-form animation within the method documentation",
810-
() {
811-
expect(withDeprecatedAnimation.documentation,
812-
contains('<video id="deprecatedAnimation"'));
813-
expect(
814-
packageGraph.packageWarningCounter.hasWarning(
815-
withDeprecatedAnimation,
816-
PackageWarning.deprecated,
817-
'Deprecated form of @animation directive, '
818-
'"{@animation deprecatedAnimation 100 100 http://host/path/to/video.mp4}"\n'
819-
'Animation directives are now of the form "{@animation '
820-
'WIDTH HEIGHT URL [id=ID]}" (id is an optional '
821-
'parameter)'),
822-
isTrue);
823-
});
824776
test("warns on a non-unique animation name within a method", () {
825777
expect(
826-
packageGraph.packageWarningCounter.hasWarning(
778+
packageGraphErrors.packageWarningCounter.hasWarning(
827779
withAnimationNonUnique,
828780
PackageWarning.invalidParameter,
829781
'An animation has a non-unique identifier, "barHerderAnimation". '
@@ -833,7 +785,7 @@ void main() {
833785
test("warns on a non-unique animation name within a deprecated-form method",
834786
() {
835787
expect(
836-
packageGraph.packageWarningCounter.hasWarning(
788+
packageGraphErrors.packageWarningCounter.hasWarning(
837789
withAnimationNonUniqueDeprecated,
838790
PackageWarning.invalidParameter,
839791
'An animation has a non-unique identifier, "fooHerderAnimation". '
@@ -842,7 +794,7 @@ void main() {
842794
});
843795
test("warns on animation with missing parameters", () {
844796
expect(
845-
packageGraph.packageWarningCounter.hasWarning(
797+
packageGraphErrors.packageWarningCounter.hasWarning(
846798
withAnimationWrongParams,
847799
PackageWarning.invalidParameter,
848800
'Invalid @animation directive, "{@animation http://host/path/to/video.mp4}"\n'
@@ -852,7 +804,7 @@ void main() {
852804
});
853805
test("warns on animation with non-integer width", () {
854806
expect(
855-
packageGraph.packageWarningCounter.hasWarning(
807+
packageGraphErrors.packageWarningCounter.hasWarning(
856808
withAnimationBadWidth,
857809
PackageWarning.invalidParameter,
858810
'An animation has an invalid width (badWidthAnimation), "100px". '
@@ -861,13 +813,82 @@ void main() {
861813
});
862814
test("warns on animation with non-integer height", () {
863815
expect(
864-
packageGraph.packageWarningCounter.hasWarning(
816+
packageGraphErrors.packageWarningCounter.hasWarning(
865817
withAnimationBadHeight,
866818
PackageWarning.invalidParameter,
867819
'An animation has an invalid height (badHeightAnimation), '
868820
'"100px". The height must be an integer.'),
869821
isTrue);
870822
});
823+
test("Unknown arguments generate an error.", () {
824+
expect(
825+
packageGraphErrors.packageWarningCounter.hasWarning(
826+
withAnimationUnknownArg,
827+
PackageWarning.invalidParameter,
828+
'The {@animation ...} directive was called with invalid '
829+
'parameters. FormatException: Could not find an option named "name".'),
830+
isTrue);
831+
});
832+
});
833+
834+
group('Animation', () {
835+
Class dog;
836+
Method withAnimation;
837+
Method withNamedAnimation;
838+
Method withQuoteNamedAnimation;
839+
Method withDeprecatedAnimation;
840+
Method withAnimationInOneLineDoc;
841+
Method withAnimationInline;
842+
Method withAnimationOutOfOrder;
843+
844+
setUp(() {
845+
dog = exLibrary.classes.firstWhere((c) => c.name == 'Dog');
846+
withAnimation =
847+
dog.allInstanceMethods.firstWhere((m) => m.name == 'withAnimation');
848+
withNamedAnimation = dog.allInstanceMethods
849+
.firstWhere((m) => m.name == 'withNamedAnimation');
850+
withQuoteNamedAnimation = dog.allInstanceMethods
851+
.firstWhere((m) => m.name == 'withQuotedNamedAnimation');
852+
withDeprecatedAnimation = dog.allInstanceMethods
853+
.firstWhere((m) => m.name == 'withDeprecatedAnimation');
854+
withAnimationInOneLineDoc = dog.allInstanceMethods
855+
.firstWhere((m) => m.name == 'withAnimationInOneLineDoc');
856+
withAnimationInline = dog.allInstanceMethods
857+
.firstWhere((m) => m.name == 'withAnimationInline');
858+
withAnimationOutOfOrder = dog.allInstanceMethods
859+
.firstWhere((m) => m.name == 'withAnimationOutOfOrder');
860+
packageGraph.allLocalModelElements.forEach((m) => m.documentation);
861+
});
862+
863+
test("renders an unnamed animation within the method documentation", () {
864+
expect(withAnimation.documentation, contains('<video id="animation_1"'));
865+
});
866+
test("renders a named animation within the method documentation", () {
867+
expect(withNamedAnimation.documentation,
868+
contains('<video id="namedAnimation"'));
869+
});
870+
test("renders a quoted, named animation within the method documentation",
871+
() {
872+
expect(withQuoteNamedAnimation.documentation,
873+
contains('<video id="quotedNamedAnimation"'));
874+
expect(withQuoteNamedAnimation.documentation,
875+
contains('<video id="quotedNamedAnimation2"'));
876+
});
877+
test("renders a deprecated-form animation within the method documentation",
878+
() {
879+
expect(withDeprecatedAnimation.documentation,
880+
contains('<video id="deprecatedAnimation"'));
881+
expect(
882+
packageGraph.packageWarningCounter.hasWarning(
883+
withDeprecatedAnimation,
884+
PackageWarning.deprecated,
885+
'Deprecated form of @animation directive, '
886+
'"{@animation deprecatedAnimation 100 100 http://host/path/to/video.mp4}"\n'
887+
'Animation directives are now of the form "{@animation '
888+
'WIDTH HEIGHT URL [id=ID]}" (id is an optional '
889+
'parameter)'),
890+
isTrue);
891+
});
871892
test("Doesn't place animations in one line doc", () {
872893
expect(withAnimationInOneLineDoc.oneLineDoc, isNot(contains('<video')));
873894
expect(withAnimationInOneLineDoc.documentation, contains('<video'));
@@ -881,15 +902,6 @@ void main() {
881902
expect(withAnimationOutOfOrder.documentation,
882903
contains('<video id="outOfOrder"'));
883904
});
884-
test("Unknown arguments generate an error.", () {
885-
expect(
886-
packageGraph.packageWarningCounter.hasWarning(
887-
withAnimationUnknownArg,
888-
PackageWarning.invalidParameter,
889-
'The {@animation ...} directive was called with invalid '
890-
'parameters. FormatException: Could not find an option named "name".'),
891-
isTrue);
892-
});
893905
});
894906

895907
group('MultiplyInheritedExecutableElement handling', () {
@@ -1570,7 +1582,7 @@ void main() {
15701582
});
15711583

15721584
test('get methods', () {
1573-
expect(Dog.publicInstanceMethods, hasLength(26));
1585+
expect(Dog.publicInstanceMethods, hasLength(19));
15741586
});
15751587

15761588
test('get operators', () {
@@ -1636,23 +1648,16 @@ void main() {
16361648
'testMethod',
16371649
'toString',
16381650
'withAnimation',
1639-
'withAnimationBadHeight',
1640-
'withAnimationBadWidth',
16411651
'withAnimationInline',
1652+
'withAnimationOutOfOrder',
16421653
'withAnimationInOneLineDoc',
1643-
'withAnimationNonUnique',
1644-
'withAnimationNonUniqueDeprecated',
1645-
'withAnimationWrongParams',
16461654
'withDeprecatedAnimation',
1647-
'withInvalidNamedAnimation',
16481655
'withMacro',
16491656
'withMacro2',
16501657
'withNamedAnimation',
16511658
'withPrivateMacro',
16521659
'withQuotedNamedAnimation',
1653-
'withUndefinedMacro',
1654-
'withAnimationOutOfOrder',
1655-
'withAnimationUnknownArg',
1660+
'withUndefinedMacro'
16561661
]));
16571662
});
16581663

test/src/utils.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PackageMeta sdkPackageMeta;
1717
PackageGraph testPackageGraph;
1818
PackageGraph testPackageGraphGinormous;
1919
PackageGraph testPackageGraphSmall;
20+
PackageGraph testPackageGraphErrors;
2021
PackageGraph testPackageGraphSdk;
2122

2223
final Directory testPackageBadDir = new Directory('testing/test_package_bad');
@@ -78,6 +79,10 @@ void init({List<String> additionalArguments}) async {
7879
testPackageGraphSmall = await bootBasicPackage(
7980
'testing/test_package_small', [],
8081
additionalArguments: additionalArguments);
82+
83+
testPackageGraphErrors = await bootBasicPackage(
84+
'testing/test_package_doc_errors', ['css', 'code_in_comments', 'excluded'],
85+
additionalArguments: additionalArguments);
8186
testPackageGraphSdk = await bootSdkPackage();
8287
}
8388

0 commit comments

Comments
 (0)