use serde::{Deserialize, Serialize};
use std::{sync::Arc, time::Duration};
use wasmer_backend_api::types::PackageVersionWithPackage;
use super::ArgusConfig;
pub(crate) mod cli_tester;
#[cfg(feature = "wasmer_lib")]
pub(crate) mod lib_tester;
#[async_trait::async_trait]
pub(crate) trait Tester: Send + Sync {
async fn is_to_test(&self) -> bool;
async fn run_test(&self) -> anyhow::Result<TestReport>;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TestReport {
pub package_namespace: String,
pub package_name: String,
pub package_version: String,
pub runner_id: String,
pub runner_version: String,
pub compiler_backend: String,
pub time: Duration,
pub outcome: Result<String, String>,
}
impl TestReport {
pub fn new(
package: &PackageVersionWithPackage,
runner_id: String,
runner_version: String,
compiler_backend: String,
time: Duration,
outcome: Result<String, String>,
) -> Self {
Self {
package_namespace: match &package.package.namespace {
Some(ns) => ns.clone(),
None => String::from("unknown_namespace"),
},
package_name: package.package.package_name.clone(),
package_version: package.version.clone(),
runner_id,
runner_version,
compiler_backend,
time,
outcome,
}
}
pub fn to_test(&self, _config: Arc<ArgusConfig>) -> bool {
true
}
}