@@ -34,6 +34,7 @@ void main() {
34
34
expect (value.screenshots, isEmpty);
35
35
expect (value.workspace, isNull);
36
36
expect (value.resolution, isNull);
37
+ expect (value.executables, isEmpty);
37
38
});
38
39
39
40
test ('all fields set' , () async {
@@ -64,6 +65,10 @@ void main() {
64
65
'pkg2' ,
65
66
],
66
67
'resolution' : 'workspace' ,
68
+ 'executables' : {
69
+ 'my_script' : 'bin/my_script.dart' ,
70
+ 'my_script2' : 'bin/my_script2.dart' ,
71
+ },
67
72
},
68
73
skipTryPub: true ,
69
74
);
@@ -96,6 +101,11 @@ void main() {
96
101
expect (value.screenshots, hasLength (1 ));
97
102
expect (value.screenshots! .first.description, 'my screenshot' );
98
103
expect (value.screenshots! .first.path, 'path/to/screenshot' );
104
+ expect (value.executables, hasLength (2 ));
105
+ expect (value.executables.keys, contains ('my_script' ));
106
+ expect (value.executables.keys, contains ('my_script2' ));
107
+ expect (value.executables['my_script' ], 'bin/my_script.dart' );
108
+ expect (value.executables['my_script2' ], 'bin/my_script2.dart' );
99
109
expect (value.workspace, hasLength (2 ));
100
110
expect (value.workspace! .first, 'pkg1' );
101
111
expect (value.workspace! .last, 'pkg2' );
@@ -222,6 +232,58 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https
222
232
});
223
233
});
224
234
235
+ group ('executables' , () {
236
+ test ('one executable' , () async {
237
+ final value = await parse ({
238
+ ...defaultPubspec,
239
+ 'executables' : {'my_script' : 'bin/my_script.dart' },
240
+ });
241
+ expect (value.executables, hasLength (1 ));
242
+ expect (value.executables.keys, contains ('my_script' ));
243
+ expect (value.executables['my_script' ], 'bin/my_script.dart' );
244
+ });
245
+
246
+ test ('many executables' , () async {
247
+ final value = await parse ({
248
+ ...defaultPubspec,
249
+ 'executables' : {
250
+ 'my_script' : 'bin/my_script.dart' ,
251
+ 'my_script2' : 'bin/my_script2.dart' ,
252
+ },
253
+ });
254
+ expect (value.executables, hasLength (2 ));
255
+ expect (value.executables.keys, contains ('my_script' ));
256
+ expect (value.executables.keys, contains ('my_script2' ));
257
+ expect (value.executables['my_script' ], 'bin/my_script.dart' );
258
+ expect (value.executables['my_script2' ], 'bin/my_script2.dart' );
259
+ });
260
+
261
+ test ('invalid value' , () async {
262
+ expectParseThrowsContaining (
263
+ {
264
+ ...defaultPubspec,
265
+ 'executables' : {
266
+ 'script' : 32 ,
267
+ },
268
+ },
269
+ 'Unsupported value for "script". `32` is not a String.' ,
270
+ skipTryPub: true ,
271
+ );
272
+ });
273
+
274
+ test ('invalid executable - lenient' , () async {
275
+ final value = await parse (
276
+ {
277
+ ...defaultPubspec,
278
+ 'executables' : 'Invalid value' ,
279
+ },
280
+ lenient: true ,
281
+ );
282
+ expect (value.name, 'sample' );
283
+ expect (value.executables, isEmpty);
284
+ });
285
+ });
286
+
225
287
group ('invalid' , () {
226
288
test ('null' , () {
227
289
expectParseThrows (
0 commit comments