diff options
Diffstat (limited to 'cli/args/config_file.rs')
-rw-r--r-- | cli/args/config_file.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/cli/args/config_file.rs b/cli/args/config_file.rs index a0a5837fb..48f77d009 100644 --- a/cli/args/config_file.rs +++ b/cli/args/config_file.rs @@ -397,6 +397,28 @@ pub struct FmtConfig { pub files: FilesConfig, } +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(default, deny_unknown_fields)] +struct SerializedTestConfig { + pub files: SerializedFilesConfig, +} + +impl SerializedTestConfig { + pub fn into_resolved( + self, + config_file_specifier: &ModuleSpecifier, + ) -> Result<TestConfig, AnyError> { + Ok(TestConfig { + files: self.files.into_resolved(config_file_specifier)?, + }) + } +} + +#[derive(Clone, Debug, Default)] +pub struct TestConfig { + pub files: FilesConfig, +} + #[derive(Clone, Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ConfigFileJson { @@ -405,6 +427,7 @@ pub struct ConfigFileJson { pub lint: Option<Value>, pub fmt: Option<Value>, pub tasks: Option<Value>, + pub test: Option<Value>, } #[derive(Clone, Debug)] @@ -583,6 +606,16 @@ impl ConfigFile { } } + pub fn to_test_config(&self) -> Result<Option<TestConfig>, AnyError> { + if let Some(config) = self.json.test.clone() { + let lint_config: SerializedTestConfig = serde_json::from_value(config) + .context("Failed to parse \"test\" configuration")?; + Ok(Some(lint_config.into_resolved(&self.specifier)?)) + } else { + Ok(None) + } + } + /// Return any tasks that are defined in the configuration file as a sequence /// of JSON objects providing the name of the task and the arguments of the /// task in a detail field. |