-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: impl basic test suite loader and runner
Signed-off-by: peefy <[email protected]>
- Loading branch information
Showing
16 changed files
with
492 additions
and
28 deletions.
There are no files selected for viewing
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 @@ | ||
a = 1 |
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 @@ | ||
a = 1 |
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 @@ | ||
a = 2 |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod fix; | ||
pub mod format; | ||
pub mod lint; | ||
pub mod testing; | ||
pub mod util; | ||
pub mod vet; |
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,49 @@ | ||
//! [kclvm_tools::test] module mainly contains some functions of language testing tool. | ||
pub use crate::testing::suite::{load_test_suites, TestSuite}; | ||
use anyhow::{Error, Result}; | ||
use indexmap::IndexMap; | ||
use kclvm_runner::ExecProgramArgs; | ||
use std::time::Duration; | ||
|
||
mod suite; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
/// Trait for running tests. | ||
pub trait TestRun { | ||
type Options; | ||
type Result; | ||
|
||
/// Run the test with the given options and return the result. | ||
fn run(&self, opts: &Self::Options) -> Result<Self::Result>; | ||
} | ||
|
||
/// Represents the result of a test. | ||
#[derive(Debug, Default)] | ||
pub struct TestResult { | ||
/// This field stores the log message of the test. | ||
pub log_message: String, | ||
/// This field stores test case information in an [IndexMap], where the key is a [String] and the value is a [TestCaseInfo] struct. | ||
pub info: IndexMap<String, TestCaseInfo>, | ||
} | ||
|
||
/// Represents information about a test case. | ||
#[derive(Debug, Default)] | ||
pub struct TestCaseInfo { | ||
/// This field stores the error associated with the test case, if any. | ||
pub error: Option<Error>, | ||
/// This field stores the duration of the test case. | ||
pub duration: Duration, | ||
} | ||
|
||
/// Represents options for running tests. | ||
#[derive(Debug, Default, Clone)] | ||
pub struct TestOptions { | ||
/// This field stores the execution program arguments. | ||
pub exec_args: ExecProgramArgs, | ||
/// This field stores a regular expression for filtering tests to run. | ||
pub run_regexp: String, | ||
/// This field determines whether the test run should stop on the first failure. | ||
pub fail_fast: bool, | ||
} |
Oops, something went wrong.