@@ -30,33 +30,49 @@ use anyhow::Context;
3030use anyhow:: Result ;
3131use serde:: de:: DeserializeOwned ;
3232use serde:: Deserialize ;
33+ use std:: collections:: HashMap ;
3334
3435/// Configuration that can be placed at the top of runtime tests in source
35- /// language files. This is currently language-agnostic.
36+ /// language files.
37+ ///
38+ /// This is a union of language-agnostic and language-specific configuration.
39+ /// Language-agnostic configuration can be bindings generator arguments:
40+ ///
41+ /// ```toml
42+ /// args = '--foo --bar'
43+ /// # or ...
44+ /// args = ['--foo', '--bar']
45+ /// ```
46+ ///
47+ /// but languages may each have their own configuration:
48+ ///
49+ /// ```toml
50+ /// [lang]
51+ /// rustflags = '-O'
52+ /// ```
53+ ///
54+ /// The `Component::deserialize_lang_config` helper is used to deserialize the
55+ /// `lang` field here.
3656#[ derive( Default , Deserialize ) ]
3757#[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
38- pub struct RuntimeTestConfig {
58+ pub struct RuntimeTestConfig < T = HashMap < String , toml :: Value > > {
3959 /// Extra command line arguments to pass to the language-specific bindings
4060 /// generator.
4161 ///
4262 /// This is either a string which is whitespace delimited or it's an array
4363 /// of strings. By default no extra arguments are passed.
4464 #[ serde( default ) ]
4565 pub args : StringList ,
46- //
47- // Maybe add something like this eventually if necessary? For example plumb
48- // arbitrary configuration from tests to the "compile" backend. This would
49- // then thread through as `Compile` and could be used to pass compiler flags
50- // for example.
51- //
52- // lang: HashMap<String, String>,
5366
54- // ...
55- //
56- // or alternatively could also have something dedicated like:
57- // compile_flags: StringList,
67+ /// Language-specific configuration
5868 //
59- // unclear! This should be expanded on over time as necessary.
69+ // Note that this is an `Option<T>` where `T` defaults to a catch-all hash
70+ // map with a bunch of toml values in it. The idea here is that tests are
71+ // first parsed with the `HashMap` configuration. If that's not present
72+ // then the language uses its default configuration but if it is present
73+ // then the fields are re-parsed where `T` is specific-per-language. The
74+ // `Component::deserialize_lang_config` helper is intended for this.
75+ pub lang : Option < T > ,
6076}
6177
6278#[ derive( Deserialize ) ]
0 commit comments