Skip to content

Commit 275bf8c

Browse files
committed
Get ride of Config on Runtime
Signed-off-by: Ryan Levick <[email protected]>
1 parent 62ef9a6 commit 275bf8c

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

tests/conformance-tests/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
fn main() {
2+
let spin_binary: std::path::PathBuf = std::env::args()
3+
.skip(1)
4+
.next()
5+
.expect("expected first argument to be path to spin binary")
6+
.into();
27
let tests_dir = conformance_tests::download_tests().unwrap();
38

49
for test in conformance_tests::tests(&tests_dir).unwrap() {
5-
let spin_binary = "/Users/rylev/.local/bin/spin".into();
610
let env_config = testing_framework::TestEnvironmentConfig::spin(
7-
spin_binary,
11+
spin_binary.clone(),
812
[],
913
move |e| {
1014
e.copy_into(&test.manifest, "spin.toml")?;

tests/runtime-tests/src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ use testing_framework::{
66
in_process_spin::InProcessSpin,
77
spin_cli::{SpinCli, SpinConfig},
88
},
9-
EnvTemplate, OnTestError, Runtime, ServicesConfig, TestEnvironment, TestEnvironmentConfig,
10-
TestError, TestResult,
9+
EnvTemplate, OnTestError, ServicesConfig, TestEnvironment, TestEnvironmentConfig, TestError,
10+
TestResult,
1111
};
1212

1313
/// Configuration for a runtime test
14-
pub struct RuntimeTestConfig<R: Runtime> {
14+
pub struct RuntimeTestConfig<R> {
15+
/// Path to the test
1516
pub test_path: PathBuf,
16-
pub runtime_config: R::Config,
17+
/// Specific configuration for the runtime
18+
pub runtime_config: R,
19+
/// What to do when a test errors
1720
pub on_error: OnTestError,
1821
}
1922

@@ -47,7 +50,7 @@ impl RuntimeTest<SpinCli> {
4750
})
4851
}
4952

50-
pub fn bootstrap(config: RuntimeTestConfig<SpinCli>) -> anyhow::Result<Self> {
53+
pub fn bootstrap(config: RuntimeTestConfig<SpinConfig>) -> anyhow::Result<Self> {
5154
log::info!("Testing: {}", config.test_path.display());
5255
let test_path_clone = config.test_path.to_owned();
5356
let spin_binary = config.runtime_config.binary_path.clone();
@@ -116,7 +119,7 @@ impl RuntimeTest<InProcessSpin> {
116119
})
117120
}
118121

119-
pub fn bootstrap(config: RuntimeTestConfig<InProcessSpin>) -> anyhow::Result<Self> {
122+
pub fn bootstrap(config: RuntimeTestConfig<()>) -> anyhow::Result<Self> {
120123
log::info!("Testing: {}", config.test_path.display());
121124
let test_path_clone = config.test_path.to_owned();
122125
let preboot = move |env: &mut TestEnvironment<InProcessSpin>| {
@@ -258,7 +261,7 @@ impl<R> RuntimeTest<R> {
258261
}
259262
}
260263

261-
fn services_config<R: Runtime>(config: &RuntimeTestConfig<R>) -> anyhow::Result<ServicesConfig> {
264+
fn services_config<R>(config: &RuntimeTestConfig<R>) -> anyhow::Result<ServicesConfig> {
262265
let required_services = required_services(&config.test_path)?;
263266
let services_config = ServicesConfig::new(required_services)?;
264267
Ok(services_config)

tests/testing-framework/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ pub enum OnTestError {
2626

2727
/// A runtime which can be tested
2828
pub trait Runtime {
29-
type Config;
30-
31-
/// Return an error if one has occurred
29+
/// Return an error if the runtime has errored
3230
fn error(&mut self) -> anyhow::Result<()>;
3331
}
3432

tests/testing-framework/src/runtimes/in_process_spin.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ impl InProcessSpin {
5252
}
5353

5454
impl Runtime for InProcessSpin {
55-
type Config = ();
56-
5755
fn error(&mut self) -> anyhow::Result<()> {
5856
Ok(())
5957
}

tests/testing-framework/src/runtimes/spin_cli.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ impl Drop for SpinCli {
256256
}
257257

258258
impl Runtime for SpinCli {
259-
type Config = SpinConfig;
260-
261259
fn error(&mut self) -> anyhow::Result<()> {
262260
if !matches!(self.io_mode, IoMode::None) && self.try_wait()?.is_some() {
263261
anyhow::bail!("Spin exited early: {}", self.stderr());

tests/testing-framework/src/test_environment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use anyhow::Context as _;
1313
/// A callback to create a runtime given a path to a temporary directory and a set of services
1414
pub type RuntimeCreator<R> = dyn FnOnce(&mut TestEnvironment<R>) -> anyhow::Result<R>;
1515

16-
/// All the requirements to run a test
16+
/// An environment for running tests
1717
pub struct TestEnvironment<R> {
1818
temp: temp_dir::TempDir,
1919
services: Services,

0 commit comments

Comments
 (0)