only build image once per test runner run
This commit is contained in:
parent
1d616e822d
commit
9101bb1046
@ -2,8 +2,8 @@ use std::fs;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::{self, Child, Output};
|
use std::process::{self, Child, Output};
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::sync::atomic;
|
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
use std::sync::{atomic, Once};
|
||||||
|
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
@ -17,6 +17,7 @@ pub struct Container {
|
|||||||
impl Container {
|
impl Container {
|
||||||
/// Starts the container in a "parked" state
|
/// Starts the container in a "parked" state
|
||||||
pub fn run() -> Result<Self> {
|
pub fn run() -> Result<Self> {
|
||||||
|
static ONCE: Once = Once::new();
|
||||||
static COUNT: AtomicUsize = AtomicUsize::new(0);
|
static COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
// TODO configurable: hickory; bind
|
// TODO configurable: hickory; bind
|
||||||
@ -37,11 +38,11 @@ impl Container {
|
|||||||
.arg("-f")
|
.arg("-f")
|
||||||
.arg(dockerfile_path)
|
.arg(dockerfile_path)
|
||||||
.arg(docker_dir_path);
|
.arg(docker_dir_path);
|
||||||
let status = command.status()?;
|
|
||||||
|
|
||||||
if !status.success() {
|
ONCE.call_once(|| {
|
||||||
return Err(format!("`{command:?}` failed").into());
|
let status = command.status().unwrap();
|
||||||
}
|
assert!(status.success());
|
||||||
|
});
|
||||||
|
|
||||||
let mut command = Command::new("docker");
|
let mut command = Command::new("docker");
|
||||||
let pid = process::id();
|
let pid = process::id();
|
||||||
|
Loading…
Reference in New Issue
Block a user