chore: apply clippy lints
This commit is contained in:
parent
1dcd1e955d
commit
963ce0174b
7 changed files with 38 additions and 41 deletions
|
@ -425,7 +425,7 @@ mod tests {
|
|||
assert!(job.scheduled_at.is_none());
|
||||
assert!(job.finished_at.is_none());
|
||||
assert_eq!(
|
||||
db.get_all_jobs_of_state(&*JOB_STATE_CREATE).await.unwrap(),
|
||||
db.get_all_jobs_of_state(&JOB_STATE_CREATE).await.unwrap(),
|
||||
vec![job, job2.clone()]
|
||||
);
|
||||
|
||||
|
@ -433,7 +433,7 @@ mod tests {
|
|||
let job = db.get_job(COMMIT_HASH).await.unwrap();
|
||||
assert!(job.scheduled_at.is_some());
|
||||
assert_eq!(
|
||||
db.get_all_jobs_of_state(&*JOB_STATE_RUNNING).await.unwrap(),
|
||||
db.get_all_jobs_of_state(&JOB_STATE_RUNNING).await.unwrap(),
|
||||
vec![job]
|
||||
);
|
||||
|
||||
|
@ -441,7 +441,7 @@ mod tests {
|
|||
let job = db.get_job(COMMIT_HASH).await.unwrap();
|
||||
assert!(job.finished_at.is_some());
|
||||
assert_eq!(
|
||||
db.get_all_jobs_of_state(&*JOB_STATE_FINISH).await.unwrap(),
|
||||
db.get_all_jobs_of_state(&JOB_STATE_FINISH).await.unwrap(),
|
||||
vec![job]
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
|
@ -105,7 +105,7 @@ impl DockerLike for Docker {
|
|||
Command::new("docker")
|
||||
.args(args)
|
||||
.spawn()
|
||||
.expect(&format!("unable to remove docker container {name}"));
|
||||
.unwrap_or_else(|_| panic!("unable to remove docker container {name}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ use std::sync::Arc;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JValue;
|
||||
|
||||
use crate::docker::Docker;
|
||||
use crate::docker::DockerLike;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
|
||||
|
@ -61,7 +60,7 @@ impl DockerCompose {
|
|||
return containers;
|
||||
}
|
||||
|
||||
return Vec::default();
|
||||
Vec::default()
|
||||
}
|
||||
|
||||
pub fn up(&self) {
|
||||
|
@ -90,7 +89,7 @@ impl DockerCompose {
|
|||
.current_dir(&self.base_dir)
|
||||
.args(opts)
|
||||
.spawn()
|
||||
.expect(&format!("unable to remove"));
|
||||
.expect("unable to remove");
|
||||
child.wait().unwrap();
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +98,8 @@ impl DockerCompose {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::docker::Docker;
|
||||
|
||||
#[test]
|
||||
fn test_docker_compose() {
|
||||
DockerCompose::version();
|
||||
|
|
|
@ -85,7 +85,7 @@ mod tests {
|
|||
let repo = tmp.join("git_works");
|
||||
let contents = fs::read_to_string(repo.join("2_commit.txt")).unwrap();
|
||||
let commits = fs::read_to_string(commits_file).unwrap();
|
||||
assert_eq!(commits.lines().into_iter().count(), 2);
|
||||
assert_eq!(commits.lines().count(), 2);
|
||||
assert!(contents.contains("bar"));
|
||||
assert!(!contents.contains("new commit"));
|
||||
|
||||
|
@ -101,7 +101,7 @@ mod tests {
|
|||
Git::pull(&repo, "master");
|
||||
|
||||
let new_commits = fs::read_to_string(commits_file).unwrap();
|
||||
assert_eq!(new_commits.lines().into_iter().count(), 3);
|
||||
assert_eq!(new_commits.lines().count(), 3);
|
||||
|
||||
let changes = Git::files_changed_from_previous_commit(&repo);
|
||||
assert_eq!(changes.len(), 1);
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::complaince::target::Target;
|
||||
use crate::docker::Docker;
|
||||
use crate::docker::DockerLike;
|
||||
use crate::utils::get_random;
|
||||
use crate::AppCtx;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use url::Url;
|
|||
use super::results::*;
|
||||
use crate::complaince::result::Result as CResult;
|
||||
use crate::complaince::suite::Suite;
|
||||
use crate::complaince::suite::Test;
|
||||
use crate::utils::get_random;
|
||||
|
||||
pub struct SuiteRunnerState {
|
||||
|
@ -21,6 +22,7 @@ pub struct SuiteRunnerState {
|
|||
pub struct TestRunnerState {
|
||||
rx: Receiver<CResult>,
|
||||
container_name: String,
|
||||
test: Test,
|
||||
}
|
||||
|
||||
impl SuiteRunnerState {
|
||||
|
@ -29,8 +31,8 @@ impl SuiteRunnerState {
|
|||
suite: &crate::complaince::suite::Suite,
|
||||
ctx: &crate::ctx::ArcCtx,
|
||||
) -> ArchivableSuiteResult {
|
||||
let state = Self::launch_suite(container_host, suite, &ctx);
|
||||
state.collect_results(&ctx).await
|
||||
let state = Self::launch_suite(container_host, suite, ctx);
|
||||
state.collect_results(ctx).await
|
||||
}
|
||||
|
||||
fn launch_suite(
|
||||
|
@ -54,6 +56,7 @@ impl SuiteRunnerState {
|
|||
env.extend(custom_vars);
|
||||
}
|
||||
let name = format!("{}---{}--{}", suite.name, test.name, &auth[0..5]);
|
||||
tracing::info!("Starting {name} with env vars {:?}", &env);
|
||||
|
||||
ctx.docker.run_container(
|
||||
&name,
|
||||
|
@ -74,6 +77,7 @@ impl SuiteRunnerState {
|
|||
TestRunnerState {
|
||||
container_name: name,
|
||||
rx,
|
||||
test: test.clone(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -86,12 +90,8 @@ impl SuiteRunnerState {
|
|||
|
||||
async fn collect_results(mut self, ctx: &crate::ctx::ArcCtx) -> ArchivableSuiteResult {
|
||||
let mut tests = Vec::with_capacity(self.tests.len());
|
||||
for (auth, mut r) in self.tests.drain() {
|
||||
for (_auth, mut r) in self.tests.drain() {
|
||||
let result = r.rx.recv().await.unwrap();
|
||||
{
|
||||
let mut w = ctx.results.write().unwrap();
|
||||
w.remove(&auth);
|
||||
}
|
||||
let log = ctx.docker.get_logs(&r.container_name);
|
||||
ctx.docker.rm_container(&r.container_name, true);
|
||||
let container = ArchivableContainer {
|
||||
|
@ -105,22 +105,21 @@ impl SuiteRunnerState {
|
|||
container,
|
||||
};
|
||||
let s = ArchivableTest {
|
||||
name: result.test.name,
|
||||
url: result.test.url,
|
||||
version: result.test.version,
|
||||
container: result.test.container,
|
||||
env_vars: result.test.env_vars,
|
||||
name: r.test.name,
|
||||
url: r.test.url,
|
||||
version: r.test.version,
|
||||
container: r.test.container,
|
||||
env_vars: r.test.env_vars,
|
||||
result: res,
|
||||
};
|
||||
|
||||
tests.push(s);
|
||||
}
|
||||
|
||||
let res = ArchivableSuiteResult {
|
||||
ArchivableSuiteResult {
|
||||
suite: self.suite.clone(),
|
||||
tests,
|
||||
};
|
||||
res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,18 +235,17 @@ mod tests {
|
|||
|
||||
for (k, v) in state.tests.iter() {
|
||||
assert_eq!(ctx.docker.get_exit_status(&v.container_name), 0);
|
||||
{
|
||||
let tx = {
|
||||
let r = ctx.results.read().unwrap();
|
||||
let tx = r.get(k).unwrap();
|
||||
let tx_result = CResult {
|
||||
test: dummy_test.clone(),
|
||||
success: true,
|
||||
// sent by the app
|
||||
logs: format!("{}{LOGS}", v.container_name),
|
||||
};
|
||||
r.get(k).unwrap().to_owned()
|
||||
};
|
||||
let tx_result = CResult {
|
||||
success: true,
|
||||
// sent by the app
|
||||
logs: format!("{}{LOGS}", v.container_name),
|
||||
};
|
||||
|
||||
tx.send(tx_result).await.unwrap();
|
||||
}
|
||||
tx.send(tx_result).await.unwrap();
|
||||
}
|
||||
let results = state.collect_results(&ctx).await;
|
||||
assert_eq!(results.tests.len(), 2);
|
||||
|
|
|
@ -12,11 +12,11 @@ use crate::AppCtx;
|
|||
|
||||
use crate::docker_compose::DockerCompose;
|
||||
|
||||
pub const FTEST_TARGET_FILE: &str = "ftest.toml";
|
||||
const FTEST_TARGET_FILE: &str = "ftest.toml";
|
||||
|
||||
pub async fn run_target(
|
||||
ctx: &AppCtx,
|
||||
target: &PathBuf,
|
||||
target: PathBuf,
|
||||
) -> (
|
||||
Vec<ArchivableSuiteResult>,
|
||||
Option<Vec<ArchivableInitResult>>,
|
||||
|
@ -30,13 +30,13 @@ pub async fn run_target(
|
|||
let ftest_def = fs::read_to_string(&ftest_path).unwrap();
|
||||
let target: Target = toml::from_str(&ftest_def).unwrap();
|
||||
|
||||
let init_containers = crate::runner::init_scripts::launch_init_containers(&ctx, &target);
|
||||
let init_containers = crate::runner::init_scripts::launch_init_containers(ctx, &target);
|
||||
|
||||
let mut suite_results = Vec::with_capacity(target.suites.len());
|
||||
|
||||
for suite in target.suites.iter() {
|
||||
let results =
|
||||
crate::runner::suite::SuiteRunnerState::run(&target.container_host, suite, &ctx).await;
|
||||
crate::runner::suite::SuiteRunnerState::run(&target.container_host, suite, ctx).await;
|
||||
suite_results.push(results)
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ pub async fn run_target(
|
|||
|
||||
pub fn get_targets(control: &Path) -> Vec<PathBuf> {
|
||||
let mut res = Vec::default();
|
||||
let files_changed = Git::files_changed_from_previous_commit(&control);
|
||||
let files_changed = Git::files_changed_from_previous_commit(control);
|
||||
|
||||
let targets = control.clone().join("targets");
|
||||
for entry in fs::read_dir(targets).unwrap() {
|
||||
|
|
Loading…
Reference in a new issue