@@ -137,6 +137,13 @@ pub struct DownstreamTest {
137137 pub downstream : String ,
138138}
139139
140+ /// A test that checks if R libraries can be loaded
141+ #[ derive( Default , Debug , Clone , PartialEq , Serialize , Deserialize ) ]
142+ pub struct RTest {
143+ /// List of R libraries to test with library()
144+ pub libraries : Vec < String > ,
145+ }
146+
140147/// The test type enum
141148#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
142149#[ serde( untagged) ]
@@ -151,6 +158,11 @@ pub enum TestType {
151158 /// The modules to test
152159 perl : PerlTest ,
153160 } ,
161+ /// An R test that will test if the R libraries can be loaded
162+ R {
163+ /// The R libraries to load and test
164+ r : RTest ,
165+ } ,
154166 /// A test that executes multiple commands in a freshly created environment
155167 Command ( CommandsTest ) ,
156168 /// A test that runs the tests of a downstream package
@@ -247,9 +259,9 @@ impl TryConvertNode<TestType> for RenderedMappingNode {
247259 match key_str {
248260 "python" => {
249261 let python = as_mapping ( value, key_str) ?. try_convert ( key_str) ?;
250- test = TestType :: Python { python } ;
262+ test = TestType :: Python { python } ;
251263 }
252- "script" | "requirements" | "files" => {
264+ "script" | "requirements" | "files" => {
253265 let commands = self . try_convert ( key_str) ?;
254266 test = TestType :: Command ( commands) ;
255267 }
@@ -265,10 +277,14 @@ impl TryConvertNode<TestType> for RenderedMappingNode {
265277 let perl = as_mapping ( value, key_str) ?. try_convert ( key_str) ?;
266278 test = TestType :: Perl { perl } ;
267279 }
280+ "r" => {
281+ let rscript = as_mapping ( value, key_str) ?. try_convert ( key_str) ?;
282+ test = TestType :: R { r : rscript } ;
283+ }
268284 invalid => Err ( vec ! [ _partialerror!(
269285 * key. span( ) ,
270286 ErrorKind :: InvalidField ( invalid. to_string( ) . into( ) ) ,
271- help = format!( "expected fields for {name} is one of `python`, `perl`, `script`, `downstream`, `package_contents`" )
287+ help = format!( "expected fields for {name} is one of `python`, `perl`, `r`, ` script`, `downstream`, `package_contents`" )
272288 ) ] ) ?
273289 }
274290 Ok ( ( ) )
@@ -414,6 +430,24 @@ impl TryConvertNode<PerlTest> for RenderedMappingNode {
414430 }
415431}
416432
433+ ///////////////////////////
434+ /// R Test ///
435+ ///////////////////////////
436+ impl TryConvertNode < RTest > for RenderedMappingNode {
437+ fn try_convert ( & self , _name : & str ) -> Result < RTest , Vec < PartialParsingError > > {
438+ let mut rtest = RTest :: default ( ) ;
439+ validate_keys ! ( rtest, self . iter( ) , libraries) ;
440+ if rtest. libraries . is_empty ( ) {
441+ Err ( vec ! [ _partialerror!(
442+ * self . span( ) ,
443+ ErrorKind :: MissingField ( "libraries" . into( ) ) ,
444+ help = "expected field `libraries` in R test to be a list of strings."
445+ ) ] ) ?;
446+ }
447+ Ok ( rtest)
448+ }
449+ }
450+
417451///////////////////////////
418452/// Package Contents ///
419453///////////////////////////
0 commit comments