Skip to content

Commit

Permalink
Add --strict-compile-id for compile id presence testing (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezyang authored Apr 24, 2024
1 parent 6c418cf commit fcbfbc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ pub struct Cli {
/// testing.
#[arg(long)]
strict: bool,
/// Return non-zero exit code if some log lines do not have associated compile id. Used for
/// unit testing
#[arg(long)]
strict_compile_id: bool,
/// Don't open browser at the end
#[arg(long)]
no_browser: bool,
Expand All @@ -43,6 +47,7 @@ fn main() -> anyhow::Result<()> {

let config = ParseConfig {
strict: cli.strict,
strict_compile_id: cli.strict_compile_id,
custom_parsers: Vec::new(),
};

Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod types;

pub struct ParseConfig {
pub strict: bool,
pub strict_compile_id: bool,
pub custom_parsers: Vec<Box<dyn crate::parsers::StructuredLogParser>>,
}

Expand Down Expand Up @@ -281,6 +282,8 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu

eprintln!("{:?}", stats);

let has_unknown_compile_id = directory.contains_key(&None);

let index_context = IndexContext {
css: CSS,
directory: directory
Expand Down Expand Up @@ -312,5 +315,9 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu
return Err(anyhow!("Something went wrong"));
}

if config.strict_compile_id && has_unknown_compile_id {
return Err(anyhow!("Some log entries did not have compile id"));
}

Ok(output)
}

0 comments on commit fcbfbc7

Please sign in to comment.