summaryrefslogtreecommitdiff
path: root/cli/args/config_file.rs
diff options
context:
space:
mode:
authorGeert-Jan Zwiers <geertjanzwiers@protonmail.com>2022-12-10 02:30:47 +0100
committerGitHub <noreply@github.com>2022-12-10 02:30:47 +0100
commit890b0653104388bfef60ca7ebd0af758caf5f0be (patch)
tree8e31ad81f180c34dfd07088a790567ab72527b43 /cli/args/config_file.rs
parent4eb8e875fd6fc91ff1dbc34b7bc8750fff728a32 (diff)
feat(cli): support deno bench in the config file (#16608)
This PR adds the ability to set `include/exclude` fields for `deno bench` in the configuration file.
Diffstat (limited to 'cli/args/config_file.rs')
-rw-r--r--cli/args/config_file.rs37
1 files changed, 35 insertions, 2 deletions
diff --git a/cli/args/config_file.rs b/cli/args/config_file.rs
index 16e11a5a8..904efdff8 100644
--- a/cli/args/config_file.rs
+++ b/cli/args/config_file.rs
@@ -429,6 +429,28 @@ pub struct TestConfig {
pub files: FilesConfig,
}
+#[derive(Clone, Debug, Default, Deserialize)]
+#[serde(default, deny_unknown_fields)]
+struct SerializedBenchConfig {
+ pub files: SerializedFilesConfig,
+}
+
+impl SerializedBenchConfig {
+ pub fn into_resolved(
+ self,
+ config_file_specifier: &ModuleSpecifier,
+ ) -> Result<BenchConfig, AnyError> {
+ Ok(BenchConfig {
+ files: self.files.into_resolved(config_file_specifier)?,
+ })
+ }
+}
+
+#[derive(Clone, Debug, Default)]
+pub struct BenchConfig {
+ pub files: FilesConfig,
+}
+
#[derive(Clone, Debug, Deserialize)]
#[serde(untagged)]
pub enum LockConfig {
@@ -445,6 +467,7 @@ pub struct ConfigFileJson {
pub fmt: Option<Value>,
pub tasks: Option<Value>,
pub test: Option<Value>,
+ pub bench: Option<Value>,
pub lock: Option<Value>,
}
@@ -653,9 +676,19 @@ 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)
+ let test_config: SerializedTestConfig = serde_json::from_value(config)
.context("Failed to parse \"test\" configuration")?;
- Ok(Some(lint_config.into_resolved(&self.specifier)?))
+ Ok(Some(test_config.into_resolved(&self.specifier)?))
+ } else {
+ Ok(None)
+ }
+ }
+
+ pub fn to_bench_config(&self) -> Result<Option<BenchConfig>, AnyError> {
+ if let Some(config) = self.json.bench.clone() {
+ let bench_config: SerializedBenchConfig = serde_json::from_value(config)
+ .context("Failed to parse \"bench\" configuration")?;
+ Ok(Some(bench_config.into_resolved(&self.specifier)?))
} else {
Ok(None)
}