Skip to content

Commit c445ba0

Browse files
committed
rust: bear output writer is a separate module
1 parent a1d2129 commit c445ba0

File tree

4 files changed

+414
-405
lines changed

4 files changed

+414
-405
lines changed

rust/bear/src/compilation.rs

Lines changed: 0 additions & 191 deletions
This file was deleted.

rust/bear/src/config.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const SUPPORTED_SCHEMA_VERSION: &str = "4.0";
2828
const PRELOAD_LIBRARY_PATH: &str = env!("PRELOAD_LIBRARY_PATH");
2929
const WRAPPER_EXECUTABLE_PATH: &str = env!("WRAPPER_EXECUTABLE_PATH");
3030

31-
3231
/// Represents the application configuration.
3332
///
3433
/// ```yaml
@@ -146,7 +145,9 @@ impl Main {
146145
pub fn from_file(file: &Path) -> Result<Self> {
147146
info!("Loading configuration file: {}", file.display());
148147

149-
let reader = OpenOptions::new().read(true).open(file)
148+
let reader = OpenOptions::new()
149+
.read(true)
150+
.open(file)
150151
.with_context(|| format!("Failed to open configuration file: {:?}", file))?;
151152

152153
let content = Self::from_reader(reader)
@@ -216,7 +217,7 @@ impl Default for Intercept {
216217
Intercept::Wrapper {
217218
path: default_wrapper_executable(),
218219
directory: default_wrapper_directory(),
219-
executables: vec![], // FIXME: better default value
220+
executables: vec![], // FIXME: better default value
220221
}
221222
}
222223
}
@@ -241,8 +242,7 @@ pub enum Output {
241242
format: Format,
242243
},
243244
#[serde(rename = "bear")]
244-
Semantic {
245-
},
245+
Semantic {},
246246
}
247247

248248
/// The default output is the clang format.
@@ -276,7 +276,7 @@ pub struct Transform {
276276
/// - Compilers: Specify on the compiler path and arguments.
277277
/// - Source: Specify the source file location.
278278
/// - Duplicates: Specify the fields of the JSON compilation database record to detect duplicates.
279-
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
279+
#[derive(Debug, PartialEq, Deserialize, Serialize)]
280280
pub struct Filter {
281281
#[serde(default)]
282282
pub compilers: CompilerFilter,
@@ -330,7 +330,7 @@ pub struct SourceFilter {
330330
/// Duplicate filter configuration is used to filter the duplicate compiler calls.
331331
///
332332
/// - By fields: Specify the fields of the JSON compilation database record to detect duplicates.
333-
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
333+
#[derive(Debug, PartialEq, Deserialize, Serialize)]
334334
pub struct DuplicateFilter {
335335
pub by_fields: Vec<OutputFields>,
336336
}
@@ -417,8 +417,8 @@ where
417417

418418
#[cfg(test)]
419419
mod test {
420-
use crate::{vec_of_pathbuf, vec_of_strings};
421420
use super::*;
421+
use crate::{vec_of_pathbuf, vec_of_strings};
422422

423423
#[test]
424424
fn test_wrapper_config() {
@@ -485,7 +485,7 @@ mod test {
485485
},
486486
duplicates: DuplicateFilter {
487487
by_fields: vec![OutputFields::File, OutputFields::Directory],
488-
}
488+
},
489489
},
490490
format: Format {
491491
command_as_array: true,
@@ -516,8 +516,7 @@ mod test {
516516
intercept: Intercept::Preload {
517517
path: PathBuf::from("/usr/local/lib/libexec.so"),
518518
},
519-
output: Output::Semantic {
520-
},
519+
output: Output::Semantic {},
521520
schema: String::from("4.0"),
522521
};
523522

@@ -559,7 +558,10 @@ mod test {
559558
assert!(result.is_err());
560559

561560
let message = result.unwrap_err().to_string();
562-
assert_eq!("Unsupported schema version: 3.0. Expected: 4.0 at line 2 column 9", message);
561+
assert_eq!(
562+
"Unsupported schema version: 3.0. Expected: 4.0 at line 2 column 9",
563+
message
564+
);
563565
}
564566

565567
#[test]
@@ -579,4 +581,4 @@ mod test {
579581

580582
assert!(result.is_err());
581583
}
582-
}
584+
}

0 commit comments

Comments
 (0)