Skip to content

Commit ee20156

Browse files
authored
Support latest package:build (#278)
Update to `build_test` v 0.9.0 and update tests to use `decodedMatches`
1 parent b131681 commit ee20156

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.7.2+1
2+
3+
* Allow `package:build` version 0.11.0
4+
15
## 0.7.2
26

37
* Support an optional `header` argument to `PartBuilder` and `LibraryBuilder`.

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
name: source_gen
2-
version: 0.7.2
2+
version: 0.7.2+1
33
author: Dart Team <[email protected]>
44
description: Automated source code generation for Dart.
55
homepage: https://github.com/dart-lang/source_gen
66
environment:
77
sdk: '>=1.22.1 <2.0.0'
88
dependencies:
99
analyzer: '>=0.29.10 <0.31.0'
10-
build: ^0.10.0
10+
build: '>=0.10.0 <0.12.0'
1111
dart_style: '>=0.1.7 <2.0.0'
1212
meta: ^1.1.0
1313
path: ^1.3.2
1414
source_span: ^1.4.0
1515
dev_dependencies:
16-
build_test: '>=0.7.0 <0.9.0'
16+
build_test: ^0.9.0
1717
collection: ^1.1.2
1818
cli_util: '>=0.1.0 <0.2.0'
1919
logging: ^0.11.3

test/builder_test.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ void main() {
2626
await testBuilder(builder, srcs,
2727
generateFor: new Set.from(['$pkgName|lib/test_lib.dart']),
2828
outputs: {
29-
'$pkgName|lib/test_lib.g.dart': contains('not valid code!'),
29+
'$pkgName|lib/test_lib.g.dart':
30+
decodedMatches(contains('not valid code!')),
3031
});
3132
});
3233

@@ -48,7 +49,7 @@ void main() {
4849
generateFor: new Set.from(['$pkgName|lib/test_lib.dart']),
4950
outputs: {
5051
'$pkgName|lib/test_lib.g.dart':
51-
startsWith(_customHeader + '\n\n// ***')
52+
decodedMatches(startsWith(_customHeader + '\n\n// ***'))
5253
});
5354
});
5455

@@ -57,7 +58,9 @@ void main() {
5758
var builder = new LibraryBuilder(const CommentGenerator(), header: '');
5859
await testBuilder(builder, srcs,
5960
generateFor: new Set.from(['$pkgName|lib/test_lib.dart']),
60-
outputs: {'$pkgName|lib/test_lib.g.dart': startsWith('// ***')});
61+
outputs: {
62+
'$pkgName|lib/test_lib.g.dart': decodedMatches(startsWith('// ***'))
63+
});
6164
});
6265

6366
test('Expect no error when multiple generators used on nonstandalone builder',
@@ -142,7 +145,7 @@ void main() {
142145
generateFor: new Set.from(['$pkgName|lib/a.dart']),
143146
outputs: {
144147
'$pkgName|lib/a.g.dart':
145-
contains(UnformattedCodeGenerator.formattedCode),
148+
decodedMatches(contains(UnformattedCodeGenerator.formattedCode)),
146149
});
147150
});
148151

@@ -153,7 +156,8 @@ void main() {
153156
{'$pkgName|lib/a.dart': 'library a; part "a.part.dart";'},
154157
generateFor: new Set.from(['$pkgName|lib/a.dart']),
155158
outputs: {
156-
'$pkgName|lib/a.g.dart': startsWith(_customHeader + '\npart of'),
159+
'$pkgName|lib/a.g.dart':
160+
decodedMatches(startsWith(_customHeader + '\npart of')),
157161
});
158162
});
159163

@@ -163,7 +167,7 @@ void main() {
163167
{'$pkgName|lib/a.dart': 'library a; part "a.part.dart";'},
164168
generateFor: new Set.from(['$pkgName|lib/a.dart']),
165169
outputs: {
166-
'$pkgName|lib/a.g.dart': startsWith('part of'),
170+
'$pkgName|lib/a.g.dart': decodedMatches(startsWith('part of')),
167171
});
168172
});
169173

@@ -174,8 +178,8 @@ void main() {
174178
{'$pkgName|lib/a.dart': 'library a; part "a.part.dart";'},
175179
generateFor: new Set.from(['$pkgName|lib/a.dart']),
176180
outputs: {
177-
'$pkgName|lib/a.g.dart':
178-
contains(UnformattedCodeGenerator.unformattedCode),
181+
'$pkgName|lib/a.g.dart': decodedMatches(
182+
contains(UnformattedCodeGenerator.unformattedCode)),
179183
});
180184
});
181185

@@ -187,7 +191,7 @@ void main() {
187191
{'$pkgName|lib/a.dart': 'library a; part "a.part.dart";'},
188192
generateFor: new Set.from(['$pkgName|lib/a.dart']),
189193
outputs: {
190-
'$pkgName|lib/a.g.dart': contains(customOutput),
194+
'$pkgName|lib/a.g.dart': decodedMatches(contains(customOutput)),
191195
});
192196
});
193197

@@ -209,7 +213,7 @@ Future _generateTest(CommentGenerator gen, String expectedContent) async {
209213
await testBuilder(builder, srcs,
210214
generateFor: new Set.from(['$pkgName|lib/test_lib.dart']),
211215
outputs: {
212-
'$pkgName|lib/test_lib.g.dart': expectedContent,
216+
'$pkgName|lib/test_lib.g.dart': decodedMatches(expectedContent),
213217
},
214218
onLog: (log) => fail('Unexpected log message: ${log.message}'));
215219
}

0 commit comments

Comments
 (0)