Work on run info
This commit is contained in:
parent
fd6e49f6d2
commit
d911510a64
68
src/main.rs
68
src/main.rs
|
|
@ -22,9 +22,9 @@ use xshell::Shell;
|
|||
/// A more thorough information struct would likely be useful however
|
||||
/// this should the trick for now
|
||||
struct LastRuns {
|
||||
/// Duration of the last run with full clean
|
||||
/// Status of the last run with full clean
|
||||
last_run_clean: Option<RunStats>,
|
||||
/// Duration of the last run without a full clean
|
||||
/// Status of the last run without a full clean
|
||||
last_run_incremental: Option<RunStats>,
|
||||
}
|
||||
|
||||
|
|
@ -32,10 +32,18 @@ struct LastRuns {
|
|||
/// The stats of a run, useful to print more helpful progress info and debug infos
|
||||
struct RunStats {
|
||||
/// Duration of the last run without a full clean
|
||||
duration_skip: Duration,
|
||||
run_duration: Duration,
|
||||
/// Status of the last run
|
||||
run_status: RunStatus,
|
||||
}
|
||||
impl Default for RunStats{
|
||||
fn default() -> Self {
|
||||
Self{
|
||||
run_duration: Duration::from_secs(10),
|
||||
run_status: RunStatus::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Current run info, including the last run to save
|
||||
struct CurrentRunStats {
|
||||
|
|
@ -44,32 +52,58 @@ struct CurrentRunStats {
|
|||
/// Current run type
|
||||
run_type: RunType,
|
||||
/// The informations on the current run
|
||||
current_run: RunStats
|
||||
current_run: RunStats,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
/// A (very) simple run status
|
||||
enum RunStatus {
|
||||
/// The last run was a succes
|
||||
Succes,
|
||||
#[default]
|
||||
/// The tests failed to run
|
||||
Failure,
|
||||
}
|
||||
|
||||
enum RunType{
|
||||
#[derive(Clone, Copy)]
|
||||
enum RunType {
|
||||
Incremental,
|
||||
Clean,
|
||||
}
|
||||
|
||||
impl CurrentRunStats{
|
||||
impl CurrentRunStats {
|
||||
/// Generate a new run with the current context
|
||||
fn from_last_run_with_context(){}
|
||||
fn from_last_run_with_context(last_run: LastRuns, args: &CLIArgs) -> Self {
|
||||
let run_type = match args.skip_clean {
|
||||
true => RunType::Incremental,
|
||||
false => RunType::Clean,
|
||||
};
|
||||
Self {
|
||||
last_runs_save: last_run,
|
||||
run_type,
|
||||
current_run: RunStats::default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the last run to save it
|
||||
fn into_save_runs(){}
|
||||
fn into_save_runs(self) -> LastRuns {
|
||||
let mut last_runs = self.last_runs_save;
|
||||
match self.run_type {
|
||||
RunType::Incremental => last_runs.last_run_incremental = Some(self.current_run),
|
||||
RunType::Clean => last_runs.last_run_clean = Some(self.current_run),
|
||||
}
|
||||
last_runs
|
||||
}
|
||||
|
||||
/// Get the last run of the same type
|
||||
fn get_last_run(){}
|
||||
fn get_last_run(&self) -> &Option<RunStats>{
|
||||
match self.run_type{
|
||||
RunType::Incremental => &self.last_runs_save.last_run_incremental,
|
||||
RunType::Clean => &self.last_runs_save.last_run_clean,
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
|
|
@ -135,8 +169,9 @@ struct CLIArgs {
|
|||
fn main() -> anyhow::Result<()> {
|
||||
let args = CLIArgs::parse();
|
||||
|
||||
let last_run_status = load_status(&args);
|
||||
// let current_run_status= CurrentRun::from(&last_run_status);
|
||||
let run_status = load_status(&args);
|
||||
let run_status = CurrentRunStats::from_last_run_with_context(run_status, &args);
|
||||
|
||||
let new_progress_bar = || {
|
||||
ProgressBar::new_spinner()
|
||||
// .with_style(
|
||||
|
|
@ -161,11 +196,12 @@ fn main() -> anyhow::Result<()> {
|
|||
unimplemented!("Please run with tarpaulin for now")
|
||||
// run_tests_only(&sh, pb_model.clone(), &args)?;
|
||||
}
|
||||
(false, true) => run_coverage(&sh, new_progress_bar(), &args)?, // The coverage know wether to write the badge test with the cli args
|
||||
(false, false) => run_coverage(&sh, new_progress_bar(), &args)?,
|
||||
(false, true) => run_coverage(&sh, new_progress_bar(), &args, &run_status)?, // The coverage know wether to write the badge test with the cli args
|
||||
(false, false) => run_coverage(&sh, new_progress_bar(), &args, &run_status)?,
|
||||
}
|
||||
|
||||
if let Err(e) = save_status(&last_run_status) {
|
||||
// TODO: Maybe make save a method instead ?
|
||||
if let Err(e) = save_status(&run_status.into_save_runs()) {
|
||||
println!("Couldn't save the run configuration: {e}");
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -202,7 +238,7 @@ fn save_status(status: &LastRuns) -> anyhow::Result<()> {
|
|||
// FORMAT: 2025-03-10T20:00:03.543721Z INFO cargo_tarpaulin::process_handling::linux: Launching test
|
||||
// FORMAT: 2025-03-10T20:00:08.030646Z INFO cargo_tarpaulin::report: Coverage Results:
|
||||
// #[coverage(off)] // No real coverage can be done as it would recurse indefinitely
|
||||
fn run_coverage(_sh: &Shell, pb: ProgressBar, args: &CLIArgs) -> Result<(), anyhow::Error> {
|
||||
fn run_coverage(_sh: &Shell, pb: ProgressBar, args: &CLIArgs, run_info: &CurrentRunStats) -> Result<(), anyhow::Error> {
|
||||
let started = Instant::now();
|
||||
// FORMAT: 84.78% coverage, 78/92 lines covered, -15.22% change in coverage
|
||||
let pb = pb.with_message(format!(
|
||||
|
|
|
|||
Loading…
Reference in New Issue