-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2563aed
commit 6b1e44e
Showing
11 changed files
with
654 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2025 Jonas Kruckenberg | ||
// | ||
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or | ||
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or | ||
// http://opensource.org/licenses/MIT>, at your option. This file may not be | ||
// copied, modified, or distributed except according to those terms. | ||
|
||
use ktest::Test; | ||
|
||
#[derive(Default)] | ||
pub struct Arguments<'a> { | ||
pub test_name: Option<&'a str>, | ||
pub list: bool, | ||
pub include_ignored: bool, | ||
pub ignored: bool, | ||
pub exact: bool, | ||
pub format: FormatSetting, | ||
} | ||
|
||
#[derive(Default, Copy, Clone)] | ||
pub enum FormatSetting { | ||
#[default] | ||
Pretty, | ||
Terse, | ||
Json, | ||
} | ||
|
||
impl<'a> Arguments<'a> { | ||
#[allow(clippy::should_implement_trait)] | ||
pub fn from_str(str: &'a str) -> Self { | ||
Self::parse(str.split_ascii_whitespace()) | ||
} | ||
|
||
pub fn parse(mut iter: impl Iterator<Item = &'a str>) -> Self { | ||
let mut out = Self::default(); | ||
|
||
while let Some(str) = iter.next() { | ||
match str { | ||
"--list" => out.list = true, | ||
"--include-ignored" => out.include_ignored = true, | ||
"--ignored" => out.ignored = true, | ||
"--exact" => out.exact = true, | ||
"--format" => match iter.next().unwrap() { | ||
"pretty" => out.format = FormatSetting::Pretty, | ||
"terse" => out.format = FormatSetting::Terse, | ||
"json" => out.format = FormatSetting::Json, | ||
_ => {} | ||
}, | ||
_ => out.test_name = Some(str), | ||
} | ||
} | ||
|
||
out | ||
} | ||
|
||
/// Returns `true` if the given test should be ignored. | ||
pub fn is_ignored(&self, test: &Test) -> bool { | ||
test.info.ignored && !self.ignored && !self.include_ignored | ||
} | ||
} |
Oops, something went wrong.