@@ -7,6 +7,7 @@ use spk_schema_foundation::{option_map, pkg_name, FromYaml, IsDefault};
7
7
8
8
use super :: { AutoHostVars , BuildSpec } ;
9
9
use crate :: build_spec:: UncheckedBuildSpec ;
10
+ use crate :: LintedItem ;
10
11
11
12
#[ rstest]
12
13
fn test_auto_host_vars_default ( ) {
@@ -223,3 +224,127 @@ options:
223
224
. unwrap ( ) ;
224
225
assert_ne ! ( build_id1, build_id2) ;
225
226
}
227
+
228
+ #[ rstest]
229
+ fn test_build_script_lint ( ) {
230
+ let build_spec: LintedItem < UncheckedBuildSpec > = serde_yaml:: from_str (
231
+ r#"
232
+ options:
233
+ - var: arch
234
+ - var: os
235
+ - var: centos
236
+ - pkg: python/3
237
+ variants:
238
+ - {python: 2.7}
239
+ - {python: 3.7, gcc: 9.3}
240
+ scripts:
241
+ - echo "Hello World!"
242
+ "# ,
243
+ )
244
+ . unwrap ( ) ;
245
+
246
+ assert_eq ! ( build_spec. lints. len( ) , 1 ) ;
247
+ for lint in build_spec. lints . iter ( ) {
248
+ assert_eq ! ( lint. get_key( ) , "build.scripts" ) ;
249
+ }
250
+ }
251
+
252
+ #[ rstest]
253
+ fn test_build_variant_lint ( ) {
254
+ let build_spec: LintedItem < UncheckedBuildSpec > = serde_yaml:: from_str (
255
+ r#"
256
+ options:
257
+ - var: arch
258
+ - var: os
259
+ - var: centos
260
+ - pkg: python/3
261
+ variant:
262
+ - {python: 2.7}
263
+ - {python: 3.7, gcc: 9.3}
264
+ script:
265
+ - echo "Hello World!"
266
+ "# ,
267
+ )
268
+ . unwrap ( ) ;
269
+
270
+ assert_eq ! ( build_spec. lints. len( ) , 1 ) ;
271
+ for lint in build_spec. lints . iter ( ) {
272
+ assert_eq ! ( lint. get_key( ) , "build.variant" ) ;
273
+ }
274
+ }
275
+
276
+ #[ rstest]
277
+ fn test_build_options_lint ( ) {
278
+ let build_spec: LintedItem < UncheckedBuildSpec > = serde_yaml:: from_str (
279
+ r#"
280
+ option:
281
+ - var: arch
282
+ - var: os
283
+ - var: centos
284
+ - pkg: python/3
285
+ variants:
286
+ - {python: 2.7}
287
+ - {python: 3.7, gcc: 9.3}
288
+ script:
289
+ - echo "Hello World!"
290
+ "# ,
291
+ )
292
+ . unwrap ( ) ;
293
+
294
+ assert_eq ! ( build_spec. lints. len( ) , 1 ) ;
295
+ for lint in build_spec. lints . iter ( ) {
296
+ assert_eq ! ( lint. get_key( ) , "build.option" ) ;
297
+ }
298
+ }
299
+
300
+ #[ rstest]
301
+ fn test_build_auto_host_vars_lint ( ) {
302
+ let build_spec: LintedItem < UncheckedBuildSpec > = serde_yaml:: from_str (
303
+ r#"
304
+ options:
305
+ - var: arch
306
+ - var: os
307
+ - var: centos
308
+ - pkg: python/3
309
+ variants:
310
+ - {python: 2.7}
311
+ - {python: 3.7, gcc: 9.3}
312
+ script:
313
+ - echo "Hello World!"
314
+ auto_host_var: "None"
315
+ "# ,
316
+ )
317
+ . unwrap ( ) ;
318
+
319
+ assert_eq ! ( build_spec. lints. len( ) , 1 ) ;
320
+ for lint in build_spec. lints . iter ( ) {
321
+ assert_eq ! ( lint. get_key( ) , "build.auto_host_var" ) ;
322
+ }
323
+ }
324
+
325
+ #[ rstest]
326
+ fn test_build_validation_lint ( ) {
327
+ let build_spec: LintedItem < UncheckedBuildSpec > = serde_yaml:: from_str (
328
+ r#"
329
+ options:
330
+ - var: arch
331
+ - var: os
332
+ - var: centos
333
+ - pkg: python/3
334
+ variants:
335
+ - {python: 2.7}
336
+ - {python: 3.7, gcc: 9.3}
337
+ script:
338
+ - echo "Hello World!"
339
+ validations: {
340
+ "rules": [{"allow": "EmptyPackage"}]
341
+ }
342
+ "# ,
343
+ )
344
+ . unwrap ( ) ;
345
+
346
+ assert_eq ! ( build_spec. lints. len( ) , 1 ) ;
347
+ for lint in build_spec. lints . iter ( ) {
348
+ assert_eq ! ( lint. get_key( ) , "build.validations" ) ;
349
+ }
350
+ }
0 commit comments